summaryrefslogtreecommitdiff
path: root/firmware/lib/cgptlib
diff options
context:
space:
mode:
authorNam T. Nguyen <namnguyen@chromium.org>2014-10-30 15:09:43 -0700
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2014-10-31 20:55:31 +0000
commit5ce8325f4ac4662d0daef63878c85462a8e59ff4 (patch)
treefa11c0a60e8e754be8da762c2ccff03400419b9f /firmware/lib/cgptlib
parentf4f395e1ca724ef8795cfe86a9edbf15f14eacd1 (diff)
downloadvboot-5ce8325f4ac4662d0daef63878c85462a8e59ff4.tar.gz
vboot: cgpt: Check for NULL entry array.
When GptLoad() fails to validate a header, it will not load the corresponding entry array, and hence will not allocate memory. The "*_entries" pointer then stay NULL. This CL checks for NULL pointer in CheckEntries() in the same way that CheckHeader() does. BUG=none BRANCH=none TEST=unittest Change-Id: I9f72e843590fbcbcf90d55640f86c782446e8755 Reviewed-on: https://chromium-review.googlesource.com/226778 Reviewed-by: Bill Richardson <wfrichar@chromium.org> Commit-Queue: Nam Nguyen <namnguyen@chromium.org> Tested-by: Nam Nguyen <namnguyen@chromium.org>
Diffstat (limited to 'firmware/lib/cgptlib')
-rw-r--r--firmware/lib/cgptlib/cgptlib_internal.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/firmware/lib/cgptlib/cgptlib_internal.c b/firmware/lib/cgptlib/cgptlib_internal.c
index 9fdf9e28..4eea03df 100644
--- a/firmware/lib/cgptlib/cgptlib_internal.c
+++ b/firmware/lib/cgptlib/cgptlib_internal.c
@@ -131,6 +131,8 @@ int IsKernelEntry(const GptEntry *e)
int CheckEntries(GptEntry *entries, GptHeader *h)
{
+ if (!entries)
+ return GPT_ERROR_INVALID_ENTRIES;
GptEntry *entry;
uint32_t crc32;
uint32_t i;