]> git.cameronkatri.com Git - pw-darwin.git/commitdiff
Don't depend on assert(3) getting evaluated
authorAlan Somers <asomers@FreeBSD.org>
Wed, 10 May 2017 16:06:22 +0000 (16:06 +0000)
committerAlan Somers <asomers@FreeBSD.org>
Wed, 10 May 2017 16:06:22 +0000 (16:06 +0000)
Reported by: imp
MFC after: 3 weeks
X-MFC-With: 318141, 318143
Sponsored by: Spectra Logic Corp

pw/pw_user.c

index cf38e9ccb345431b1b74b0b0ba63405266fa8027..76849ba9554633ff4107423cf15b4616f3503ee6 100644 (file)
@@ -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);
 }