Skip to content

Commit

Permalink
lib/loginprompt.c: login_prompt(): Use strtcpy() instead of its pattern
Browse files Browse the repository at this point in the history
Signed-off-by: Alejandro Colomar <[email protected]>
  • Loading branch information
alejandro-colomar committed Oct 14, 2024
1 parent 4a15739 commit 3a253dc
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions lib/loginprompt.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"


Expand All @@ -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];

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 3a253dc

Please sign in to comment.