diff --git a/src/misc.c b/src/misc.c index 5178e79d..f08dd239 100644 --- a/src/misc.c +++ b/src/misc.c @@ -297,12 +297,33 @@ int extractEmail(char *rawmail, char *email){ } +/* + * Generate a random string from /dev/urandom or + * using the rand() function if not possible + */ + void make_random_string(char *buf, int buflen){ - int i, len; + int i, len, fd; + int urandom=0; static char alphanum[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; + unsigned char s[QUEUE_ID_LEN]; len = strlen(alphanum); + fd = open(RANDOM_POOL, O_RDONLY); + if(fd != -1){ + if(readFromEntropyPool(fd, s, sizeof(s)) == sizeof(s)){ + for(i=0; ittmpfile, sdata->tot_len, sdata->stored_len, parser_state.n_attachments, parser_state.reference, parser_state.message_id,