[U-Boot] [U-Boot,v8,15/30] vsprintf: Handle NULL with %pU
Heinrich Schuchardt
xypron.glpk at gmx.de
Wed Jun 27 19:00:18 UTC 2018
On 06/18/2018 04:08 PM, Simon Glass wrote:
> At present a NULL pointer passed to printf for a %pU argument will cause
> U-Boot to access memory at 0. Fix this by adding a check, and print
> "(null)" instead.
>
> Signed-off-by: Simon Glass <sjg at chromium.org>
> Reviewed-by: Alexander Graf <agraf at suse.de>
> ---
>
> Changes in v8: None
> Changes in v7: None
> Changes in v6: None
> Changes in v5: None
> Changes in v4: None
> Changes in v3: None
> Changes in v2: None
>
> lib/vsprintf.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/lib/vsprintf.c b/lib/vsprintf.c
> index 8b1b29fb5a..2da7f88b18 100644
> --- a/lib/vsprintf.c
> +++ b/lib/vsprintf.c
> @@ -407,7 +407,10 @@ static char *uuid_string(char *buf, char *end, u8 *addr, int field_width,
> break;
> }
>
> - uuid_bin_to_str(addr, uuid, str_format);
> + if (addr)
> + uuid_bin_to_str(addr, uuid, str_format);
> + else
> + strcpy(uuid, "(null)");
Everywhere else in vsprintf.c we use "<NULL>". I would prefer consistency.
@Alex:
You already added the patch to efi-next. Could you update the string,
please?
Best regards
Heinrich
>
> return string(buf, end, uuid, field_width, precision, flags);
> }
>
More information about the U-Boot
mailing list