Many old implementations have stray zero bytes at the end of record
type 3 (Chassis Information), probably due to some confusion
regarding the preceding variable length section. Only decode the SKU
field if the SMBIOS specification version being implemented includes
this field.

Signed-off-by: Jean Delvare <[email protected]>
---
 dmidecode.c |   13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

--- a/dmidecode.c
+++ b/dmidecode.c
@@ -4604,8 +4604,17 @@ static void dmi_decode(const struct dmi_
                        if (h->length < 0x15 + data[0x13] * data[0x14]) break;
                        dmi_chassis_elements(data[0x13], data[0x14], data + 
0x15);
                        if (h->length < 0x16 + data[0x13] * data[0x14]) break;
-                       pr_attr("SKU Number", "%s",
-                               dmi_string(h, data[0x15 + data[0x13] * 
data[0x14]]));
+                       /*
+                        * Many old implementations have stray zero bytes at
+                        * the end of this record, probably due to some
+                        * confusion regarding the preceding variable length
+                        * section. Only decode the following fields if they
+                        * are defined in the SMBIOS specification version
+                        * which is implemented.
+                        */
+                       if (ver >= 0x0207)
+                               pr_attr("SKU Number", "%s",
+                                       dmi_string(h, data[0x15 + data[0x13] * 
data[0x14]]));
                        break;
 
                case 4: /* 7.5 Processor Information */

-- 
Jean Delvare
SUSE L3 Support

Reply via email to