logo

utils-std

Collection of commonly available Unix tools
commit: 2a2221d859e0280975b5d5d0c8fd4bee87ea1feb
parent b309903b578f59a1655deb2dbcebf527271b700f
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Thu,  2 May 2024 13:14:16 +0200

cmd/printf.c: Prevent null-dereference in getchr, getstr, getnum

Diffstat:

Mcmd/printf.c6+++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/cmd/printf.c b/cmd/printf.c @@ -604,14 +604,14 @@ escape(char *fmt, int percent, size_t *len) static int getchr(void) { - if(!*gargv) return ('\0'); + if(!gargv || !*gargv) return ('\0'); return ((int)**gargv++); } static const char * getstr(void) { - if(!*gargv) return (""); + if(!gargv || !*gargv) return (""); return (*gargv++); } @@ -639,7 +639,7 @@ getnum(intmax_t *ip, uintmax_t *uip, int signedconv) char *ep; int rval; - if(!*gargv) + if(!gargv || !*gargv) { *ip = *uip = 0; return (0);