|
|
f2fa6b |
From 3a7feeff6cdb3b96a1ef2ccff8c150e2324d50a9 Mon Sep 17 00:00:00 2001
|
|
|
f2fa6b |
From: Peter Jones <pjones@redhat.com>
|
|
|
f2fa6b |
Date: Fri, 15 Nov 2013 09:38:41 -0500
|
|
|
f2fa6b |
Subject: [PATCH 16/19] Rewrite directory traversal allocation path so coverity
|
|
|
f2fa6b |
can grok it.
|
|
|
f2fa6b |
|
|
|
f2fa6b |
The things we do for our tools. In this case, make the AllocatePool()
|
|
|
f2fa6b |
happen outside of a conditional, even though that conditional will
|
|
|
f2fa6b |
always bee satisfied. This way coverity won't think we're setting fi
|
|
|
f2fa6b |
to NULL and passing it to StrCaseCmp.
|
|
|
f2fa6b |
|
|
|
f2fa6b |
Signed-off-by: Peter Jones <pjones@redhat.com>
|
|
|
f2fa6b |
---
|
|
|
f2fa6b |
fallback.c | 21 ++++++++++++++-------
|
|
|
f2fa6b |
1 file changed, 14 insertions(+), 7 deletions(-)
|
|
|
f2fa6b |
|
|
|
f2fa6b |
diff --git a/fallback.c b/fallback.c
|
|
|
f2fa6b |
index c875144..ba864ee 100644
|
|
|
f2fa6b |
--- a/fallback.c
|
|
|
f2fa6b |
+++ b/fallback.c
|
|
|
f2fa6b |
@@ -445,25 +445,32 @@ find_boot_csv(EFI_FILE_HANDLE fh, CHAR16 *dirname)
|
|
|
f2fa6b |
return EFI_SUCCESS;
|
|
|
f2fa6b |
}
|
|
|
f2fa6b |
FreePool(buffer);
|
|
|
f2fa6b |
+ buffer = NULL;
|
|
|
f2fa6b |
|
|
|
f2fa6b |
bs = 0;
|
|
|
f2fa6b |
do {
|
|
|
f2fa6b |
bs = 0;
|
|
|
f2fa6b |
rc = uefi_call_wrapper(fh->Read, 3, fh, &bs, NULL);
|
|
|
f2fa6b |
- if (rc == EFI_BUFFER_TOO_SMALL) {
|
|
|
f2fa6b |
- buffer = AllocateZeroPool(bs);
|
|
|
f2fa6b |
- if (!buffer) {
|
|
|
f2fa6b |
- Print(L"Could not allocate memory\n");
|
|
|
f2fa6b |
- return EFI_OUT_OF_RESOURCES;
|
|
|
f2fa6b |
- }
|
|
|
f2fa6b |
+ if (EFI_ERROR(rc) && rc != EFI_BUFFER_TOO_SMALL) {
|
|
|
f2fa6b |
+ Print(L"Could not read \\EFI\\%s\\: %d\n", dirname, rc);
|
|
|
f2fa6b |
+ if (buffer)
|
|
|
f2fa6b |
+ FreePool(buffer);
|
|
|
f2fa6b |
+ return rc;
|
|
|
f2fa6b |
+ }
|
|
|
f2fa6b |
|
|
|
f2fa6b |
- rc = uefi_call_wrapper(fh->Read, 3, fh, &bs, buffer);
|
|
|
f2fa6b |
+ buffer = AllocateZeroPool(bs);
|
|
|
f2fa6b |
+ if (!buffer) {
|
|
|
f2fa6b |
+ Print(L"Could not allocate memory\n");
|
|
|
f2fa6b |
+ return EFI_OUT_OF_RESOURCES;
|
|
|
f2fa6b |
}
|
|
|
f2fa6b |
+
|
|
|
f2fa6b |
+ rc = uefi_call_wrapper(fh->Read, 3, fh, &bs, buffer);
|
|
|
f2fa6b |
if (EFI_ERROR(rc)) {
|
|
|
f2fa6b |
Print(L"Could not read \\EFI\\%s\\: %d\n", dirname, rc);
|
|
|
f2fa6b |
FreePool(buffer);
|
|
|
f2fa6b |
return rc;
|
|
|
f2fa6b |
}
|
|
|
f2fa6b |
+
|
|
|
f2fa6b |
if (bs == 0)
|
|
|
f2fa6b |
break;
|
|
|
f2fa6b |
|
|
|
f2fa6b |
--
|
|
|
f2fa6b |
1.8.5.3
|
|
|
f2fa6b |
|