aboutsummaryrefslogtreecommitdiff
path: root/crypto/openssl/crypto/rand/randfile.c
diff options
context:
space:
mode:
authorKris Kennaway <kris@FreeBSD.org>2001-05-20 03:07:21 +0000
committerKris Kennaway <kris@FreeBSD.org>2001-05-20 03:07:21 +0000
commit5740a5e34c49bfc6885d8602958155fc91b62765 (patch)
treeaf21ae7d0d7d432ead379f1689adfee9ffe965f6 /crypto/openssl/crypto/rand/randfile.c
parentde7cdddab120ecc07d412749bfb3f191c4e0afe3 (diff)
downloadsrc-5740a5e34c49bfc6885d8602958155fc91b62765.tar.gz
src-5740a5e34c49bfc6885d8602958155fc91b62765.zip
Initial import of OpenSSL 0.9.6a
Notes
Notes: svn path=/vendor-crypto/openssl/dist/; revision=76866
Diffstat (limited to 'crypto/openssl/crypto/rand/randfile.c')
-rw-r--r--crypto/openssl/crypto/rand/randfile.c28
1 files changed, 16 insertions, 12 deletions
diff --git a/crypto/openssl/crypto/rand/randfile.c b/crypto/openssl/crypto/rand/randfile.c
index 02f16aa81032..7548ac324c05 100644
--- a/crypto/openssl/crypto/rand/randfile.c
+++ b/crypto/openssl/crypto/rand/randfile.c
@@ -73,7 +73,7 @@
# include <sys/stat.h>
#endif
-#include <openssl/e_os.h>
+#include "openssl/e_os.h"
#include <openssl/crypto.h>
#include <openssl/rand.h>
@@ -194,12 +194,13 @@ err:
return (rand_err ? -1 : ret);
}
-const char *RAND_file_name(char *buf, int size)
+const char *RAND_file_name(char *buf, size_t 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);
}