diff options
| author | Simon L. B. Nielsen <simon@FreeBSD.org> | 2008-09-21 14:56:30 +0000 | 
|---|---|---|
| committer | Simon L. B. Nielsen <simon@FreeBSD.org> | 2008-09-21 14:56:30 +0000 | 
| commit | bb1499d2aac1d25a95b8573ff425751f06f159e1 (patch) | |
| tree | a136b5b2317abe8eb83b021afe5e088230fd67e2 /crypto/rand/randfile.c | |
| parent | ee266f1253f9cc49430572463d26f72910dfb49e (diff) | |
Diffstat (limited to 'crypto/rand/randfile.c')
| -rw-r--r-- | crypto/rand/randfile.c | 8 | 
1 files changed, 5 insertions, 3 deletions
| diff --git a/crypto/rand/randfile.c b/crypto/rand/randfile.c index d69bdf8b8a040..6c0ec9a41cdfc 100644 --- a/crypto/rand/randfile.c +++ b/crypto/rand/randfile.c @@ -102,10 +102,8 @@ int RAND_load_file(const char *file, long bytes)  	if (file == NULL) return(0); -	i=stat(file,&sb); -	/* If the state fails, put some crap in anyway */ +	if (stat(file,&sb) < 0) return(0);  	RAND_add(&sb,sizeof(sb),0.0); -	if (i < 0) return(0);  	if (bytes == 0) return(ret);  	in=fopen(file,"rb"); @@ -128,8 +126,12 @@ int RAND_load_file(const char *file, long bytes)  			n = BUFSIZE;  		i=fread(buf,1,n,in);  		if (i <= 0) break; +#ifdef PURIFY +		RAND_add(buf,i,(double)i); +#else  		/* even if n != i, use the full array */  		RAND_add(buf,n,(double)i); +#endif  		ret+=i;  		if (bytes > 0)  			{ | 
