Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit aa66327

Browse files
committed
dmidecode: Fix reading from SMBIOS 3 dump files
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>
1 parent 6d0486c commit aa66327

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

‎CHANGELOG‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
* util.c: Don't leak a file descriptor in function read_file.
44
* util.c, util.c, dmidecode.c: Let callers pass an offset to function
55
read_file.
6+
* dmidecode.c: Fix reading from SMBIOS 3 dump files using a 64-bit
7+
entry point.
68

79
2017年04月10日 Jean Delvare <jdelvare@suse.de>
810

‎dmidecode.c‎

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4540,17 +4540,19 @@ static void dmi_table(off_t base, u32 len, u16 num, u16 ver, const char *devmem,
45404540
printf("\n");
45414541
}
45424542

4543-
if (flags & FLAG_NO_FILE_OFFSET)
4543+
if ((flags & FLAG_NO_FILE_OFFSET) || (opt.flags&FLAG_FROM_DUMP))
45444544
{
45454545
/*
4546-
* When reading from sysfs, the file may be shorter than
4547-
* announced. For SMBIOS v3 this is expcted, as we only know
4548-
* the maximum table size, not the actual table size. For older
4549-
* implementations (and for SMBIOS v3 too), this would be the
4550-
* result of the kernel truncating the table on parse error.
4546+
* When reading from sysfs or from a dump file, the file may be
4547+
* shorter than announced. For SMBIOS v3 this is expcted, as we
4548+
* only know the maximum table size, not the actual table size.
4549+
* For older implementations (and for SMBIOS v3 too), this
4550+
* would be the result of the kernel truncating the table on
4551+
* parse error.
45514552
*/
45524553
size_t size = len;
4553-
buf = read_file(0, &size, devmem);
4554+
buf = read_file(flags & FLAG_NO_FILE_OFFSET ? 0 : base,
4555+
&size, devmem);
45544556
if (!(opt.flags & FLAG_QUIET) && num && size != (size_t)len)
45554557
{
45564558
fprintf(stderr, "Wrong DMI structures length: %u bytes "

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /