]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
smbios: Fix table when no string is present
authorMatthias Brugger <mbrugger@suse.com>
Tue, 6 Apr 2021 09:04:35 +0000 (11:04 +0200)
committerHeinrich Schuchardt <heinrich.schuchardt@canonical.com>
Fri, 2 Feb 2024 18:56:54 +0000 (19:56 +0100)
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>
lib/smbios.c

index 11b7611a84e90eea6022ccfe50e195bb2de3fbbb..0ae857855ec3b801328f2f8aa0a30e8dfbf1c63c 100644 (file)
@@ -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;
 }