summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
Diffstat (limited to 'ext')
-rw-r--r--ext/standard/md5.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/ext/standard/md5.c b/ext/standard/md5.c
index 4938babf7a..7d24dfeb7a 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));
}