Hi Matthias, On Thu, 18 Mar 2021 at 00:30, <matthias....@kernel.org> wrote: > > From: Matthias Brugger <mbrug...@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 <mbrug...@suse.com> > > --- > > lib/smbios.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-)
There is a bug here but I don't think this is right fix. I remember worrying about this, making the same change as you did, reverting it and then forgetting about it :-( It has no tests. You are effectively changing the definition of next_ptr here: * @next_ptr: pointer to the start of the next string to be added. When the * table is not empty, this points to the byte after the \0 of the * previous string. (there is a typo in that in the code) I think that breaks adding new strings. Can you instead change smbios_string_table_len() to add 2? > > diff --git a/lib/smbios.c b/lib/smbios.c > index 7d463c84a9..d21d37cdac 100644 > --- a/lib/smbios.c > +++ b/lib/smbios.c > @@ -153,7 +153,7 @@ static int smbios_add_prop(struct smbios_ctx *ctx, const > char *prop) > static void smbios_set_eos(struct smbios_ctx *ctx, char *eos) > { > ctx->eos = eos; > - ctx->next_ptr = eos; > + ctx->next_ptr = eos + 1; > ctx->last_str = NULL; > } > > -- > 2.30.2 > Regards, Simon