]> git.ipfire.org Git - thirdparty/shadow.git/commit
lib/: Remove off-by-one bugs in calls to strncpy(3)
authorAlejandro Colomar <alx@kernel.org>
Wed, 15 Nov 2023 21:14:18 +0000 (22:14 +0100)
committerSerge Hallyn <serge@hallyn.com>
Sun, 26 Nov 2023 12:48:18 +0000 (06:48 -0600)
commit07ab1af55c32406a5c287cc213cfab75cd0265cd
tree48999d6a0ff441a5c45d33f4979dd6b803d784a8
parent81f0e6a30fe27cc20a8a65e1d74eee589e548bb8
lib/: Remove off-by-one bugs in calls to strncpy(3)

We're not even zeroing the last byte after this call.  This was a
completely gratuitous truncation of one byte, and the resulting
character array still wasn't guaranteed to be null terminated, because
strncpy(3) can't do that.

Just to clarify, none of these structures needed zeroing, as they are
treated as null-padded fixed-size character arrays.  Calling strncpy(3)
was actually the correct call, and the only problem was unnecessarily
truncating strings by one byte more than necessary.

Cc: Matthew House <mattlloydhouse@gmail.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
lib/log.c
lib/utmp.c