From 3dfc7586e5e6371845bec073d83ff681c9a0df61 Mon Sep 17 00:00:00 2001 From: Poul-Henning Kamp Date: Sun, 6 Nov 1994 21:08:19 +0000 Subject: [PATCH] Always make the salt a 8 char string (incl '\0') for algorithms that can use it --- usr.bin/passwd/local_passwd.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/usr.bin/passwd/local_passwd.c b/usr.bin/passwd/local_passwd.c index 804c48e3dd4e..89d485fc7eb2 100644 --- a/usr.bin/passwd/local_passwd.c +++ b/usr.bin/passwd/local_passwd.c @@ -36,6 +36,7 @@ static char sccsid[] = "@(#)local_passwd.c 8.3 (Berkeley) 4/2/94"; #endif /* not lint */ #include +#include #include #include @@ -78,6 +79,7 @@ getnewpasswd(pw) int tries; char *p, *t; char buf[_PASSWORD_LEN+1], salt[9]; + struct timeval tv; (void)printf("Changing local password for %s.\n", pw->pw_name); @@ -115,7 +117,12 @@ getnewpasswd(pw) to64(&salt[1], (long)(29 * 25), 4); to64(&salt[5], random(), 4); #else - to64(&salt[0], random(), 2); + /* Make a good size salt for algoritms that can use it. */ + to64(&salt[0], random(), 3); + gettimeofday(&tv,0); + to64(&salt[3], tv.tv_usec, 3); + to64(&salt[6], tv.tv_sec, 2); + salt[8] = '\0'; #endif return (crypt(buf, salt)); }