On Mon, Jan 29, 2024 at 10:04:50PM +0100, Heinrich Schuchardt wrote: > The string section of the different SMBIOS structures is always terminated > by two NUL bytes even if there is no string at all. This is described in > section 6.1.3 "Text string" of the SMBIOS 3.7.0 specification. > > Signed-off-by: Heinrich Schuchardt <heinrich.schucha...@canonical.com>
I send the very same patch some years ago [1], unfortunately it got somehow lost. Happy to see you trying to fix the same problem, so: Reviewed-by: Matthias Brugger <mbrug...@suse.com> [1] https://patchwork.ozlabs.org/project/uboot/patch/20210406090435.19357-1-matthias....@kernel.org/ > --- > lib/smbios.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/lib/smbios.c b/lib/smbios.c > index 7bd9805fec0..81908e89610 100644 > --- a/lib/smbios.c > +++ b/lib/smbios.c > @@ -311,6 +311,9 @@ int smbios_update_version(const char *version) > */ > static int smbios_string_table_len(const struct smbios_ctx *ctx) > { > + /* If the structure contains no string it is followed by to NUL bytes */ > + if (ctx->next_ptr == ctx->eos) > + return 2; > /* Allow for the final \0 after all strings */ > return (ctx->next_ptr + 1) - ctx->eos; > } > -- > 2.43.0