From cf1d7bdf456c60c6be8a6c26d5f4d2424ef5e870 Mon Sep 17 00:00:00 2001 From: SJ Date: Fri, 28 Oct 2016 22:11:14 +0200 Subject: [PATCH] improved queue id generation Change-Id: I8a0f91eabd3eaf6c074946f723147a3f6ef925d9 Signed-off-by: SJ --- src/misc.c | 23 ++++++++++++++++++++++- src/piler.c | 2 +- 2 files changed, 23 insertions(+), 2 deletions(-) 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,