aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--loginutils/passwd.c27
1 files changed, 10 insertions, 17 deletions
diff --git a/loginutils/passwd.c b/loginutils/passwd.c
index 1f488290a..a062596b4 100644
--- a/loginutils/passwd.c
+++ b/loginutils/passwd.c
@@ -5,7 +5,6 @@
5 5
6#include "busybox.h" 6#include "busybox.h"
7#include <syslog.h> 7#include <syslog.h>
8#include <sys/times.h> /* times() */
9 8
10 9
11static void nuke_str(char *str) 10static void nuke_str(char *str)
@@ -16,7 +15,8 @@ static void nuke_str(char *str)
16 15
17static int i64c(int i) 16static int i64c(int i)
18{ 17{
19 if (i <= 0) 18 i &= 0x3f;
19 if (i == 0)
20 return '.'; 20 return '.';
21 if (i == 1) 21 if (i == 1)
22 return '/'; 22 return '/';
@@ -30,23 +30,16 @@ static int i64c(int i)
30 30
31static void crypt_make_salt(char *p, int cnt) 31static void crypt_make_salt(char *p, int cnt)
32{ 32{
33#if !defined(__GLIBC__) 33 unsigned x = x; /* it's pointless to initialize it anyway :) */
34 struct tms t;
35#define TIMES times(&t)
36#else
37/* glibc allows for times(NULL) a-la time() */
38#define TIMES times(NULL)
39#endif
40 unsigned long x = x; /* it's pointless to initialize it anyway :) */
41 34
42 x += getpid(); 35 x += getpid() + time(NULL) + clock();
43 do { 36 do {
44 /* clock() and times() variability is different between systems */ 37 /* x = (x*1664525 + 1013904223) mod 2^32 generator is lame
45 /* hopefully at least one is good enough */ 38 * (low-order bit is not "random", etc...),
46 x += time(NULL) + clock() + TIMES; 39 * but for our purposes it is good enough */
47 *p++ = i64c(((x >> 18) ^ (x >> 6)) & 0x3f); 40 x = x*1664525 + 1013904223;
48 *p++ = i64c(((x >> 12) ^ x) & 0x3f); 41 *p++ = i64c(x >> 16);
49 usleep(100); /* or else time() etc won't change */ 42 *p++ = i64c(x >> 22);
50 } while (--cnt); 43 } while (--cnt);
51 *p = '\0'; 44 *p = '\0';
52} 45}