From: Andy Polyakov Date: Tue, 20 Sep 2016 14:59:32 +0000 (+0200) Subject: rand/randfile.c: restore fallback to $HOME for non-setuid programs. X-Git-Tag: OpenSSL_1_1_1-pre1~3482 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=799c1293fcf412db64dcc8a09a6b11cc755914dc;p=openssl rand/randfile.c: restore fallback to $HOME for non-setuid programs. Reported in GH#1589, but solution is different from suggested. Reviewed-by: Rich Salz --- diff --git a/crypto/rand/randfile.c b/crypto/rand/randfile.c index 7aeb871743..16cc27aa9b 100644 --- a/crypto/rand/randfile.c +++ b/crypto/rand/randfile.c @@ -316,12 +316,14 @@ const char *RAND_file_name(char *buf, size_t size) } } #else - if (OPENSSL_issetugid() == 0) { - s = getenv("RANDFILE"); - } else { + if (OPENSSL_issetugid() != 0) { use_randfile = 0; - if (OPENSSL_issetugid() == 0) + } else { + s = getenv("RANDFILE"); + if (s == NULL || *s == '\0') { + use_randfile = 0; s = getenv("HOME"); + } } #endif #ifdef DEFAULT_HOME