qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [SeaBIOS] [PATCH] smbios: catch zero-length strings


From: Markus Armbruster
Subject: Re: [Qemu-devel] [SeaBIOS] [PATCH] smbios: catch zero-length strings
Date: Tue, 21 Jan 2014 14:26:42 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2 (gnu/linux)

Gerd Hoffmann <address@hidden> writes:

> qemu may pass us zero-length strings for smbios fields, when starting
> qemu this way  ...
>
>       qemu -smbios type=1,version=,serial=test
>
> ... for example.
>
> Today we don't specifically handle them and simply append them to the
> string list.  Therefore we get two string-terminating zeros in a row.
> Result is that we by accident create a end-of-entry marker in the middle
> of the entry.

And dmidecode screaming bloody murder :)  More detail than you probably
want to know at https://bugzilla.redhat.com/show_bug.cgi?id=1052837

> Fix this by handling zero-length strings like non-present strings.
>
> Cc: address@hidden
> Signed-off-by: Gerd Hoffmann <address@hidden>

Spelling correction inline.

Reviewed-by: Markus Armbruster <address@hidden>

> ---
>  src/fw/smbios.c | 10 +++++++---
>  1 file changed, 7 insertions(+), 3 deletions(-)
>
> diff --git a/src/fw/smbios.c b/src/fw/smbios.c
> index affb9be..d549329 100644
> --- a/src/fw/smbios.c
> +++ b/src/fw/smbios.c
> @@ -133,20 +133,24 @@ get_external(int type, char **p, unsigned *nr_structs,
>      do {                                                                \
>          size = get_field(type, offsetof(struct smbios_type_##type,      \
>                                          field), end);                   \
> -        if (size > 0) {                                                 \
> +        if (size == 1) {                                                \
> +            /* zero-length string, skip to avoid bogous end marker */   \

s/bogous/bogus/

> +            p->field = 0;                                               \
> +        } else if (size > 1) {                                          \
>              end += size;                                                \
> +            p->field = ++str_index;                                     \
>          } else {                                                        \
>              memcpy(end, def, sizeof(def));                              \
>              end += sizeof(def);                                         \
> +            p->field = ++str_index;                                     \
>          }                                                               \
> -        p->field = ++str_index;                                         \
>      } while (0)
>  
>  #define load_str_field_or_skip(type, field)                             \
>      do {                                                                \
>          size = get_field(type, offsetof(struct smbios_type_##type,      \
>                                          field), end);                   \
> -        if (size > 0) {                                                 \
> +        if (size > 1) {                                                 \
>              end += size;                                                \
>              p->field = ++str_index;                                     \
>          } else {                                                        \



reply via email to

[Prev in Thread] Current Thread [Next in Thread]