Skip to content

Commit 9d927b4

Browse files
committed
oem: Strip spaces at the end of vendor names
Often DMI strings have trailing spaces. Ignore these when checking for known vendor names.
1 parent c2553ee commit 9d927b4

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

CHANGELOG

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
unsigned integers.
66
* util.c: Fix warnings about unused labels when building without
77
-DUSE_MMAP.
8+
* dmioem.c: Strip spaces at the end of vendor names.
89

910
2015-05-12 Jean Delvare <[email protected]>
1011

dmioem.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,17 @@ static enum DMI_VENDORS dmi_vendor = VENDOR_UNKNOWN;
4141
*/
4242
void dmi_set_vendor(const char *s)
4343
{
44-
if (strcmp(s, "HP") == 0 || strcmp(s, "Hewlett-Packard") == 0)
44+
int len;
45+
46+
/*
47+
* Often DMI strings have trailing spaces. Ignore these
48+
* when checking for known vendor names.
49+
*/
50+
len = strlen(s);
51+
while (len && s[len - 1] == ' ')
52+
len--;
53+
54+
if (strncmp(s, "HP", len) == 0 || strncmp(s, "Hewlett-Packard", len) == 0)
4555
dmi_vendor = VENDOR_HP;
4656
}
4757

0 commit comments

Comments
 (0)