From: Alejandro Colomar Date: Fri, 18 Jul 2025 22:18:30 +0000 (+0200) Subject: src/chfn.c: Write an empty string if there's nothing in the GECOS field X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=9c61f5f0e430426214dbf9214b415d684330d8e2;p=thirdparty%2Fshadow.git src/chfn.c: Write an empty string if there's nothing in the GECOS field Otherwise, the buffer would contain garbage. Signed-off-by: Alejandro Colomar --- diff --git a/src/chfn.c b/src/chfn.c index 6834366c0..4c7f5c559 100644 --- a/src/chfn.c +++ b/src/chfn.c @@ -480,23 +480,23 @@ static void get_old_fields (const char *gecos) f = strsep(&p, ","); if (!fflg) - strcpy(fullnm, f); + strcpy(fullnm, f ?: ""); f = strsep(&p, ","); - if (!rflg && f != NULL) - strcpy(roomno, f); + if (!rflg) + strcpy(roomno, f ?: ""); f = strsep(&p, ","); - if (!wflg && f != NULL) - strcpy(workph, f); + if (!wflg) + strcpy(workph, f ?: ""); f = strsep(&p, ","); - if (!hflg && f != NULL) - strcpy(homeph, f); + if (!hflg) + strcpy(homeph, f ?: ""); /* Anything left over is "slop". */ - if (!oflg && p != NULL) - strcpy(slop, p); + if (!oflg) + strcpy(slop, p ?: ""); } /*