[PATCH v2] smbios: Fix table when no string is present
matthias.bgg at kernel.org
matthias.bgg at kernel.org
Tue Apr 6 11:04:35 CEST 2021
From: Matthias Brugger <mbrugger at suse.com>
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 at suse.com>
---
Changes in v2:
- check in smbios_string_table_len if no string present and return value
accordingly
lib/smbios.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/lib/smbios.c b/lib/smbios.c
index 9eb226ec9f..fd57d8694f 100644
--- a/lib/smbios.c
+++ b/lib/smbios.c
@@ -191,6 +191,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;
}
--
2.30.2
More information about the U-Boot
mailing list