From: Simon Glass Date: Mon, 18 Jun 2018 14:08:20 +0000 (-0600) Subject: vsprintf: Handle NULL with %pU X-Git-Tag: v2018.09-rc1~2^2~32 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=d7ae1609a9d5a76235978e34de0e9928979af781;p=oweals%2Fu-boot.git vsprintf: Handle NULL with %pU 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 Reviewed-by: Alexander Graf [agraf: s/(null)//] Signed-off-by: Alexander Graf --- diff --git a/lib/vsprintf.c b/lib/vsprintf.c index 8b1b29fb5a..914fbd30cb 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, ""); return string(buf, end, uuid, field_width, precision, flags); }