OPENSSL_issetugid() as in the main branch.

This commit is contained in:
Ulf Möller 2001-02-19 23:57:18 +00:00
parent 54f7c8571f
commit 15ed15d3e4
5 changed files with 24 additions and 14 deletions

View File

@ -4,6 +4,10 @@
Changes between 0.9.6 and 0.9.6a [xx XXX 2001] Changes between 0.9.6 and 0.9.6a [xx XXX 2001]
*) Don't use getenv in library functions when run as setuid/setgid.
New function OPENSSL_issetugid().
[Ulf Moeller]
*) Avoid false positives in memory leak detection code (crypto/mem_dbg.c) *) Avoid false positives in memory leak detection code (crypto/mem_dbg.c)
due to incorrect handling of multi-threading: due to incorrect handling of multi-threading:

View File

@ -34,8 +34,8 @@ SDIRS= md2 md5 sha mdc2 hmac ripemd \
GENERAL=Makefile README crypto-lib.com install.com GENERAL=Makefile README crypto-lib.com install.com
LIB= $(TOP)/libcrypto.a LIB= $(TOP)/libcrypto.a
LIBSRC= cryptlib.c mem.c mem_dbg.c cversion.c ex_data.c tmdiff.c cpt_err.c ebcdic.c LIBSRC= cryptlib.c mem.c mem_dbg.c cversion.c ex_data.c tmdiff.c cpt_err.c ebcdic.c uid.c
LIBOBJ= cryptlib.o mem.o mem_dbg.o cversion.o ex_data.o tmdiff.o cpt_err.o ebcdic.o LIBOBJ= cryptlib.o mem.o mem_dbg.o cversion.o ex_data.o tmdiff.o cpt_err.o ebcdic.o uid.o
SRC= $(LIBSRC) SRC= $(LIBSRC)

View File

@ -277,6 +277,8 @@ int CRYPTO_is_mem_check_on(void);
const char *SSLeay_version(int type); const char *SSLeay_version(int type);
unsigned long SSLeay(void); unsigned long SSLeay(void);
int OPENSSL_issetugid(void);
int CRYPTO_get_ex_new_index(int idx, STACK_OF(CRYPTO_EX_DATA_FUNCS) **skp, long argl, void *argp, int CRYPTO_get_ex_new_index(int idx, STACK_OF(CRYPTO_EX_DATA_FUNCS) **skp, long argl, void *argp,
CRYPTO_EX_new *new_func, CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func); CRYPTO_EX_new *new_func, CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func);
int CRYPTO_set_ex_data(CRYPTO_EX_DATA *ad, int idx, void *val); int CRYPTO_set_ex_data(CRYPTO_EX_DATA *ad, int idx, void *val);

View File

@ -196,10 +196,11 @@ err:
const char *RAND_file_name(char *buf, int size) const char *RAND_file_name(char *buf, int size)
{ {
char *s; char *s=NULL;
char *ret=NULL; char *ret=NULL;
s=getenv("RANDFILE"); if (OPENSSL_issetugid() == 0)
s=getenv("RANDFILE");
if (s != NULL) if (s != NULL)
{ {
strncpy(buf,s,size-1); strncpy(buf,s,size-1);
@ -208,16 +209,19 @@ const char *RAND_file_name(char *buf, int size)
} }
else else
{ {
s=getenv("HOME"); if (OPENSSL_issetugid() == 0)
if (s == NULL) return(RFILE); s=getenv("HOME");
if (((int)(strlen(s)+strlen(RFILE)+2)) > size) if (s != NULL && (strlen(s)+strlen(RFILE)+2 < size))
return(RFILE); {
strcpy(buf,s); strcpy(buf,s);
#ifndef VMS #ifndef VMS
strcat(buf,"/"); strcat(buf,"/");
#endif #endif
strcat(buf,RFILE); strcat(buf,RFILE);
ret=buf; ret=buf;
}
else
buf[0] = '\0'; /* no file name */
} }
return(ret); return(ret);
} }

View File

@ -53,7 +53,7 @@
* *
*/ */
#include <openssl/crypto.h> #include "openssl/crypto.h"
#if defined(__OpenBSD__) || (defined(__FreeBSD__) && __FreeBSD__ > 2) #if defined(__OpenBSD__) || (defined(__FreeBSD__) && __FreeBSD__ > 2)
@ -64,7 +64,7 @@ int OPENSSL_issetugid(void)
return issetugid(); return issetugid();
} }
#elif defined(OPENSSL_SYS_WIN32) #elif defined(WIN32)
int OPENSSL_issetugid(void) int OPENSSL_issetugid(void)
{ {