summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkhali <khali>2015-05-13 07:25:10 +0000
committerkhali <khali>2015-05-13 07:25:10 +0000
commitc954f0b69dd5320279bc81a0f8d2e8325311d1e2 (patch)
tree84d85c1239f4ed02d74cf6a47aef8f099e944de7
parentf88b13f7d8b96baf9e4cf91afdf271bbf1e581c8 (diff)
downloaddmidecode-c954f0b69dd5320279bc81a0f8d2e8325311d1e2.tar.gz
oem: Strip spaces at the end of vendor names
Often DMI strings have trailing spaces. Ignore these when checking for known vendor names.
-rw-r--r--CHANGELOG1
-rw-r--r--dmioem.c12
2 files changed, 12 insertions, 1 deletions
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 <jdelvare@suse.de>
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;
}