提交 49e3c9d8 编写于 作者: A Andy Polyakov

Mask libcrypto references to stat with OPENSSL_NO_POSIX_IO.

上级 1715e488
...@@ -75,9 +75,7 @@ ...@@ -75,9 +75,7 @@
#ifndef NO_SYS_TYPES_H #ifndef NO_SYS_TYPES_H
# include <sys/types.h> # include <sys/types.h>
#endif #endif
#ifdef MAC_OS_pre_X #ifndef OPENSSL_NO_POSIX_IO
# include <stat.h>
#else
# include <sys/stat.h> # include <sys/stat.h>
#endif #endif
...@@ -96,21 +94,25 @@ int RAND_load_file(const char *file, long bytes) ...@@ -96,21 +94,25 @@ int RAND_load_file(const char *file, long bytes)
* if bytes == -1, read complete file. */ * if bytes == -1, read complete file. */
MS_STATIC unsigned char buf[BUFSIZE]; MS_STATIC unsigned char buf[BUFSIZE];
#ifndef OPENSSL_NO_POSIX_IO
struct stat sb; struct stat sb;
#endif
int i,ret=0,n; int i,ret=0,n;
FILE *in; FILE *in;
if (file == NULL) return(0); if (file == NULL) return(0);
#ifndef OPENSSL_NO_POSIX_IO
i=stat(file,&sb); i=stat(file,&sb);
/* If the state fails, put some crap in anyway */ /* If the state fails, put some crap in anyway */
RAND_add(&sb,sizeof(sb),0.0); RAND_add(&sb,sizeof(sb),0.0);
if (i < 0) return(0); if (i < 0) return(0);
#endif
if (bytes == 0) return(ret); if (bytes == 0) return(ret);
in=fopen(file,"rb"); in=fopen(file,"rb");
if (in == NULL) goto err; if (in == NULL) goto err;
#if defined(S_IFBLK) && defined(S_IFCHR) #if defined(S_IFBLK) && defined(S_IFCHR) && !defined(OPNESSL_NO_POSIX_IO)
if (sb.st_mode & (S_IFBLK | S_IFCHR)) { if (sb.st_mode & (S_IFBLK | S_IFCHR)) {
/* this file is a device. we don't want read an infinite number /* this file is a device. we don't want read an infinite number
* of bytes from a random device, nor do we want to use buffered * of bytes from a random device, nor do we want to use buffered
...@@ -149,6 +151,7 @@ int RAND_write_file(const char *file) ...@@ -149,6 +151,7 @@ int RAND_write_file(const char *file)
int i,ret=0,rand_err=0; int i,ret=0,rand_err=0;
FILE *out = NULL; FILE *out = NULL;
int n; int n;
#ifndef OPENSSL_NO_POSIX_IO
struct stat sb; struct stat sb;
i=stat(file,&sb); i=stat(file,&sb);
...@@ -164,8 +167,9 @@ int RAND_write_file(const char *file) ...@@ -164,8 +167,9 @@ int RAND_write_file(const char *file)
} }
#endif #endif
} }
#endif
#if defined(O_CREAT) && !defined(OPENSSL_SYS_WIN32) #if defined(O_CREAT) && !defined(OPENSSL_SYS_WIN32) && !defined(OPENSSL_NO_POSIX_IO)
{ {
/* For some reason Win32 can't write to files created this way */ /* For some reason Win32 can't write to files created this way */
......
...@@ -65,9 +65,7 @@ ...@@ -65,9 +65,7 @@
#ifndef NO_SYS_TYPES_H #ifndef NO_SYS_TYPES_H
# include <sys/types.h> # include <sys/types.h>
#endif #endif
#ifdef MAC_OS_pre_X #ifndef OPENSSL_NO_POSIX_IO
# include <stat.h>
#else
# include <sys/stat.h> # include <sys/stat.h>
#endif #endif
...@@ -254,7 +252,6 @@ static int get_cert_by_subject(X509_LOOKUP *xl, int type, X509_NAME *name, ...@@ -254,7 +252,6 @@ static int get_cert_by_subject(X509_LOOKUP *xl, int type, X509_NAME *name,
int i,j,k; int i,j,k;
unsigned long h; unsigned long h;
BUF_MEM *b=NULL; BUF_MEM *b=NULL;
struct stat st;
X509_OBJECT stmp,*tmp; X509_OBJECT stmp,*tmp;
const char *postfix=""; const char *postfix="";
...@@ -334,8 +331,13 @@ static int get_cert_by_subject(X509_LOOKUP *xl, int type, X509_NAME *name, ...@@ -334,8 +331,13 @@ static int get_cert_by_subject(X509_LOOKUP *xl, int type, X509_NAME *name,
postfix,k); postfix,k);
} }
k++; k++;
#ifndef OPENSSL_NO_POSIX_IO
{
struct stat st;
if (stat(b->data,&st) < 0) if (stat(b->data,&st) < 0)
break; break;
}
#endif
/* found one. */ /* found one. */
if (type == X509_LU_X509) if (type == X509_LU_X509)
{ {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册