diff options
author | Matthias Brugger <mbrugger@suse.com> | 2021-04-06 11:04:35 +0200 |
---|---|---|
committer | Heinrich Schuchardt <heinrich.schuchardt@canonical.com> | 2024-02-02 19:56:54 +0100 |
commit | e31efe50b5cce46a2ee68c96db445e0a3d481aa8 (patch) | |
tree | b472c810f5ad5d6e97520dea29a21fefff73db7f /lib | |
parent | c11f176ab16a3488c0b057fed41d76ef96091564 (diff) | |
download | u-boot-e31efe50b5cce46a2ee68c96db445e0a3d481aa8.zip u-boot-e31efe50b5cce46a2ee68c96db445e0a3d481aa8.tar.gz u-boot-e31efe50b5cce46a2ee68c96db445e0a3d481aa8.tar.bz2 |
smbios: Fix table when no string is present
When no string is present in a table, next_ptr points to the same
location as eos. When calculating the string table length, we would only
reserve one \0. By spec a SMBIOS table has to end with two \0\0 when no
strings a present.
Signed-off-by: Matthias Brugger <mbrugger@suse.com>
Reviewed-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/smbios.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/smbios.c b/lib/smbios.c index 11b7611..0ae8578 100644 --- a/lib/smbios.c +++ b/lib/smbios.c @@ -312,6 +312,10 @@ int smbios_update_version(const char *version) */ static int smbios_string_table_len(const struct smbios_ctx *ctx) { + /* In case no string is defined we have to return two \0 */ + if (ctx->next_ptr == ctx->eos) + return 2; + /* Allow for the final \0 after all strings */ return (ctx->next_ptr + 1) - ctx->eos; } |