From b4668e2bd68fc700ca027d1c77f69b5be960daa6 Mon Sep 17 00:00:00 2001 From: Solomon Peachy Date: Thu, 20 Jun 2024 15:22:36 -0400 Subject: libc: Check for a null string argument in *printf If we are passed a null string argument, use the fixed string "(null)" instead. Change-Id: I4f70ae76cdcac1104ff1e42dc3b1a5f03e2723fe --- firmware/common/vuprintf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/firmware/common/vuprintf.c b/firmware/common/vuprintf.c index a040a3f0ac..4f669b2610 100644 --- a/firmware/common/vuprintf.c +++ b/firmware/common/vuprintf.c @@ -511,7 +511,7 @@ static inline const char * format_s(const void *str, return NULL; /* wchar_t support for now */ } - const char *s = str; + const char *s = str ? str : "(null)"; size_t len; /* string length may be specified by precision instead of \0- terminated; however, don't go past a \0 if one is there */ -- cgit v1.2.3