summaryrefslogtreecommitdiffstats
path: root/usr.sbin
diff options
context:
space:
mode:
authorasomers <asomers@FreeBSD.org>2017-05-30 22:48:17 +0000
committerasomers <asomers@FreeBSD.org>2017-05-30 22:48:17 +0000
commitda217d0db5b3aeb619707c893bc2e054f8b9772d (patch)
tree04a06b78aa37b865375c2130dedbe70d41a45eca /usr.sbin
parent8872da9dd903cd4bc3426c50cd1d7121028ac913 (diff)
downloadFreeBSD-src-da217d0db5b3aeb619707c893bc2e054f8b9772d.zip
FreeBSD-src-da217d0db5b3aeb619707c893bc2e054f8b9772d.tar.gz
MFC r318141, r318143-r318144
r318141: strcpy => strlcpy Reported by: Coverity CID: 1352771 Sponsored by: Spectra Logic Corp r318143: strcpy => strlcpy Reported by: Coverity CID: 1006715 Sponsored by: Spectra Logic Corp r318144: Don't depend on assert(3) getting evaluated Reported by: imp X-MFC-With: 318141, 318143 Sponsored by: Spectra Logic Corp
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/pw/pw_user.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/usr.sbin/pw/pw_user.c b/usr.sbin/pw/pw_user.c
index f93f9ed..8555ed1 100644
--- a/usr.sbin/pw/pw_user.c
+++ b/usr.sbin/pw/pw_user.c
@@ -35,6 +35,7 @@ static const char rcsid[] =
#include <sys/time.h>
#include <sys/types.h>
+#include <assert.h>
#include <ctype.h>
#include <dirent.h>
#include <err.h>
@@ -492,6 +493,7 @@ pw_pwcrypt(char *password)
char salt[SALTSIZE + 1];
char *cryptpw;
static char buf[256];
+ size_t pwlen;
/*
* Calculate a salt value
@@ -503,7 +505,9 @@ pw_pwcrypt(char *password)
cryptpw = crypt(password, salt);
if (cryptpw == NULL)
errx(EX_CONFIG, "crypt(3) failure");
- return strcpy(buf, cryptpw);
+ pwlen = strlcpy(buf, cryptpw, sizeof(buf));
+ assert(pwlen < sizeof(buf));
+ return (buf);
}
static char *
OpenPOWER on IntegriCloud