diff options
author | Hannes Magnusson <bjori@php.net> | 2011-02-14 15:32:02 +0000 |
---|---|---|
committer | Hannes Magnusson <bjori@php.net> | 2011-02-14 15:32:02 +0000 |
commit | 7c1a9e37cabec0ae4369ad681e39e3924fab2b5b (patch) | |
tree | 6a62397dcd585147913e63d7983918f1f84e4c6f /ext/fileinfo/fileinfo.c | |
parent | 011143d1bf856a1781074f2e4ed02e30930edc1f (diff) | |
download | php-git-7c1a9e37cabec0ae4369ad681e39e3924fab2b5b.tar.gz |
Bug#54016 (finfo_file() Cannot determine filetype in archives)
Diffstat (limited to 'ext/fileinfo/fileinfo.c')
-rw-r--r-- | ext/fileinfo/fileinfo.c | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/ext/fileinfo/fileinfo.c b/ext/fileinfo/fileinfo.c index b2697260d2..398659b8e3 100644 --- a/ext/fileinfo/fileinfo.c +++ b/ext/fileinfo/fileinfo.c @@ -478,7 +478,7 @@ static void _php_finfo_get_type(INTERNAL_FUNCTION_PARAMETERS, int mode, int mime /* determine if the file is a local file or remote URL */ char *tmp2; php_stream_wrapper *wrap; - struct stat sb; + php_stream_statbuf ssb; if (buffer == NULL || !*buffer) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Empty filename or path"); @@ -486,17 +486,6 @@ static void _php_finfo_get_type(INTERNAL_FUNCTION_PARAMETERS, int mode, int mime goto clean; } - if (php_sys_stat(buffer, &sb) == 0) { - if (sb.st_mode & _S_IFDIR) { - ret_val = mime_directory; - goto common; - } - } else { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "File or path not found '%s'", buffer); - RETVAL_FALSE; - goto clean; - } - wrap = php_stream_locate_url_wrapper(buffer, &tmp2, 0 TSRMLS_CC); if (wrap) { @@ -512,7 +501,14 @@ static void _php_finfo_get_type(INTERNAL_FUNCTION_PARAMETERS, int mode, int mime goto clean; } - ret_val = (char *)magic_stream(magic, stream); + if (php_stream_stat(stream, &ssb) == SUCCESS) { + if (ssb.sb.st_mode & S_IFDIR) { + ret_val = mime_directory; + } else { + ret_val = (char *)magic_stream(magic, stream); + } + } + php_stream_close(stream); } break; |