* Move the srandom call to gensalt.

* Replace the test on salt_size by an assert.
This commit is contained in:
nekral-guest 2007-11-23 21:04:43 +00:00
parent 43b10b311a
commit 963bfaf521
2 changed files with 9 additions and 4 deletions

View File

@ -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>

View 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);