Skip to content

Commit 3f70b35

Browse files
committed
dmidecode: Fix up invalid DMI type 34 structure length
Several boards have a bug where some type 34 structures have their length incorrectly set to 0x10 instead of 0x0B. This causes the first 5 characters of the device name to be trimmed. It's easy to check and fix, so do it, but warn.
1 parent 196ca4a commit 3f70b35

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

CHANGELOG

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
2015-05-21 Jean Delvare <[email protected]>
2+
3+
* dmidecode.c: Fix up invalid DMI type 34 structure length.
4+
15
2015-05-13 Jean Delvare <[email protected]>
26

37
* dmidecode.c: Add support for SMBIOS3 EFI table.

dmidecode.c

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2928,6 +2928,29 @@ static void dmi_64bit_memory_error_address(u64 code)
29282928
* 7.35 Management Device (Type 34)
29292929
*/
29302930

2931+
/*
2932+
* Several boards have a bug where some type 34 structures have their
2933+
* length incorrectly set to 0x10 instead of 0x0B. This causes the
2934+
* first 5 characters of the device name to be trimmed. It's easy to
2935+
* check and fix, so do it, but warn.
2936+
*/
2937+
static void dmi_fixup_type_34(struct dmi_header *h)
2938+
{
2939+
u8 *p = h->data;
2940+
int i;
2941+
2942+
if (h->length != 0x10)
2943+
return;
2944+
2945+
/* Make sure the hidden data is ASCII only */
2946+
for (i = 0x0B; i < 0x10; i++)
2947+
if (p[i] < 32 || p[i] >= 127)
2948+
return;
2949+
2950+
printf("Invalid entry length (%u). Fixed up to %u.\n", 0x10, 0x0B);
2951+
h->length = 0x0B;
2952+
}
2953+
29312954
static const char *dmi_management_device_type(u8 code)
29322955
{
29332956
/* 7.35.1 */
@@ -4410,6 +4433,10 @@ static void dmi_table_decode(u8 *buf, u32 len, u16 num, u16 ver, u32 flags)
44104433
if (h.type == 1 && h.length >= 5)
44114434
dmi_set_vendor(dmi_string(&h, data[0x04]));
44124435

4436+
/* Fixup a common mistake */
4437+
if (h.type == 34)
4438+
dmi_fixup_type_34(&h);
4439+
44134440
/* look for the next handle */
44144441
next = data + h.length;
44154442
while ((unsigned long)(next - buf + 1) < len

0 commit comments

Comments
 (0)