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: <https://github.com/shadow-maint/shadow/issues/1210>
Link: <https://github.com/shadow-maint/shadow/pull/1213>
Link: <https://github.com/shadow-maint/shadow/pull/1212>
Reported-by: Chris Hofstaedtler <zeha@debian.org>
Suggested-by: Chris Hofstaedtler <zeha@debian.org>
Tested-by: Chris Hofstaedtler <zeha@debian.org>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
*/
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;
}
/*