From: Simon Glass Date: Mon, 18 Jun 2018 08:08:20 -0600 Subject: [U-Boot] [PATCH v8 15/30] vsprintf: Handle NULL with %pU In-Reply-To: <20180618140835.195901-1-sjg@chromium.org> References: <20180618140835.195901-1-sjg@chromium.org> Message-ID: <20180618140835.195901-16-sjg@chromium.org> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de 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 --- 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