]> granicus.if.org Git - shadow/commitdiff
* Move the srandom call to gensalt.
authornekral-guest <nekral-guest@5a98b0ae-9ef6-0310-add3-de5d479b70d7>
Fri, 23 Nov 2007 21:04:43 +0000 (21:04 +0000)
committernekral-guest <nekral-guest@5a98b0ae-9ef6-0310-add3-de5d479b70d7>
Fri, 23 Nov 2007 21:04:43 +0000 (21:04 +0000)
* Replace the test on salt_size by an assert.

ChangeLog
libmisc/salt.c

index 4d24babf3eaea155313f2a7fe90c1797e7f09cc7..46cde8ea22ea29ffd635313ef8f093e6a13dcb14 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2007-11-23  Nicolas François  <nicolas.francois@centraliens.net>
+
+       * libmisc/salt.c: Move the srandom call to gensalt.
+       * libmisc/salt.c (gensalt): Replace the test on salt_size by an
+       assert.
+
 2007-11-23  Nicolas François  <nicolas.francois@centraliens.net>
 
        Patch contributed by Dan Kopecek <dkopecek@redhat.com>
index a64811870fc10baf23ece0c42a81e773b8e49c75..280b860237a7f7459bd7d9723ebfd4234a7ee571 100644 (file)
@@ -143,14 +143,14 @@ char *gensalt (unsigned int salt_size) {
  
   salt[0] = '\0';
   
-  if (salt_size >= MIN_SALT_SIZE &&
-      salt_size <= MAX_SALT_SIZE) {
+       assert (salt_size >= MIN_SALT_SIZE &&
+               salt_size <= MAX_SALT_SIZE);
+       srandom ((unsigned int)time(NULL));
     strcat (salt, l64a (random()));
     do {
       strcat (salt, l64a (random()));
     } while (strlen (salt) < salt_size);
     salt[salt_size] = '\0';
-  }
   
   return salt;
 }
@@ -217,7 +217,6 @@ char *crypt_make_salt (char *meth, void *arg)
         * Concatenate a pseudo random salt.
         */
        assert (sizeof (result) > strlen (result) + salt_len);
-       srandom ((unsigned int)time(NULL));
        strncat (result, gensalt (salt_len),
                 sizeof (result) - strlen (result) - 1);