]> git.ipfire.org Git - thirdparty/shadow.git/commit
Call zustr2stp() where appropriate
authorAlejandro Colomar <alx@kernel.org>
Sun, 30 Jul 2023 16:07:35 +0000 (18:07 +0200)
committerIker Pedrosa <ikerpedrosam@gmail.com>
Fri, 1 Sep 2023 07:39:23 +0000 (09:39 +0200)
commit02b1471d5bef083726bcfdf493cd344974de4009
tree956a788c805cef0010b83ea10cccea21ad168bcd
parent6a576391d66483048095998d6f81b175a1ef5ee3
Call zustr2stp() where appropriate

These calls were intending to copy from a NUL-padded (possibly
non-NUL-terminated) character sequences contained in fixed-width arrays,
into a string, where extra padding is superfluous.  Use the appropriate
call, which removes the superfluous work.  That reduces the chance of
confusing maintainers about the intention of the code.

While at it, use the appropriate third parameter, which is the size of
the source buffer, and not the one of the destination buffer.  As a side
effect, this reduces the use of '-1', which itself reduces the chance of
off-by-one bugs.

Also, since using sizeof() on an array is dangerous, use SIZEOF_ARRAY().

Cc: Christian Göttsche <cgzones@googlemail.com>
Cc: Serge Hallyn <serge@hallyn.com>
Cc: Iker Pedrosa <ipedrosa@redhat.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
lib/utmp.c
src/logoutd.c