summaryrefslogtreecommitdiff
path: root/ext/fileinfo/fileinfo.c
diff options
context:
space:
mode:
Diffstat (limited to 'ext/fileinfo/fileinfo.c')
-rw-r--r--ext/fileinfo/fileinfo.c23
1 files changed, 9 insertions, 14 deletions
diff --git a/ext/fileinfo/fileinfo.c b/ext/fileinfo/fileinfo.c
index caab03bac3..29f9bebbc8 100644
--- a/ext/fileinfo/fileinfo.c
+++ b/ext/fileinfo/fileinfo.c
@@ -98,13 +98,12 @@ PHP_FILEINFO_API zend_object_value finfo_objects_new(zend_class_entry *class_typ
{
zend_object_value retval;
struct finfo_object *intern;
- zval *tmp;
intern = emalloc(sizeof(struct finfo_object));
memset(intern, 0, sizeof(struct finfo_object));
zend_object_std_init(&intern->zo, class_type TSRMLS_CC);
- zend_hash_copy(intern->zo.properties, &class_type->default_properties, (copy_ctor_func_t) zval_add_ref,(void *) &tmp, sizeof(zval *));
+ object_properties_init(&intern->zo, class_type);
intern->ptr = NULL;
@@ -297,14 +296,14 @@ PHP_FUNCTION(finfo_open)
FILEINFO_DECLARE_INIT_OBJECT(object)
char resolved_path[MAXPATHLEN];
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|ls", &options, &file, &file_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|lp", &options, &file, &file_len) == FAILURE) {
FILEINFO_DESTROY_OBJECT(object);
RETURN_FALSE;
}
-
+
if (object) {
struct finfo_object *finfo_obj = (struct finfo_object*)zend_object_store_get_object(object TSRMLS_CC);
-
+
if (finfo_obj->ptr) {
magic_close(finfo_obj->ptr->magic);
efree(finfo_obj->ptr);
@@ -315,15 +314,6 @@ PHP_FUNCTION(finfo_open)
if (file_len == 0) {
file = NULL;
} else if (file && *file) { /* user specified file, perform open_basedir checks */
- if (strlen(file) != file_len) {
- FILEINFO_DESTROY_OBJECT(object);
- RETURN_FALSE;
- }
- if (!VCWD_REALPATH(file, resolved_path)) {
- FILEINFO_DESTROY_OBJECT(object);
- RETURN_FALSE;
- }
- file = resolved_path;
#if PHP_API_VERSION < 20100412
if ((PG(safe_mode) && (!php_checkuid(file, NULL, CHECKUID_CHECK_FILE_AND_DIR))) || php_check_open_basedir(file TSRMLS_CC)) {
@@ -333,6 +323,11 @@ PHP_FUNCTION(finfo_open)
FILEINFO_DESTROY_OBJECT(object);
RETURN_FALSE;
}
+ if (!expand_filepath_with_mode(file, resolved_path, NULL, 0, CWD_EXPAND TSRMLS_CC)) {
+ FILEINFO_DESTROY_OBJECT(object);
+ RETURN_FALSE;
+ }
+ file = resolved_path;
}
finfo = emalloc(sizeof(struct php_fileinfo));