]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
lib/loginprompt.c: login_prompt(): Use strtcpy() instead of its pattern
authorAlejandro Colomar <alx@kernel.org>
Thu, 4 Jul 2024 14:32:17 +0000 (16:32 +0200)
committerSerge Hallyn <serge@hallyn.com>
Thu, 31 Oct 2024 02:52:21 +0000 (21:52 -0500)
Signed-off-by: Alejandro Colomar <alx@kernel.org>
lib/loginprompt.c

index cbac28ab8579febf87aa8782d7de0a6939d37299..7d3e23dc1b195e8d6470f90bdba3fb12b052965b 100644 (file)
@@ -21,6 +21,7 @@
 #include "prototypes.h"
 #include "string/memset/memzero.h"
 #include "string/strchr/stpspn.h"
+#include "string/strcpy/strtcpy.h"
 #include "string/strtok/stpsep.h"
 
 
@@ -35,8 +36,8 @@ static void login_exit (MAYBE_UNUSED int sig)
  * login_prompt() displays the standard login prompt.  If ISSUE_FILE
  * is set in login.defs, this file is displayed before the prompt.
  */
-
-void login_prompt (char *name, int namesize)
+void
+login_prompt(char *name, int namesize)
 {
        char buf[1024];
 
@@ -95,10 +96,7 @@ void login_prompt (char *name, int namesize)
         */
 
        cp = stpspn(buf, " \t");
-
-       for (i = 0; i < namesize - 1 && *cp != '\0'; name[i++] = *cp++);
-
-       stpcpy(&name[i], "");
+       strtcpy(name, cp, namesize);
 
        /*
         * Set the SIGQUIT handler back to its original value