Use the correct range check when parsing SMBIOS

The SMBIOS specification says:

    Maximum size of SMBIOS Structure Table, pointed to by the
    Structure Table Address, in bytes. The actual size is guaranteed
    to be less or equal to the maximum size.

So, the firmware is actually allowed to return a DMI blob smaller than the
specified size.

Fixes https://github.com/fwupd/fwupd/issues/5486
This commit is contained in:
Richard Hughes 2023-02-04 12:46:03 +00:00 committed by Mario Limonciello
parent e3c660d203
commit a9dbbc99f7

View File

@ -325,7 +325,7 @@ fu_smbios_setup_from_path(FuSmbios *self, const gchar *path, GError **error)
dmi_fn = g_build_filename(path, "DMI", NULL);
if (!g_file_get_contents(dmi_fn, &dmi_raw, &sz, error))
return FALSE;
if (sz != self->structure_table_len) {
if (sz > self->structure_table_len) {
g_set_error(error,
FWUPD_ERROR,
FWUPD_ERROR_INVALID_FILE,