# HG changeset patch # User Adam Chlipala # Date 1421937980 18000 # Node ID 882556b3029d070d3bbede7c9cf802e23882762a # Parent 7755f00a4fc3dc565f8a52bbd4665f9018ab77d3 Fix silly mistake from last commit; also switch away from rand() in openssl.c diff -r 7755f00a4fc3 -r 882556b3029d src/c/openssl.c --- a/src/c/openssl.c Mon Jan 12 12:02:54 2015 -0500 +++ b/src/c/openssl.c Thu Jan 22 09:46:20 2015 -0500 @@ -9,6 +9,7 @@ #include #include +#include #define PASSSIZE 4 @@ -19,10 +20,11 @@ char *uw_sig_file = NULL; static void random_password() { - int i; - - for (i = 0; i < PASSSIZE; ++i) - password[i] = rand(); + if (!RAND_bytes((unsigned char *)password, sizeof password)) { + fprintf(stderr, "Error generating random password\n"); + perror("RAND_bytes"); + exit(1); + } } void uw_init_crypto() { diff -r 7755f00a4fc3 -r 882556b3029d src/c/urweb.c --- a/src/c/urweb.c Mon Jan 12 12:02:54 2015 -0500 +++ b/src/c/urweb.c Thu Jan 22 09:46:20 2015 -0500 @@ -171,11 +171,11 @@ static uw_Basis_int my_rand() { pthread_mutex_lock(&rand_mutex); - int r = RAND_bytes((unsigned char *)&ret, sizeof ret); + int ret, r = RAND_bytes((unsigned char *)&ret, sizeof ret); pthread_mutex_unlock(&rand_mutex); if (r) - return abs(r); + return abs(ret); else return -1; } @@ -362,8 +362,6 @@ extern void uw_init_crypto(); void uw_global_init() { - srand(time(NULL) ^ getpid()); - clients = malloc(0); uw_global_custom();