From d7ae1609a9d5a76235978e34de0e9928979af781 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 18 Jun 2018 08:08:20 -0600 Subject: [PATCH] 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 --- lib/vsprintf.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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); } -- 2.25.1