summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorAhmad Fatoum <a.fatoum@pengutronix.de>2024-03-04 19:58:49 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2024-03-05 16:28:04 +0100
commit85ffcfca19bab72a68b339c17fe8ff46691eebc9 (patch)
treeb162501cd4521c2f7865414291ecc849e828e4e7 /lib
parentb0b6b9bd263420a75a48871a2ddb87a33ac42493 (diff)
downloadbarebox-85ffcfca19bab72a68b339c17fe8ff46691eebc9.tar.gz
barebox-85ffcfca19bab72a68b339c17fe8ff46691eebc9.tar.xz
vsprintf: guard against NULL in UUID %pU
To make %pU more useful for debugging, have it handle NULL gracefully. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20240304190038.3486881-5-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'lib')
-rw-r--r--lib/vsprintf.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/vsprintf.c b/lib/vsprintf.c
index 3dda158683..b12d04e378 100644
--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
@@ -329,6 +329,10 @@ char *uuid_string(char *buf, const char *end, const u8 *addr, int field_width,
const u8 *index = be;
bool uc = false;
+ /* If addr == NULL output the string '<NULL>' */
+ if (!addr)
+ return string(buf, end, NULL, field_width, precision, flags);
+
switch (*(++fmt)) {
case 'L':
uc = true; /* fall-through */