From c954f0b69dd5320279bc81a0f8d2e8325311d1e2 Mon Sep 17 00:00:00 2001 From: khali Date: Wed, 13 May 2015 07:25:10 +0000 Subject: oem: Strip spaces at the end of vendor names Often DMI strings have trailing spaces. Ignore these when checking for known vendor names. --- CHANGELOG | 1 + dmioem.c | 12 +++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 4bc8461..7236101 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -5,6 +5,7 @@ unsigned integers. * util.c: Fix warnings about unused labels when building without -DUSE_MMAP. + * dmioem.c: Strip spaces at the end of vendor names. 2015-05-12 Jean Delvare diff --git a/dmioem.c b/dmioem.c index 4219a10..bbc2fa3 100644 --- a/dmioem.c +++ b/dmioem.c @@ -41,7 +41,17 @@ static enum DMI_VENDORS dmi_vendor = VENDOR_UNKNOWN; */ void dmi_set_vendor(const char *s) { - if (strcmp(s, "HP") == 0 || strcmp(s, "Hewlett-Packard") == 0) + int len; + + /* + * Often DMI strings have trailing spaces. Ignore these + * when checking for known vendor names. + */ + len = strlen(s); + while (len && s[len - 1] == ' ') + len--; + + if (strncmp(s, "HP", len) == 0 || strncmp(s, "Hewlett-Packard", len) == 0) dmi_vendor = VENDOR_HP; } -- cgit v1.2.1