[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[dmidecode] [PATCH 5/5] dmidecode: Stop decoding v3 tables at End-of-Tab
From: |
Jean Delvare |
Subject: |
[dmidecode] [PATCH 5/5] dmidecode: Stop decoding v3 tables at End-of-Table marker |
Date: |
Tue, 21 Apr 2015 11:59:38 +0200 |
The SMBIOS v3 64-bit entry points do not provide the exact size of the
DMI table, only a maximum, so we have to stop decoding at the
End-of-Table (127) type structure.
---
dmidecode.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
--- dmidecode.orig/dmidecode.c 2015-04-21 11:05:09.325834595 +0200
+++ dmidecode/dmidecode.c 2015-04-21 11:05:11.498874706 +0200
@@ -72,6 +72,7 @@ static const char *bad_index = "<BAD IND
#define SUPPORTED_SMBIOS_VER 0x0300
#define FLAG_NO_FILE_OFFSET (1 << 0)
+#define FLAG_STOP_AT_EOT (1 << 1)
#define SYS_ENTRY_FILE "/sys/firmware/dmi/tables/smbios_entry_point"
#define SYS_TABLE_FILE "/sys/firmware/dmi/tables/DMI"
@@ -4491,6 +4492,10 @@ static void dmi_table(off_t base, u32 le
data = next;
i++;
+
+ /* SMBIOS v3 requires stopping at this marker */
+ if (h.type == 127 && (flags & FLAG_STOP_AT_EOT))
+ break;
}
/*
@@ -4562,7 +4567,7 @@ static int smbios3_decode(u8 *buf, const
return 0;
}
dmi_table(((off_t)offset.h << 32) | offset.l,
- WORD(buf + 0x0C), 0, ver, devmem, flags);
+ WORD(buf + 0x0C), 0, ver, devmem, flags | FLAG_STOP_AT_EOT);
if (opt.flags & FLAG_DUMP_BIN)
{
--
Jean Delvare
SUSE L3 Support