com php-src: fix an always true condition and improve the error check: ext/standard/md5.c

From: Date: Fri, 19 Sep 2014 08:33:01 +0000
Subject: com php-src: fix an always true condition and improve the error check: ext/standard/md5.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-81758@lists.php.net to get a copy of this message
Commit: 953386edfd4f0d59c3a8ead1ea90b20e49796ea3 Author: Anatol Belski <ab@php.net> Fri, 19 Sep 2014 10:33:01 +0200 Parents: bae92295fd7bf54b8b3e8440c1ce705e6e5e2119 Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=953386edfd4f0d59c3a8ead1ea90b20e49796ea3 Log: fix an always true condition and improve the error check Changed paths: M ext/standard/md5.c Diff: diff --git a/ext/standard/md5.c b/ext/standard/md5.c index 4938bab..7d24dfe 100644 --- a/ext/standard/md5.c +++ b/ext/standard/md5.c @@ -99,14 +99,18 @@ PHP_NAMED_FUNCTION(php_if_md5_file) PHP_MD5Update(&context, buf, n); } - PHP_MD5Final(digest, &context); - - php_stream_close(stream); + /* XXX this probably can be improved with some number of retries */ + if (!php_stream_eof(stream)) { + php_stream_close(stream); + PHP_MD5Final(digest, &context); - if (n<0) { RETURN_FALSE; } + php_stream_close(stream); + + PHP_MD5Final(digest, &context); + if (raw_output) { RETURN_STRINGL(digest, 16); } else { @@ -384,5 +388,5 @@ PHPAPI void PHP_MD5Final(unsigned char *result, PHP_MD5_CTX *ctx) result[14] = ctx->d >> 16; result[15] = ctx->d >> 24; - memset(ctx, 0, sizeof(*ctx)); + ZEND_SECURE_ZERO(ctx, sizeof(*ctx)); }

« previous php.cvs (#81758) next »