File dmidecode-fix-reading-from-smbios-3-dump-files.patch of Package dmidecode.28672
From: Jean Delvare <jdelvare@suse.de>
Date: Tue, 11 Apr 2017 11:41:46 +0200
Subject: dmidecode: Fix reading from SMBIOS 3 dump files
Git-commit: aa66327d4b6eececb932c8c174b0412e10a0ac78
Patch-mainline: 3.1
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.
Signed-off-by: Jean Delvare <jdelvare@suse.de>
---
dmidecode.c | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
--- a/dmidecode.c
+++ b/dmidecode.c
@@ -4634,17 +4634,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)
{
printf("Wrong DMI structures length: %u bytes "