From: Alejandro Colomar Date: Thu, 8 Jun 2023 18:39:04 +0000 (+0200) Subject: chfn: Replace STRFCPY() by STRLCPY() X-Git-Tag: 4.15.0-rc1~197 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8e33195c8e05169767e472ed73cd482aafdc2bea;p=thirdparty%2Fshadow.git chfn: Replace STRFCPY() by STRLCPY() 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 --- diff --git a/src/chfn.c b/src/chfn.c index 5018ab87f..242868f47 100644 --- a/src/chfn.c +++ b/src/chfn.c @@ -32,6 +32,7 @@ /*@-exitarg@*/ #include "exitcodes.h" #include "shadowlog.h" +#include "strlcpy.h" /* * Global variables. @@ -275,7 +276,7 @@ static void process_flags (int argc, char **argv) exit (E_NOPERM); } fflg = true; - STRFCPY (fullnm, optarg); + STRLCPY(fullnm, optarg); break; case 'h': if (!may_change_field ('h')) { @@ -284,7 +285,7 @@ static void process_flags (int argc, char **argv) exit (E_NOPERM); } hflg = true; - STRFCPY (homeph, optarg); + STRLCPY(homeph, optarg); break; case 'o': if (!amroot) { @@ -298,7 +299,7 @@ static void process_flags (int argc, char **argv) _("%s: fields too long\n"), Prog); exit (E_NOPERM); } - STRFCPY (slop, optarg); + STRLCPY(slop, optarg); break; case 'r': if (!may_change_field ('r')) { @@ -307,7 +308,7 @@ static void process_flags (int argc, char **argv) exit (E_NOPERM); } rflg = true; - STRFCPY (roomno, optarg); + STRLCPY(roomno, optarg); break; case 'R': /* no-op, handled in process_root_flag () */ break; @@ -321,7 +322,7 @@ static void process_flags (int argc, char **argv) exit (E_NOPERM); } wflg = true; - STRFCPY (workph, optarg); + STRLCPY(workph, optarg); break; default: usage (E_USAGE); @@ -508,7 +509,8 @@ static void get_old_fields (const char *gecos) { char *cp; /* temporary character pointer */ char old_gecos[BUFSIZ]; /* buffer for old GECOS fields */ - STRFCPY (old_gecos, gecos); + + STRLCPY(old_gecos, gecos); /* * Now get the full name. It is the first comma separated field in