summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIlia Alshanetsky <iliaa@php.net>2007-02-15 00:05:42 +0000
committerIlia Alshanetsky <iliaa@php.net>2007-02-15 00:05:42 +0000
commitf8958c466db4fd7358fa8c68e306ee67bb1d877b (patch)
tree9b01f70145d0b6f1948dd4e11e6907d24bbf64cc
parente254f976fbf71473107664d874afd6baf30165a5 (diff)
downloadphp-git-f8958c466db4fd7358fa8c68e306ee67bb1d877b.tar.gz
Fixed a possible memory corruption inside mime_content_type() on a
non-existent file.
-rw-r--r--ext/mime_magic/mime_magic.c36
1 files changed, 22 insertions, 14 deletions
diff --git a/ext/mime_magic/mime_magic.c b/ext/mime_magic/mime_magic.c
index b105d7b3f1..cb7be9950b 100644
--- a/ext/mime_magic/mime_magic.c
+++ b/ext/mime_magic/mime_magic.c
@@ -1156,21 +1156,29 @@ static int fsmagic(zval *what TSRMLS_DC)
php_stream_statbuf stat_ssb;
switch (Z_TYPE_P(what)) {
- case IS_STRING:
- if(!php_stream_stat_path(Z_STRVAL_P(what), &stat_ssb)) {
- return MIME_MAGIC_OK;
- }
- break;
- case IS_RESOURCE:
- {
- php_stream *stream;
-
- php_stream_from_zval_no_verify(stream, &what);
- if(!php_stream_stat(stream, &stat_ssb)) {
- return MIME_MAGIC_OK;
+ case IS_STRING:
+ if (php_stream_stat_path_ex(Z_STRVAL_P(what), PHP_STREAM_URL_STAT_QUIET, &stat_ssb, NULL)) {
+ if (MIME_MAGIC_G(debug)) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Non-statable file path (%s)", Z_STRVAL_P(what));
+ }
+ return MIME_MAGIC_ERROR;
}
- }
- break;
+ break;
+ case IS_RESOURCE:
+ {
+ php_stream *stream;
+
+ php_stream_from_zval_no_verify(stream, &what);
+ if (php_stream_stat(stream, &stat_ssb)) {
+ if (MIME_MAGIC_G(debug)) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Non-statable file path (%s)", Z_STRVAL_P(what));
+ }
+ return MIME_MAGIC_ERROR;
+ }
+ }
+ break;
+ default:
+ return MIME_MAGIC_OK;
}
switch (stat_ssb.sb.st_mode & S_IFMT) {