From: Richard Levitte Date: Mon, 6 Sep 2004 14:19:59 +0000 (+0000) Subject: Replace the bogus checks of n with proper uses of feof(), ferror() and X-Git-Tag: OpenSSL_0_9_7e~22 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=aef8807e76d0998d73109a9ccc3171c32aed7e35;p=oweals%2Fopenssl.git Replace the bogus checks of n with proper uses of feof(), ferror() and clearerr(). --- diff --git a/fips/fips.c b/fips/fips.c index 37a8d15f38..3c3d91dce5 100644 --- a/fips/fips.c +++ b/fips/fips.c @@ -134,17 +134,18 @@ static int FIPS_check_exe(const char *path) return 0; } HMAC_Init(&hmac,key,strlen(key),EVP_sha1()); - do + while(!feof(f)) { n=fread(buf,1,sizeof buf,f); - if(n < 0) + if(ferror(f)) { + clearerr(f); fclose(f); FIPSerr(FIPS_F_FIPS_CHECK_EXE,FIPS_R_CANNOT_READ_EXE); return 0; } - HMAC_Update(&hmac,buf,n); - } while(n > 0); + if (n) HMAC_Update(&hmac,buf,n); + } fclose(f); HMAC_Final(&hmac,mdbuf,&n); BIO_snprintf(p2,sizeof p2,"%s.sha1",path);