[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[dmidecode] [PATCH] dmidecode: Fix up invalid DMI type 34 structure leng
From: |
Jean Delvare |
Subject: |
[dmidecode] [PATCH] dmidecode: Fix up invalid DMI type 34 structure length |
Date: |
Wed, 13 May 2015 10:27:17 +0200 |
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.
---
dmidecode.c | 27 +++++++++++++++++++++++++++
1 file changed, 27 insertions(+)
--- dmidecode.orig/dmidecode.c 2015-05-13 09:17:46.388019635 +0200
+++ dmidecode/dmidecode.c 2015-05-13 10:25:35.620144793 +0200
@@ -2928,6 +2928,29 @@ static void dmi_64bit_memory_error_addre
* 7.35 Management Device (Type 34)
*/
+/*
+ * 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.
+ */
+static void dmi_fixup_type_34(struct dmi_header *h)
+{
+ u8 *p = h->data;
+ int i;
+
+ if (h->length != 0x10)
+ return;
+
+ /* Make sure the hidden data is ASCII only */
+ for (i = 0x0B; i < 0x10; i++)
+ if (p[i] < 32 || p[i] >= 127)
+ return;
+
+ printf("Invalid entry length (%u). Fixed up to %u.\n", 0x10, 0x0B);
+ h->length = 0x0B;
+}
+
static const char *dmi_management_device_type(u8 code)
{
/* 7.35.1 */
@@ -4410,6 +4433,10 @@ static void dmi_table_decode(u8 *buf, u3
if (h.type == 1 && h.length >= 5)
dmi_set_vendor(dmi_string(&h, data[0x04]));
+ /* Fixup a common mistake */
+ if (h.type == 34)
+ dmi_fixup_type_34(&h);
+
/* look for the next handle */
next = data + h.length;
while ((unsigned long)(next - buf + 1) < len
--
Jean Delvare
SUSE L3 Support
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [dmidecode] [PATCH] dmidecode: Fix up invalid DMI type 34 structure length,
Jean Delvare <=