diff options
author | khali <khali> | 2015-05-13 07:25:10 +0000 |
---|---|---|
committer | khali <khali> | 2015-05-13 07:25:10 +0000 |
commit | c954f0b69dd5320279bc81a0f8d2e8325311d1e2 (patch) | |
tree | 84d85c1239f4ed02d74cf6a47aef8f099e944de7 | |
parent | f88b13f7d8b96baf9e4cf91afdf271bbf1e581c8 (diff) | |
download | dmidecode-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-- | CHANGELOG | 1 | ||||
-rw-r--r-- | dmioem.c | 12 |
2 files changed, 12 insertions, 1 deletions
@@ -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> @@ -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; } |