X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=src%2Fsrc%2Ftls-openssl.c;h=6f2646f038aee341c30e92fc4467640743e7dffb;hb=57233af5f91cdca9a0232a71fab2d12a538cb1a6;hp=8b70b13c5e9d76dc2be0665181a1b092c38788d0;hpb=983207c12082eb01a5a5a0552962de200f231bf4;p=exim.git diff --git a/src/src/tls-openssl.c b/src/src/tls-openssl.c index 8b70b13c5..6f2646f03 100644 --- a/src/src/tls-openssl.c +++ b/src/src/tls-openssl.c @@ -1970,12 +1970,26 @@ vaguely_random_number(int max) { unsigned int r; int i, needed_len; +static pid_t pidlast = 0; +pid_t pidnow; uschar *p; uschar smallbuf[sizeof(r)]; if (max <= 1) return 0; +pidnow = getpid(); +if (pidnow != pidlast) + { + /* Although OpenSSL documents that "OpenSSL makes sure that the PRNG state + is unique for each thread", this doesn't apparently apply across processes, + so our own warning from vaguely_random_number_fallback() applies here too. + Fix per PostgreSQL. */ + if (pidlast != 0) + RAND_cleanup(); + pidlast = pidnow; + } + /* OpenSSL auto-seeds from /dev/random, etc, but this a double-check. */ if (!RAND_status()) {