Hello,
When compiled with Visual C++ 6.0, the RAND_load_file function doesn't read
the file. It appears that the VC library fopen function is "uptight" about
the mode and refuses to open a file if called with fopen(file,"br"), but
works fine with fopen(file,"rb"). I don't know if this behavior is microsoft
specific or if other compilers are just lax about it.
How do problem fixes get included in the project?
Best regards,
Youri
P.S. Here is a possible fix of for the RAND_load_file function in the
"crypto/rand/randfile.c" file (or maybe we can just always use "rb" as the
mode):
int RAND_load_file(file,bytes)
char *file;
long bytes;
{
MS_STATIC unsigned char buf[BUFSIZE];
struct stat sb;
int i,ret=0,n;
FILE *in;
if (file == NULL) return(0);
i=stat(file,&sb);
/* If the state fails, put some crap in anyway */
RAND_seed((unsigned char *)&sb,sizeof(sb));
ret+=sizeof(sb);
if (i < 0) return(0);
if (bytes <= 0) return(ret);
#ifndef _MSC_VER
in=fopen(file,"br");
#else
in=fopen(file,"rb");
#endif
if (in == NULL) goto err;
for (;;)
{
n=(bytes < BUFSIZE)?(int)bytes:BUFSIZE;
i=fread(buf,1,n,in);
if (i <= 0) break;
/* even if n != i, use the full array */
RAND_seed(buf,n);
ret+=i;
bytes-=n;
if (bytes <= 0) break;
}
fclose(in);
memset(buf,0,BUFSIZE);
err:
return(ret);
}
______________________________________________________________________
OpenSSL Project http://www.openssl.org
Development Mailing List [EMAIL PROTECTED]
Automated List Manager [EMAIL PROTECTED]