mirror of
https://git.proxmox.com/git/efi-boot-shim
synced 2025-07-25 17:25:18 +00:00
lib: simple_file_selector(): simplify the error path to confuse covscan less.
Because they don't believe code should be defensive against future changes, covscan believes: 520 out_free: 521 FreePool(dmp); CID 182824 (#1 of 1): Dereference before null check (REVERSE_INULL)check_after_deref: Null-checking entries suggests that it may be null, but it has already been dereferenced on all paths leading to the check. 522 if (entries) { 523 free_entries(entries, count); 524 FreePool(entries); 525 } 526 out_free_name: 527 FreePool(name); 528} Which is technically correct, but still kind of dumb. So this patch combines the two error out paths into just being out_free, so that the first path there is before entries is allocated. (It also initializes dmp to NULL and checks that before freeing it.) I also Lindent-ed that function. Signed-off-by: Peter Jones <pjones@redhat.com>
This commit is contained in:
parent
7ee19bdc41
commit
70a4c4a395
@ -399,12 +399,12 @@ free_entries(CHAR16 **entries, int count)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
simple_file_selector(EFI_HANDLE *im, CHAR16 **title, CHAR16 *name,
|
simple_file_selector(EFI_HANDLE * im, CHAR16 ** title, CHAR16 * name,
|
||||||
CHAR16 *filter, CHAR16 **result)
|
CHAR16 * filter, CHAR16 ** result)
|
||||||
{
|
{
|
||||||
EFI_STATUS status;
|
EFI_STATUS status;
|
||||||
CHAR16 **entries = NULL;
|
CHAR16 **entries = NULL;
|
||||||
EFI_FILE_INFO *dmp;
|
EFI_FILE_INFO *dmp = NULL;
|
||||||
int count, select, len;
|
int count, select, len;
|
||||||
CHAR16 *newname, *selected;
|
CHAR16 *newname, *selected;
|
||||||
|
|
||||||
@ -424,18 +424,17 @@ simple_file_selector(EFI_HANDLE *im, CHAR16 **title, CHAR16 *name,
|
|||||||
*im = h;
|
*im = h;
|
||||||
}
|
}
|
||||||
|
|
||||||
newname = AllocatePool((StrLen(name) + 1)*sizeof(CHAR16));
|
newname = AllocatePool((StrLen(name) + 1) * sizeof(CHAR16));
|
||||||
if (!newname)
|
if (!newname)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
StrCpy(newname, name);
|
StrCpy(newname, name);
|
||||||
name = newname;
|
name = newname;
|
||||||
|
|
||||||
redo:
|
redo:
|
||||||
status = simple_dir_filter(*im, name, filter, &entries, &count, &dmp);
|
status = simple_dir_filter(*im, name, filter, &entries, &count, &dmp);
|
||||||
|
|
||||||
if (status != EFI_SUCCESS)
|
if (status != EFI_SUCCESS)
|
||||||
goto out_free_name;
|
goto out_free;
|
||||||
|
|
||||||
select = console_select(title, entries, 0);
|
select = console_select(title, entries, 0);
|
||||||
if (select < 0)
|
if (select < 0)
|
||||||
@ -459,7 +458,6 @@ simple_file_selector(EFI_HANDLE *im, CHAR16 **title, CHAR16 *name,
|
|||||||
|
|
||||||
i = StrLen(name) - 1;
|
i = StrLen(name) - 1;
|
||||||
|
|
||||||
|
|
||||||
for (i = StrLen(name); i > 0; --i) {
|
for (i = StrLen(name); i > 0; --i) {
|
||||||
if (name[i] == '\\')
|
if (name[i] == '\\')
|
||||||
break;
|
break;
|
||||||
@ -477,11 +475,12 @@ simple_file_selector(EFI_HANDLE *im, CHAR16 **title, CHAR16 *name,
|
|||||||
goto redo;
|
goto redo;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
newname = AllocatePool((StrLen(name) + len + 2)*sizeof(CHAR16));
|
newname =
|
||||||
|
AllocatePool((StrLen(name) + len + 2) * sizeof(CHAR16));
|
||||||
if (!newname)
|
if (!newname)
|
||||||
goto out_free;
|
goto out_free;
|
||||||
StrCpy(newname, name);
|
StrCpy(newname, name);
|
||||||
|
|
||||||
if (name[StrLen(name) - 1] != '\\')
|
if (name[StrLen(name) - 1] != '\\')
|
||||||
StrCat(newname, L"\\");
|
StrCat(newname, L"\\");
|
||||||
StrCat(newname, selected);
|
StrCat(newname, selected);
|
||||||
@ -497,7 +496,7 @@ simple_file_selector(EFI_HANDLE *im, CHAR16 **title, CHAR16 *name,
|
|||||||
|
|
||||||
goto redo;
|
goto redo;
|
||||||
}
|
}
|
||||||
*result = AllocatePool((StrLen(name) + len + 2)*sizeof(CHAR16));
|
*result = AllocatePool((StrLen(name) + len + 2) * sizeof(CHAR16));
|
||||||
if (*result) {
|
if (*result) {
|
||||||
StrCpy(*result, name);
|
StrCpy(*result, name);
|
||||||
if (name[StrLen(name) - 1] != '\\')
|
if (name[StrLen(name) - 1] != '\\')
|
||||||
@ -505,12 +504,12 @@ simple_file_selector(EFI_HANDLE *im, CHAR16 **title, CHAR16 *name,
|
|||||||
StrCat(*result, selected);
|
StrCat(*result, selected);
|
||||||
}
|
}
|
||||||
|
|
||||||
out_free:
|
out_free:
|
||||||
FreePool(dmp);
|
if (dmp)
|
||||||
|
FreePool(dmp);
|
||||||
if (entries) {
|
if (entries) {
|
||||||
free_entries(entries, count);
|
free_entries(entries, count);
|
||||||
FreePool(entries);
|
FreePool(entries);
|
||||||
}
|
}
|
||||||
out_free_name:
|
|
||||||
FreePool(name);
|
FreePool(name);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user