[Pkg-shadow-commits] r1413 - upstream/trunk/libmisc

nekral-guest at alioth.debian.org nekral-guest at alioth.debian.org
Tue Nov 20 09:20:34 UTC 2007


Author: nekral-guest
Date: 2007-11-20 09:20:34 +0000 (Tue, 20 Nov 2007)
New Revision: 1413

Modified:
   upstream/trunk/libmisc/salt.c
Log:
Hopefully, I review my commits in the morning...


Modified: upstream/trunk/libmisc/salt.c
===================================================================
--- upstream/trunk/libmisc/salt.c	2007-11-20 00:05:54 UTC (rev 1412)
+++ upstream/trunk/libmisc/salt.c	2007-11-20 09:20:34 UTC (rev 1413)
@@ -52,6 +52,7 @@
 }
 #endif /* !HAVE_L64A */
 
+#ifdef ENCRYPTMETHOD_SELECT
 /*
  * Add the salt prefix.
  */
@@ -66,7 +67,8 @@
  */
 static unsigned int SHA_salt_size (void)
 {
-	return 8 + 8*rand ()/(RAND_MAX+1);
+	srand (time (NULL));
+	return 8 + (double)rand () * 9 / RAND_MAX;
 }
 
 /* ! Arguments evaluated twice ! */
@@ -102,7 +104,9 @@
 	if (min_rounds > max_rounds)
 		max_rounds = min_rounds;
 
-	rounds = min_rounds + (max_rounds - min_rounds)*rand ()/(RAND_MAX+1);
+	srand (time (NULL));
+	rounds = min_rounds +
+	         (double)rand () * (max_rounds-min_rounds+1)/RAND_MAX;
 
 	/* Sanity checks. The libc should also check this, but this
 	 * protects against a rounds_prefix overflow. */
@@ -121,6 +125,7 @@
 
 	return rounds_prefix;
 }
+#endif
 
 /*
  * Generate 8 base64 ASCII characters of random salt.  If MD5_CRYPT_ENAB
@@ -180,9 +185,9 @@
 	 * Concatenate a pseudo random salt.
 	 */
 	gettimeofday (&tv, (struct timezone *) 0);
-	strncat (result, sizeof(result), l64a (tv.tv_usec));
-	strncat (result, sizeof(result),
-		 l64a (tv.tv_sec + getpid () + clock ()));
+	strncat (result, l64a (tv.tv_usec), sizeof(result));
+	strncat (result, l64a (tv.tv_sec + getpid () + clock ()),
+	         sizeof(result));
 
 	if (strlen (result) > max_salt_len)	/* magic+salt */
 		result[max_salt_len] = '\0';




More information about the Pkg-shadow-commits mailing list