Edward O'Callaghan has uploaded this change for review.

View Change

layout.c: Validate _layout_entry_by_name() arguments before use

It maybe the case that a layout could not be derived which
would result in layout logic feed with a NULL pointer. Validate
this case and be defensive to validate the name argument as well.

BUG=b:247055486
TEST=builds

Change-Id: I2a19c0e586f8575b8b3c2c02b5afad312efacfc9
Signed-off-by: Edward O'Callaghan <quasisec@google.com>
---
M layout.c
1 file changed, 19 insertions(+), 0 deletions(-)

git pull ssh://review.coreboot.org:29418/flashrom refs/changes/22/67722/1
diff --git a/layout.c b/layout.c
index 5916d66..0212699 100644
--- a/layout.c
+++ b/layout.c
@@ -58,6 +58,8 @@
const struct flashrom_layout *const layout, const char *name)
{
struct romentry *entry = NULL;
+ if (!layout || !name)
+ return NULL;
while ((entry = mutable_layout_next(layout, entry))) {
if (!strcmp(entry->name, name))
return entry;

To view, visit change 67722. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: I2a19c0e586f8575b8b3c2c02b5afad312efacfc9
Gerrit-Change-Number: 67722
Gerrit-PatchSet: 1
Gerrit-Owner: Edward O'Callaghan <quasisec@chromium.org>
Gerrit-MessageType: newchange