From d6987c53d3648d85e410ef81a343867e239eb960 Mon Sep 17 00:00:00 2001 From: David Sommerseth Date: Thu, 6 Jan 2011 15:56:24 +0100 Subject: Harden dmi_string() calls with better NULL checks This patch fixes more potential issues where dmi_string() results was not necessarily checked for NULL, which potentially could lead to SEGV issues. Signed-off-by: David Sommerseth --- src/dmioem.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'src/dmioem.c') diff --git a/src/dmioem.c b/src/dmioem.c index 361810a..67cd517 100644 --- a/src/dmioem.c +++ b/src/dmioem.c @@ -40,10 +40,19 @@ static enum DMI_VENDORS dmi_vendor = VENDOR_UNKNOWN; * value if we know how to decode at least one specific entry type for * that vendor. */ -void dmi_set_vendor(const char *s) +void dmi_set_vendor(const struct dmi_header *h) { - if(strcmp(s, "HP") == 0) + const char *vendor; + + if( !h || !h->data ) { + return; + } + vendor = dmi_string(h, h->data[0x04]); + if( !vendor ) { + return; + } else if(strcmp(vendor, "HP") == 0) { dmi_vendor = VENDOR_HP; + } } /* -- cgit