]> git.cameronkatri.com Git - pw-darwin.git/blobdiff - pw/pw_user.c
Handle NULL return from crypt(3). Mostly from DragonFly
[pw-darwin.git] / pw / pw_user.c
index 0001a4125e813b36a3164e16244aac399d796cc1..b59789c9f576148cee89b84d8ff3757abf551abb 100644 (file)
@@ -1028,6 +1028,7 @@ pw_pwcrypt(char *password)
 {
        int             i;
        char            salt[SALTSIZE + 1];
+       char            *cryptpw;
 
        static char     buf[256];
 
@@ -1038,7 +1039,10 @@ pw_pwcrypt(char *password)
                salt[i] = chars[arc4random_uniform(sizeof(chars) - 1)];
        salt[SALTSIZE] = '\0';
 
-       return strcpy(buf, crypt(password, salt));
+       cryptpw = crypt(password, salt);
+       if (cryptpw == NULL)
+               errx(EX_CONFIG, "crypt(3) failure");
+       return strcpy(buf, cryptpw);
 }