| 411 | } |
| 412 | |
| 413 | static int Ext2FillEntry(void *context, const char *name, int namlen, |
| 414 | ULONG offset, __u32 ino, unsigned int d_type) |
| 415 | { |
| 416 | PEXT2_FILLDIR_CONTEXT fc = context; |
| 417 | PEXT2_IRP_CONTEXT IrpContext = fc->efc_irp; |
| 418 | |
| 419 | PEXT2_FCB Fcb = IrpContext->Fcb; |
| 420 | PEXT2_CCB Ccb = IrpContext->Ccb; |
| 421 | PEXT2_VCB Vcb = Fcb->Vcb; |
| 422 | |
| 423 | OEM_STRING Oem; |
| 424 | UNICODE_STRING Unicode = { 0 }; |
| 425 | NTSTATUS Status = STATUS_SUCCESS; |
| 426 | ULONG EntrySize; |
| 427 | USHORT NameLen; |
| 428 | int rc = 0; |
| 429 | |
| 430 | if (fc->efc_start > 0 && (fc->efc_single || (fc->efc_size < |
| 431 | fc->efc_start + namlen * 2 + Ext2GetInfoLength(fc->efc_fi)) )) { |
| 432 | rc = 1; |
| 433 | goto errorout; |
| 434 | } |
| 435 | |
| 436 | |
| 437 | Oem.Buffer = (void *)name; |
| 438 | Oem.Length = namlen & 0xFF; |
| 439 | Oem.MaximumLength = Oem.Length; |
| 440 | |
| 441 | /* skip . and .. */ |
| 442 | if ((Oem.Length == 1 && name[0] == '.') || (Oem.Length == 2 && |
| 443 | name[0] == '.' && name[1] == '.' )) { |
| 444 | goto errorout; |
| 445 | } |
| 446 | |
| 447 | if (Ext2IsWearingCloak(Vcb, &Oem)) { |
| 448 | goto errorout; |
| 449 | } |
| 450 | |
| 451 | NameLen = (USHORT)Ext2OEMToUnicodeSize(Vcb, &Oem); |
| 452 | if (NameLen <= 0) { |
| 453 | fc->efc_status = STATUS_INSUFFICIENT_RESOURCES; |
| 454 | rc = -ENOMEM; |
| 455 | goto errorout; |
| 456 | } |
| 457 | |
| 458 | Unicode.MaximumLength = NameLen + 2; |
| 459 | Unicode.Buffer = Ext2AllocatePool( |
| 460 | PagedPool, |
| 461 | Unicode.MaximumLength, |
| 462 | EXT2_INAME_MAGIC |
| 463 | ); |
| 464 | if (!Unicode.Buffer) { |
| 465 | DEBUG(DL_ERR, ( "Ex2QueryDirectory: failed to " |
| 466 | "allocate InodeFileName.\n")); |
| 467 | fc->efc_status = STATUS_INSUFFICIENT_RESOURCES; |
| 468 | rc = -ENOMEM; |
| 469 | goto errorout; |
| 470 | } |
nothing calls this directly
no test coverage detected