diff options
author | David Sommerseth <davids@redhat.com> | 2011-01-06 15:56:24 +0100 |
---|---|---|
committer | David Sommerseth <davids@redhat.com> | 2011-01-06 15:56:24 +0100 |
commit | d6987c53d3648d85e410ef81a343867e239eb960 (patch) | |
tree | 7b4a39570fb13a88bf76a213d48b9c8f71321ffd /src/dmioem.c | |
parent | 734d025ce6503851447f5a3dd08b107425f8b515 (diff) | |
download | python-dmidecode-d6987c53d3648d85e410ef81a343867e239eb960.tar.gz python-dmidecode-d6987c53d3648d85e410ef81a343867e239eb960.tar.xz python-dmidecode-d6987c53d3648d85e410ef81a343867e239eb960.zip |
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 <davids@redhat.com>
Diffstat (limited to 'src/dmioem.c')
-rw-r--r-- | src/dmioem.c | 13 |
1 files changed, 11 insertions, 2 deletions
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; + } } /* |