diff options
| author | Peter Jones <pjones@redhat.com> | 2025-03-12 16:11:58 -0400 |
|---|---|---|
| committer | Peter Jones <pjones@redhat.com> | 2025-03-14 11:05:05 -0400 |
| commit | 7b753820e79b5b38be59c40aaa7960eab0aae119 (patch) | |
| tree | 32fb6801fb17ff6d963c703b7397cd59dd26de42 | |
| parent | db0432183680121df2fcaba2b697025fef9db6ac (diff) | |
| download | efi-boot-shim-7b753820e79b5b38be59c40aaa7960eab0aae119.tar.gz efi-boot-shim-7b753820e79b5b38be59c40aaa7960eab0aae119.zip | |
simple_dir_filter(): test our 'next' pointer
"gcc -fanalyzer" thinks that in simple_dir_filter(), we can get "next"
to be a NULL pointer even when simple_dir_read_all() return success and
we're iterating the total number of entries it claimed it returned.
I don't think this is true, but to make it stop complaining I've added
tests to that pointer that'll make it stop if it gets to the end of the
list.
Signed-off-by: Peter Jones <pjones@redhat.com>
| -rw-r--r-- | lib/simple_file.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/simple_file.c b/lib/simple_file.c index 6057f883..abbc4975 100644 --- a/lib/simple_file.c +++ b/lib/simple_file.c @@ -288,7 +288,7 @@ simple_dir_filter(EFI_HANDLE image, CHAR16 *name, CHAR16 *filter, goto out; ptr = next = *entries; - for (i = 0; i < tot; i++) { + for (i = 0; next && i < tot; i++) { int len = StrLen(next->FileName); for (c = 0; c < filtercount; c++) { @@ -311,7 +311,7 @@ simple_dir_filter(EFI_HANDLE image, CHAR16 *name, CHAR16 *filter, *count = 0; ptr = next = *entries; - for (i = 0; i < tot; i++) { + for (i = 0; next && i < tot; i++) { int len = StrLen(next->FileName); if (StrCmp(next->FileName, L".") == 0) |
