summaryrefslogtreecommitdiffstats
path: root/dmi.c
diff options
context:
space:
mode:
authorStefan Tauner <stefan.tauner@alumni.tuwien.ac.at>2013-10-29 01:38:45 +0000
committerStefan Tauner <stefan.tauner@alumni.tuwien.ac.at>2013-10-29 01:38:45 +0000
commitd1045d8b245ab231bed5419d91a6bf380678932d (patch)
tree65ef0eb6df4f8536cb5ab8dcdad74b048171bfae /dmi.c
parent2c5b65eb197cf149b56caff68f6d0442cb99d10f (diff)
downloadast2050-flashrom-d1045d8b245ab231bed5419d91a6bf380678932d.zip
ast2050-flashrom-d1045d8b245ab231bed5419d91a6bf380678932d.tar.gz
Ensure DMI strings used in dmi_compare() are not NULL
Previously the external DMI decoder did not allow this to happen because all possible pointers were initialized at startup by the output of 'dmidecode -s ...' which has default values for all supported types. The now active internal DMI decoder does work differently: it scans the complete DMI table once and copies the available strings. Therefore, strings that are not set by the firmware are left at their default value of NULL. A segfault would arise if the following conditions are all true: - the firmware sets up a DMI/SMBIOS table which has at least a correct checksum, and - that table does *not* define at least one of the DMI strings we use for matching (as defined by dmi_strings[] in dmi.c), and - there exists a board enable whose PCI IDs are matched by the board, and which has a DMI string set that ends with a $ anchor, and - the user calls the internal programmer of flashrom without the optional mainboard parameter. This was first observed by Gelip on an abit BF6 using the coreboot port for the abit BE6-II V2.0. The segfault was reproduced by Idwer Vollering on an ASUS F2A85-M with the default DMI values of CONFIG_MAINBOARD_SMBIOS_MANUFACTURER etc. overwritten and a forged board enable matching his board. Idwer also verified that this patch fixes the problem, thanks a lot! Corresponding to flashrom svn r1763. Signed-off-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at> Acked-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
Diffstat (limited to 'dmi.c')
-rw-r--r--dmi.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/dmi.c b/dmi.c
index 14f3871..ef7ae2c 100644
--- a/dmi.c
+++ b/dmi.c
@@ -406,8 +406,8 @@ void dmi_init(void)
* at the beginning and '$' at the end. So you can look for "^prefix",
* "suffix$", "substring" or "^complete string$".
*
- * @param value The string to check.
- * @param pattern The pattern.
+ * @param value The non-NULL string to check.
+ * @param pattern The non-NULL pattern.
* @return Nonzero if pattern matches.
*/
static int dmi_compare(const char *value, const char *pattern)
@@ -454,9 +454,13 @@ int dmi_match(const char *pattern)
if (!has_dmi_support)
return 0;
- for (i = 0; i < ARRAY_SIZE(dmi_strings); i++)
+ for (i = 0; i < ARRAY_SIZE(dmi_strings); i++) {
+ if (dmi_strings[i].value == NULL)
+ continue;
+
if (dmi_compare(dmi_strings[i].value, pattern))
return 1;
+ }
return 0;
}
OpenPOWER on IntegriCloud