summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlan Somers <asomers@FreeBSD.org>2017-05-10 16:06:22 +0000
committerAlan Somers <asomers@FreeBSD.org>2017-05-10 16:06:22 +0000
commitf03b79738ca650b944ae041581b20008076d436c (patch)
tree6315c0aa8eb42dedfd5c55b3b541cec7a8bdda86
parent056b40fd25d3a512e7e4bd2b0dc20c2933fb4c64 (diff)
downloadpw-darwin-f03b79738ca650b944ae041581b20008076d436c.tar.gz
pw-darwin-f03b79738ca650b944ae041581b20008076d436c.tar.zst
pw-darwin-f03b79738ca650b944ae041581b20008076d436c.zip
Don't depend on assert(3) getting evaluated
Reported by: imp MFC after: 3 weeks X-MFC-With: 318141, 318143 Sponsored by: Spectra Logic Corp
-rw-r--r--pw/pw_user.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/pw/pw_user.c b/pw/pw_user.c
index cf38e9c..76849ba 100644
--- a/pw/pw_user.c
+++ b/pw/pw_user.c
@@ -491,6 +491,7 @@ pw_pwcrypt(char *password)
char salt[SALTSIZE + 1];
char *cryptpw;
static char buf[256];
+ size_t pwlen;
/*
* Calculate a salt value
@@ -502,7 +503,8 @@ pw_pwcrypt(char *password)
cryptpw = crypt(password, salt);
if (cryptpw == NULL)
errx(EX_CONFIG, "crypt(3) failure");
- assert(strlcpy(buf, cryptpw, sizeof(buf)) < sizeof(buf));
+ pwlen = strlcpy(buf, cryptpw, sizeof(buf));
+ assert(pwlen < sizeof(buf));
return (buf);
}