[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[dmidecode] [PATCH 3/3] dmidecode: Fix reading from SMBIOS 3 dump files
From: |
Jean Delvare |
Subject: |
[dmidecode] [PATCH 3/3] dmidecode: Fix reading from SMBIOS 3 dump files |
Date: |
Wed, 5 Apr 2017 15:09:40 +0200 |
In an SMBIOS 3 dump file using the 64-bit entry point format, we
don't know in advance the exact size of the DMI table, only a maximum
size. This is the same situation as when reading the same table from
sysfs, so we should use the same code.
---
dmidecode.c | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
--- dmidecode.orig/dmidecode.c 2017-04-05 14:41:58.328004878 +0200
+++ dmidecode/dmidecode.c 2017-04-05 14:43:58.246159057 +0200
@@ -4540,17 +4540,19 @@ static void dmi_table(off_t base, u32 le
printf("\n");
}
- if (flags & FLAG_NO_FILE_OFFSET)
+ if ((flags & FLAG_NO_FILE_OFFSET) || (opt.flags & FLAG_FROM_DUMP))
{
/*
- * When reading from sysfs, the file may be shorter than
- * announced. For SMBIOS v3 this is expcted, as we only know
- * the maximum table size, not the actual table size. For older
- * implementations (and for SMBIOS v3 too), this would be the
- * result of the kernel truncating the table on parse error.
+ * When reading from sysfs or from a dump file, the file may be
+ * shorter than announced. For SMBIOS v3 this is expcted, as we
+ * only know the maximum table size, not the actual table size.
+ * For older implementations (and for SMBIOS v3 too), this
+ * would be the result of the kernel truncating the table on
+ * parse error.
*/
size_t size = len;
- buf = read_file(0, &size, devmem);
+ buf = read_file(flags & FLAG_NO_FILE_OFFSET ? 0 : base,
+ &size, devmem);
if (!(opt.flags & FLAG_QUIET) && num && size != (size_t)len)
{
fprintf(stderr, "Wrong DMI structures length: %u bytes "
--
Jean Delvare
SUSE L3 Support