diff options
author | Felipe Pena <felipe@php.net> | 2008-08-26 15:06:28 +0000 |
---|---|---|
committer | Felipe Pena <felipe@php.net> | 2008-08-26 15:06:28 +0000 |
commit | 727990f432bdab0ec1e28b710e65f1efc832d110 (patch) | |
tree | f94e3926fdb9f721d9954ec8089c159253318981 | |
parent | b805c7f8b76011e98920ca95a3897d5683e5c704 (diff) | |
download | php-git-727990f432bdab0ec1e28b710e65f1efc832d110.tar.gz |
- MFH: Added check for empty file name
-rw-r--r-- | ext/fileinfo/fileinfo.c | 7 | ||||
-rw-r--r-- | ext/fileinfo/tests/finfo_file_001.phpt | 17 |
2 files changed, 21 insertions, 3 deletions
diff --git a/ext/fileinfo/fileinfo.c b/ext/fileinfo/fileinfo.c index 9ad8ddc156..1e9c49e346 100644 --- a/ext/fileinfo/fileinfo.c +++ b/ext/fileinfo/fileinfo.c @@ -448,11 +448,12 @@ static void _php_finfo_get_type(INTERNAL_FUNCTION_PARAMETERS, int mode) /* {{{ * } } else { /* local file */ char resolved_path[MAXPATHLEN]; - if (!VCWD_REALPATH(buffer, resolved_path)) { + + if (buffer_len && VCWD_REALPATH(buffer, resolved_path)) { + ret_val = (char *) magic_file(finfo->magic, buffer); + } else { RETURN_FALSE; } - - ret_val = (char *) magic_file(finfo->magic, buffer); goto common; } } else { /* buffer */ diff --git a/ext/fileinfo/tests/finfo_file_001.phpt b/ext/fileinfo/tests/finfo_file_001.phpt new file mode 100644 index 0000000000..6ef8e27863 --- /dev/null +++ b/ext/fileinfo/tests/finfo_file_001.phpt @@ -0,0 +1,17 @@ +--TEST-- +finfo_file(): Testing file names +--FILE-- +<?php + +$fp = finfo_open(); +var_dump(finfo_file($fp, '')); +var_dump(finfo_file($fp, NULL)); +var_dump(finfo_file($fp, '.')); +var_dump(finfo_file($fp, '&')); + +?> +--EXPECT-- +bool(false) +bool(false) +string(9) "directory" +bool(false) |