diff options
| author | 2023-04-16 20:27:38 +0200 | |
|---|---|---|
| committer | 2023-04-16 20:27:38 +0200 | |
| commit | 3ccf4e3759684e9809ad80c2f2639ec5f069beff (patch) | |
| tree | 540cd5bdb3e578f208f8d0efef3eaaae211057ea /utils.c | |
| parent | Replaced random() with arc4random(). (diff) | |
| download | snac2-3ccf4e3759684e9809ad80c2f2639ec5f069beff.tar.gz snac2-3ccf4e3759684e9809ad80c2f2639ec5f069beff.tar.xz snac2-3ccf4e3759684e9809ad80c2f2639ec5f069beff.zip | |
arc4random() does not exist in not-so-old systems, so revert this.
Revert "Replaced random() with arc4random()."
This reverts commit f658f345cac7b24d6fa61f08b4ec09823d28b11a.
Diffstat (limited to 'utils.c')
| -rw-r--r-- | utils.c | 7 |
1 files changed, 4 insertions, 3 deletions
| @@ -198,9 +198,10 @@ void new_password(const char *uid, d_char **clear_pwd, d_char **hashed_pwd) | |||
| 198 | { | 198 | { |
| 199 | int rndbuf[3]; | 199 | int rndbuf[3]; |
| 200 | 200 | ||
| 201 | rndbuf[0] = arc4random(); | 201 | srandom(time(NULL) ^ getpid()); |
| 202 | rndbuf[1] = arc4random(); | 202 | rndbuf[0] = random() & 0xffffffff; |
| 203 | rndbuf[2] = arc4random(); | 203 | rndbuf[1] = random() & 0xffffffff; |
| 204 | rndbuf[2] = random() & 0xffffffff; | ||
| 204 | 205 | ||
| 205 | *clear_pwd = xs_base64_enc((char *)rndbuf, sizeof(rndbuf)); | 206 | *clear_pwd = xs_base64_enc((char *)rndbuf, sizeof(rndbuf)); |
| 206 | *hashed_pwd = hash_password(uid, *clear_pwd, NULL); | 207 | *hashed_pwd = hash_password(uid, *clear_pwd, NULL); |