]> git.ipfire.org Git - thirdparty/shadow.git/commit
lib/, src/: Use strsep(3) instead of strtok(3)
authorAlejandro Colomar <alx@kernel.org>
Thu, 4 Jul 2024 11:21:12 +0000 (13:21 +0200)
committerSerge Hallyn <serge@hallyn.com>
Thu, 5 Dec 2024 21:33:32 +0000 (15:33 -0600)
commit90afe61003efd885df252764aef2a31c185fe55f
tree58b728b937f1f7559ff016344349abcdbdd7d1da
parentbdb5e2b79ff0c15ecfed172263f94bd94766ec57
lib/, src/: Use strsep(3) instead of strtok(3)

strsep(3) is stateless, and so is easier to reason about.

It also has a slight difference: strtok(3) jumps over empty fields,
while strsep(3) respects them as empty fields.  In most of the cases
where we were using strtok(3), it makes more sense to respect empty
fields, and this commit probably silently fixes a few bugs.

In other cases (most notably filesystem paths), contiguous delimiters
("//") should be collapsed, so strtok(3) still makes more sense there.
This commit doesn't replace such strtok(3) calls.

While at this, remove some useless variables used by these calls, and
reduce the scope of others.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
lib/addgrps.c
lib/console.c
lib/motd.c
src/groupadd.c
src/groupmod.c
src/login_nopam.c
src/suauth.c