diff options
author | Simon Glass | 2018-06-18 08:08:20 -0600 |
---|---|---|
committer | Alexander Graf | 2018-07-25 14:57:44 +0200 |
commit | d7ae1609a9d5a76235978e34de0e9928979af781 (patch) | |
tree | b367e3de78e421c8e682b0629d70c310e7f806a6 /lib/vsprintf.c | |
parent | 282a06cbcae84acd86125210dbd54a10ff41e809 (diff) |
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 <sjg@chromium.org>
Reviewed-by: Alexander Graf <agraf@suse.de>
[agraf: s/(null)/<NULL>/]
Signed-off-by: Alexander Graf <agraf@suse.de>
Diffstat (limited to 'lib/vsprintf.c')
-rw-r--r-- | lib/vsprintf.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/vsprintf.c b/lib/vsprintf.c index 8b1b29fb5aa..914fbd30cbc 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); } |