From 963bfaf521cae97ee78328541838700be9a492e2 Mon Sep 17 00:00:00 2001 From: nekral-guest Date: Fri, 23 Nov 2007 21:04:43 +0000 Subject: [PATCH] * Move the srandom call to gensalt. * Replace the test on salt_size by an assert. --- ChangeLog | 6 ++++++ libmisc/salt.c | 7 +++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4d24babf..46cde8ea 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2007-11-23 Nicolas François + + * 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 Patch contributed by Dan Kopecek diff --git a/libmisc/salt.c b/libmisc/salt.c index a6481187..280b8602 100644 --- a/libmisc/salt.c +++ b/libmisc/salt.c @@ -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);