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