From 2ffc1a76f58aae642358d7a4fb9a305c98e26273 Mon Sep 17 00:00:00 2001 From: Alejandro Colomar Date: Thu, 8 Jun 2023 20:46:09 +0200 Subject: [PATCH] chsh: Replace STRFCPY() by STRLCPY() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The variables are only being read as strings (char *), so data after the '\0' can't be leaked. Cc: Christian Göttsche Cc: Serge Hallyn Cc: Iker Pedrosa Signed-off-by: Alejandro Colomar --- src/chsh.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/chsh.c b/src/chsh.c index e069b9fb..29f8afc8 100644 --- a/src/chsh.c +++ b/src/chsh.c @@ -31,6 +31,7 @@ /*@-exitarg@*/ #include "exitcodes.h" #include "shadowlog.h" +#include "strlcpy.h" #ifndef SHELLS_FILE #define SHELLS_FILE "/etc/shells" @@ -257,7 +258,7 @@ static void process_flags (int argc, char **argv) break; case 's': sflg = true; - STRFCPY (loginsh, optarg); + STRLCPY(loginsh, optarg); break; default: usage (E_USAGE); @@ -552,7 +553,7 @@ int main (int argc, char **argv) * file, or use the value from the command line. */ if (!sflg) { - STRFCPY (loginsh, pw->pw_shell); + STRLCPY(loginsh, pw->pw_shell); } /*