[PATCH 4/7] smbios: string table always needs two terminating NUL bytes

Ilias Apalodimas ilias.apalodimas at linaro.org
Thu Feb 1 09:38:10 CET 2024


On Mon, 29 Jan 2024 at 23:05, Heinrich Schuchardt
<heinrich.schuchardt at canonical.com> 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.schuchardt at canonical.com>
> ---
>  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
>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas at linaro.org>


More information about the U-Boot mailing list