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 {
result[14] = ctx->d >> 16;
result[15] = ctx->d >> 24;
- memset(ctx, 0, sizeof(*ctx));
+ ZEND_SECURE_ZERO(ctx, sizeof(*ctx));
}