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 <[email protected]>
---

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)");
 
        return string(buf, end, uuid, field_width, precision, flags);
 }
-- 
2.18.0.rc1.244.gcf134e6275-goog

_______________________________________________
U-Boot mailing list
[email protected]
https://lists.denx.de/listinfo/u-boot

Reply via email to