diff options
author | Konstantin Aladyshev <aladyshev22@gmail.com> | 2017-08-01 15:52:46 +0300 |
---|---|---|
committer | Martin Roth <martinroth@google.com> | 2017-08-10 15:56:45 +0000 |
commit | d0df1d7c4ebd4d8e654c8350c27a0d9f749a88f6 (patch) | |
tree | 1ebb35d72d65917e20cec93746cae9c5d753cbc7 /src/arch | |
parent | 0722613563247d41caa406c176ee452465df3572 (diff) |
SMBIOS: Correct length calculation for empty string table
If all strings in SMBIOS table are empty, smbios_string_table_len
function should return 2, cause every table must end with "\0\0".
Also replace "eos" field type in smbios structures
from char to u8.
Change-Id: Ia3178b0030aa71e1ff11a3fd3d102942f0027eb1
Signed-off-by: Konstantin Aladyshev <aladyshev22@gmail.com>
Reviewed-on: https://review.coreboot.org/20840
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Kyösti Mälkki <kyosti.malkki@gmail.com>
Diffstat (limited to 'src/arch')
-rw-r--r-- | src/arch/x86/smbios.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/arch/x86/smbios.c b/src/arch/x86/smbios.c index 72fb0dfb77..89951a10ab 100644 --- a/src/arch/x86/smbios.c +++ b/src/arch/x86/smbios.c @@ -42,10 +42,10 @@ static u8 smbios_checksum(u8 *p, u32 length) } -int smbios_add_string(char *start, const char *str) +int smbios_add_string(u8 *start, const char *str) { int i = 1; - char *p = start; + char *p = (char *)start; /* * Return 0 as required for empty strings. @@ -71,9 +71,9 @@ int smbios_add_string(char *start, const char *str) } } -int smbios_string_table_len(char *start) +int smbios_string_table_len(u8 *start) { - char *p = start; + char *p = (char *)start; int i, len = 0; while (*p) { @@ -81,10 +81,14 @@ int smbios_string_table_len(char *start) p += i; len += i; } + + if (!len) + return 2; + return len + 1; } -static int smbios_cpu_vendor(char *start) +static int smbios_cpu_vendor(u8 *start) { if (cpu_have_cpuid()) { u32 tmp[4]; @@ -99,7 +103,7 @@ static int smbios_cpu_vendor(char *start) } } -static int smbios_processor_name(char *start) +static int smbios_processor_name(u8 *start) { u32 tmp[13]; const char *str = "Unknown Processor Name"; |