summaryrefslogtreecommitdiff
path: root/ext/standard/md5.c
diff options
context:
space:
mode:
Diffstat (limited to 'ext/standard/md5.c')
-rw-r--r--ext/standard/md5.c29
1 files changed, 9 insertions, 20 deletions
diff --git a/ext/standard/md5.c b/ext/standard/md5.c
index 8c4a695d4..6b6b03b05 100644
--- a/ext/standard/md5.c
+++ b/ext/standard/md5.c
@@ -16,16 +16,14 @@
+----------------------------------------------------------------------+
*/
-/* $Id: md5.c,v 1.35 2004/01/08 08:17:33 andi Exp $ */
+/* $Id: md5.c,v 1.35.2.2 2005/04/16 09:50:13 thetaphi Exp $ */
/*
* md5.c - Copyright 1997 Lachlan Roche
* md5_file() added by Alessandro Astarita <aleast@capri.it>
*/
-#include <stdio.h>
#include "php.h"
-
#include "md5.h"
PHPAPI void make_digest(char *md5str, unsigned char *digest)
@@ -81,40 +79,31 @@ PHP_NAMED_FUNCTION(php_if_md5_file)
unsigned char digest[16];
PHP_MD5_CTX context;
int n;
- FILE *fp;
+ php_stream *stream;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|b", &arg, &arg_len, &raw_output) == FAILURE) {
return;
}
-
- if (PG(safe_mode) && (!php_checkuid(arg, NULL, CHECKUID_CHECK_FILE_AND_DIR))) {
- RETURN_FALSE;
- }
-
- if (php_check_open_basedir(arg TSRMLS_CC)) {
- RETURN_FALSE;
- }
-
- if ((fp = VCWD_FOPEN(arg, "rb")) == NULL) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to open file");
+
+ stream = php_stream_open_wrapper(arg, "rb", REPORT_ERRORS | ENFORCE_SAFE_MODE, NULL);
+ if (!stream) {
RETURN_FALSE;
}
PHP_MD5Init(&context);
- while ((n = fread(buf, 1, sizeof(buf), fp)) > 0) {
+ while ((n = php_stream_read(stream, buf, sizeof(buf))) > 0) {
PHP_MD5Update(&context, buf, n);
}
PHP_MD5Final(digest, &context);
- if (ferror(fp)) {
- fclose(fp);
+ php_stream_close(stream);
+
+ if (n<0) {
RETURN_FALSE;
}
- fclose(fp);
-
if (raw_output) {
RETURN_STRINGL(digest, 16, 1);
} else {