[PATCH 2/2] lib: fwts_scan_efi_systable: fix getting wrong smbios entry (LP: #1484046)

Ivan Hu ivan.hu at canonical.com
Fri Aug 14 03:17:08 UTC 2015


After smbios 3.0.0 released, some platforms contain multiple smbios tables
on the efi system table.
ex.
/sys/firmware/efi/systab
ACPI20=0x266be000
ACPI=0x266be000
SMBIOS30=0x37dd0000
SMBIOS=0xf0000

Using fwts_scan_efi_systab("SMBIOS"), will get the wrong entry(i.e.0x37dd0000)
This mismatch entry will get the false test results, such as the false checksum
,anchor string, etc.

Fix it with also checking the table name length with the entry we get.

Signed-off-by: Ivan Hu <ivan.hu at canonical.com>
---
 src/lib/src/fwts_scan_efi_systab.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/lib/src/fwts_scan_efi_systab.c b/src/lib/src/fwts_scan_efi_systab.c
index ad38884..66a0afa 100644
--- a/src/lib/src/fwts_scan_efi_systab.c
+++ b/src/lib/src/fwts_scan_efi_systab.c
@@ -40,9 +40,12 @@ void *fwts_scan_efi_systab(const char *name)
 
 	fwts_list_foreach(item, systab) {
 		char *str = fwts_list_data(char *, item);
-		if (strstr(str, name)) {
+		char *s_ptr = strstr(str, name);
+		if (s_ptr) {
 			char *ptr = strstr(str, "=");
 			if (ptr) {
+				if ((size_t)(ptr - s_ptr) != strlen(name))
+					continue;
 				addr = (void*)strtoul(ptr+1, NULL, 0);
 				break;
 			}
-- 
1.9.1




More information about the fwts-devel mailing list