From aef8807e76d0998d73109a9ccc3171c32aed7e35 Mon Sep 17 00:00:00 2001 From: Richard Levitte Date: Mon, 6 Sep 2004 14:19:59 +0000 Subject: [PATCH] Replace the bogus checks of n with proper uses of feof(), ferror() and clearerr(). --- fips/fips.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) 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); -- 2.25.1