]> git.ipfire.org Git - thirdparty/shadow.git/commit
lib/, src/: snprintf(3) already terminates strings with NUL
authorAlejandro Colomar <alx@kernel.org>
Sat, 26 Aug 2023 09:53:25 +0000 (11:53 +0200)
committerIker Pedrosa <ikerpedrosam@gmail.com>
Wed, 13 Dec 2023 11:34:30 +0000 (12:34 +0100)
commit9858133cc68365a7a26a847258a353df6dc40f38
tree0480fce8dfd1fbfa4ec11da1e8c33a70827ae0b1
parent93a5c47c2cb91cb79b3ae991d3ab70c6cba9fa86
lib/, src/: snprintf(3) already terminates strings with NUL

We don't need to terminate them manually after the call.  Remove all
that paranoid code, which in some cases was even wrong.  While at it,
let's do a few more things:

-  Use sizeof(buf) for the size of the buffer.  I found that a few cases
   were passing one less byte (probably because the last one was
   manually zeroed later).  This caused a double NUL.  snprintf(3) wants
   the size of the entire buffer to properly terminate it.  Passing the
   exact value hardcoded is brittle, so use sizeof().

-  Align and improve style of variable declarations.  This makes them
   appear in this diff, which will help review the patch.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
lib/shell.c
lib/user_busy.c
src/gpasswd.c