diff options
Diffstat (limited to 'crypto/rand')
-rw-r--r-- | crypto/rand/randfile.c | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/crypto/rand/randfile.c b/crypto/rand/randfile.c index 02f16aa810..0a4005bd4e 100644 --- a/crypto/rand/randfile.c +++ b/crypto/rand/randfile.c @@ -196,10 +196,11 @@ err: const char *RAND_file_name(char *buf, int size) { - char *s; + char *s=NULL; char *ret=NULL; - s=getenv("RANDFILE"); + if (OPENSSL_issetugid() == 0) + s=getenv("RANDFILE"); if (s != NULL) { strncpy(buf,s,size-1); @@ -208,16 +209,19 @@ const char *RAND_file_name(char *buf, int size) } else { - s=getenv("HOME"); - if (s == NULL) return(RFILE); - if (((int)(strlen(s)+strlen(RFILE)+2)) > size) - return(RFILE); - strcpy(buf,s); + if (OPENSSL_issetugid() == 0) + s=getenv("HOME"); + if (s != NULL && (strlen(s)+strlen(RFILE)+2 < size)) + { + strcpy(buf,s); #ifndef VMS - strcat(buf,"/"); + strcat(buf,"/"); #endif - strcat(buf,RFILE); - ret=buf; + strcat(buf,RFILE); + ret=buf; + } + else + buf[0] = '\0'; /* no file name */ } return(ret); } |