From: Alejandro Colomar Date: Mon, 17 Feb 2025 12:23:37 +0000 (+0100) Subject: src/chfn.c: Partially revert "lib/, src/: Use strsep(3) instead of its pattern" X-Git-Tag: 4.17.4~14 X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=b74c7c505897bc9d7a76871e7643893faafb1218;p=thirdparty%2Fshadow.git src/chfn.c: Partially revert "lib/, src/: Use strsep(3) instead of its pattern" This partially reverts commit 16cb664865541162c504a6f5ef5ca4b38b5e0c9a. I'll try to reintroduce this change more carefully. For now, let's revert to a known-good state. The problem was due to accidentally ignoring the effects of the 'break' on the 'cp' variable. Fixes: 16cb66486554 (2024-07-01; "lib/, src/: Use strsep(3) instead of its pattern") Closes: Link: Link: Reported-by: Chris Hofstaedtler Suggested-by: Chris Hofstaedtler Tested-by: Chris Hofstaedtler Signed-off-by: Alejandro Colomar --- diff --git a/src/chfn.c b/src/chfn.c index 4c96fba28..f06cb4495 100644 --- a/src/chfn.c +++ b/src/chfn.c @@ -216,27 +216,32 @@ static void new_fields (void) */ static char *copy_field (char *in, char *out, char *extra) { - while (NULL != in) { - char *f; + char *cp = NULL; - f = strsep(&in, ","); + while (NULL != in) { + cp = strchr (in, ','); + if (NULL != cp) { + *cp++ = '\0'; + } - if (strchr(f, '=') == NULL) + if (strchr (in, '=') == NULL) { break; + } if (NULL != extra) { if (!streq(extra, "")) { strcat (extra, ","); } - strcat(extra, f); + strcat (extra, in); } + in = cp; } if ((NULL != in) && (NULL != out)) { strcpy (out, in); } - return in; + return cp; } /*