passwd: Fix potential buffer overflow

Fixes Coverity CID 66956

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
This commit is contained in:
Corinna Vinschen 2016-10-23 17:16:30 +02:00
parent 526107a753
commit 79edb254ac
1 changed files with 2 additions and 1 deletions

View File

@ -592,7 +592,8 @@ main (int argc, char **argv)
return SetModals (xarg, narg, iarg, Larg, server);
}
strcpy (user, optind >= argc ? getlogin () : argv[optind]);
user[0] = '\0';
strncat (user, optind >= argc ? getlogin () : argv[optind], UNLEN);
/* Changing password for calling user? Use logonserver for user as well. */
if (!server && optind >= argc)