diff options
author | Richard Levitte <levitte@openssl.org> | 2001-03-13 09:49:18 +0300 |
---|---|---|
committer | Richard Levitte <levitte@openssl.org> | 2001-03-13 09:49:18 +0300 |
commit | 3d4bb90138b0586f88f44a67b7ea3b7ab4a88081 (patch) | |
tree | a07807d35f54995179f79dcab1f31c50b41c787b /crypto/rand | |
parent | c540bd28518328e7de9cf1b1af2d4b12e7c9e776 (diff) |
Merge in the 0.9.6-stable branch once more and hope for better
results.
Diffstat (limited to 'crypto/rand')
-rw-r--r-- | crypto/rand/Makefile.ssl | 3 | ||||
-rw-r--r-- | crypto/rand/rand_win.c | 5 | ||||
-rw-r--r-- | crypto/rand/randfile.c | 31 |
3 files changed, 24 insertions, 15 deletions
diff --git a/crypto/rand/Makefile.ssl b/crypto/rand/Makefile.ssl index cffd57154e..ee2d7874ff 100644 --- a/crypto/rand/Makefile.ssl +++ b/crypto/rand/Makefile.ssl @@ -39,7 +39,8 @@ all: lib lib: $(LIBOBJ) $(AR) $(LIB) $(LIBOBJ) - $(RANLIB) $(LIB) + @echo You may get an error following this line. Please ignore. + - $(RANLIB) $(LIB) @touch lib files: diff --git a/crypto/rand/rand_win.c b/crypto/rand/rand_win.c index 9f2dcff9a9..dbd82b3686 100644 --- a/crypto/rand/rand_win.c +++ b/crypto/rand/rand_win.c @@ -570,14 +570,15 @@ static void readtimer(void) DWORD w; LARGE_INTEGER l; static int have_perfc = 1; -#ifndef __GNUC__ +#ifdef _MSC_VER static int have_tsc = 1; DWORD cyclecount; if (have_tsc) { __try { __asm { - rdtsc + _emit 0x0f + _emit 0x31 mov cyclecount, eax } RAND_add(&cyclecount, sizeof(cyclecount), 1); diff --git a/crypto/rand/randfile.c b/crypto/rand/randfile.c index 528e410f74..a92541371f 100644 --- a/crypto/rand/randfile.c +++ b/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> @@ -83,6 +83,9 @@ /* #define RFILE ".rnd" - defined in ../../e_os.h */ +/* Note that these functions are intended for seed files only. + * Entropy devices and EGD sockets are handled in rand_unix.c */ + int RAND_load_file(const char *file, long bytes) { /* If bytes >= 0, read up to 'bytes' bytes. @@ -117,7 +120,7 @@ int RAND_load_file(const char *file, long bytes) if (bytes > 0) { bytes-=n; - if (bytes == 0) break; + if (bytes <= 0) break; } } fclose(in); @@ -193,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); @@ -205,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); } |