Exit our dir->Read() loop if it says there's 0 bytes of data to read.

When dir->Read() says bs=0, we shouldn't try to allocate a buffer and
read into it. On edk2 this works because there's an implicit (possibly
accidental) minimum size of one pool list entry that can be allocated,
so you wind up getting (I think) 8 bytes.

When Rob Clark tried to run this under uboot's emulated UEFI
environment, dir->Read() returned 0 and when we passed that to
AllocateZeroPool() less good things happened.

So just check for that case and exit appropriately.

Signed-off-by: Peter Jones <pjones@redhat.com>
This commit is contained in:
Peter Jones 2017-07-24 14:02:37 -04:00
parent c4aa058c2b
commit d89b722ef7

View File

@ -591,6 +591,10 @@ find_boot_csv(EFI_FILE_HANDLE fh, CHAR16 *dirname)
FreePool(buffer);
return rc;
}
/* If there's no data to read, don't try to allocate 0 bytes
* and read the data... */
if (bs == 0)
break;
buffer = AllocateZeroPool(bs);
if (!buffer) {