summaryrefslogtreecommitdiff
path: root/fallback.c
diff options
context:
space:
mode:
authorPeter Jones <pjones@redhat.com>2017-07-24 14:02:37 -0400
committerPeter Jones <pjones@redhat.com>2017-07-24 14:02:37 -0400
commitd89b722ef7059b81a480419ba7b81f1143f085e5 (patch)
treea9ac4cfa49e1034aac01c0990e8f86a13768f063 /fallback.c
parentc4aa058c2b39f01a4b4486e0a8ae8122f6508d2c (diff)
downloadefi-boot-shim-d89b722ef7059b81a480419ba7b81f1143f085e5.tar.gz
efi-boot-shim-d89b722ef7059b81a480419ba7b81f1143f085e5.zip
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>
Diffstat (limited to 'fallback.c')
-rw-r--r--fallback.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/fallback.c b/fallback.c
index 5e4a3963..81f5303a 100644
--- a/fallback.c
+++ b/fallback.c
@@ -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) {