]> git.cameronkatri.com Git - pw-darwin.git/commitdiff
strcpy => strlcpy
authorAlan Somers <asomers@FreeBSD.org>
Wed, 10 May 2017 15:38:06 +0000 (15:38 +0000)
committerAlan Somers <asomers@FreeBSD.org>
Wed, 10 May 2017 15:38:06 +0000 (15:38 +0000)
Reported by: Coverity
CID: 1006715
MFC after: 3 weeks
Sponsored by: Spectra Logic Corp

pw/pw_user.c

index 5466becfb585282db5413c085cfc4aed933d1a1c..cf38e9ccb345431b1b74b0b0ba63405266fa8027 100644 (file)
@@ -33,6 +33,7 @@ static const char rcsid[] =
 #include <sys/param.h>
 #include <sys/types.h>
 
+#include <assert.h>
 #include <ctype.h>
 #include <dirent.h>
 #include <err.h>
@@ -501,7 +502,8 @@ pw_pwcrypt(char *password)
        cryptpw = crypt(password, salt);
        if (cryptpw == NULL)
                errx(EX_CONFIG, "crypt(3) failure");
-       return strcpy(buf, cryptpw);
+       assert(strlcpy(buf, cryptpw, sizeof(buf)) < sizeof(buf));
+       return (buf);
 }
 
 static char *