From mboxrd@z Thu Jan 1 00:00:00 1970 From: Heinrich Schuchardt Date: Wed, 27 Jun 2018 21:00:18 +0200 Subject: [U-Boot] [U-Boot,v8,15/30] vsprintf: Handle NULL with %pU In-Reply-To: <20180618140835.195901-16-sjg@chromium.org> References: <20180618140835.195901-16-sjg@chromium.org> Message-ID: <844cb42d-9d40-c84c-5199-b7bbc0642d0a@gmx.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On 06/18/2018 04:08 PM, Simon Glass wrote: > 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 > --- > > 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)"); Everywhere else in vsprintf.c we use "". I would prefer consistency. @Alex: You already added the patch to efi-next. Could you update the string, please? Best regards Heinrich > > return string(buf, end, uuid, field_width, precision, flags); > } >