summaryrefslogtreecommitdiffstats
path: root/crypto/rand
diff options
context:
space:
mode:
authorUlf Möller <ulf@openssl.org>2001-02-19 23:57:18 +0000
committerUlf Möller <ulf@openssl.org>2001-02-19 23:57:18 +0000
commit15ed15d3e47defeb3ae9335aa2b628f7cdabf9b7 (patch)
tree23b8665eb35dd48408c6d903ee51b9416284413c /crypto/rand
parent54f7c8571f6d82fcf71ecec39ef4845f8be17d9d (diff)
OPENSSL_issetugid() as in the main branch.
Diffstat (limited to 'crypto/rand')
-rw-r--r--crypto/rand/randfile.c24
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);
}