cataphract Fri, 24 Feb 2012 10:01:39 +0000 Revision: http://svn.php.net/viewvc?view=revision&revision=323472
Log: - Fixed bug #61173 (Unable to detect error from finfo constructor). - Tidied up NEWS Bug: https://bugs.php.net/61173 (Feedback) Unable to detect error from finfo constructor Changed paths: U php/php-src/branches/PHP_5_3/NEWS U php/php-src/branches/PHP_5_3/ext/fileinfo/fileinfo.c A php/php-src/branches/PHP_5_3/ext/fileinfo/tests/bug61173.phpt U php/php-src/trunk/ext/fileinfo/fileinfo.c A php/php-src/trunk/ext/fileinfo/tests/bug61173.phpt
Modified: php/php-src/branches/PHP_5_3/NEWS =================================================================== --- php/php-src/branches/PHP_5_3/NEWS 2012-02-24 10:01:32 UTC (rev 323471) +++ php/php-src/branches/PHP_5_3/NEWS 2012-02-24 10:01:39 UTC (rev 323472) @@ -1,22 +1,16 @@ PHP NEWS ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| ?? ??? 2012, PHP 5.3.11 + - Core: . Improved max_input_vars directive to check nested variables (Dmitry). . Fixed bug #61095 (Incorect lexing of 0x00*+<NUM>). (Etienne) - -- Session: - . Fixed bug #60860 (session.save_handler=user without defined function core - dumps). (Felipe) - -- Tidy: - . Fixed bug #54682 (tidy null pointer dereference). (Tony, David Soria Parra) - -- Core: . Fixed bug #61072 (Memory leak when restoring an exception handler). (Nikic, Laruence) - . Fixed bug #61000 (Exceeding max nesting level doesn't delete numerical vars). - (Laruence) + . Fixed bug #61058 (array_fill leaks if start index is PHP_INT_MAX). + (Laruence) + . Fixed bug #61000 (Exceeding max nesting level doesn't delete numerical + vars). (Laruence) . Fix bug #60895 (Possible invalid handler usage in windows random functions). (Pierre) . Fixed bug #60825 (Segfault when running symfony 2 tests). @@ -25,18 +19,12 @@ (rui, Gustavo) . Fixed bug #51860 (Include fails with toplevel symlink to /). (Dmitry) +- Fileinfo + . Fixed bug #61173 (Unable to detect error from finfo constructor). (Gustavo) + - Firebird Database extension (ibase): . Fixed bug #60802 (ibase_trans() gives segfault when passing params). -- Streams: - . Fixed bug #61115 (stream related segfault on fatal error in - php_stream_context_link). (Gustavo) - . Further fix for bug #60455 (stream_get_line misbehaves if EOF is not detected - together with the last read). (Gustavo) - . Fixed bug #60817 (stream_get_line() reads from stream even when there is - already sufficient data buffered). stream_get_line() now behaves more like - fgets(), as is documented. (Gustavo) - - PHP-FPM SAPI: . Fixed bug #60811 (php-fpm compilation problem). (rasmus) @@ -53,10 +41,22 @@ . Fixed bug #60968 (Late static binding doesn't work with ReflectionMethod::invokeArgs()). (Laruence) -- Array: - . Fixed bug #61058 (array_fill leaks if start index is PHP_INT_MAX). - (Laruence) +- Session: + . Fixed bug #60860 (session.save_handler=user without defined function core + dumps). (Felipe) +- Streams: + . Fixed bug #61115 (stream related segfault on fatal error in + php_stream_context_link). (Gustavo) + . Further fix for bug #60455 (stream_get_line misbehaves if EOF is not + detected together with the last read). (Gustavo) + . Fixed bug #60817 (stream_get_line() reads from stream even when there is + already sufficient data buffered). stream_get_line() now behaves more like + fgets(), as is documented. (Gustavo) + +- Tidy: + . Fixed bug #54682 (tidy null pointer dereference). (Tony, David Soria Parra) + - XMLRPC: . Fixed bug #61097 (Memory leak in xmlrpc functions copying zvals). (Nikic) Modified: php/php-src/branches/PHP_5_3/ext/fileinfo/fileinfo.c =================================================================== --- php/php-src/branches/PHP_5_3/ext/fileinfo/fileinfo.c 2012-02-24 10:01:32 UTC (rev 323471) +++ php/php-src/branches/PHP_5_3/ext/fileinfo/fileinfo.c 2012-02-24 10:01:39 UTC (rev 323472) @@ -76,9 +76,9 @@ } \ } -/* {{{ finfo_objects_dtor +/* {{{ finfo_objects_free */ -static void finfo_objects_dtor(void *object, zend_object_handle handle TSRMLS_DC) +static void finfo_objects_free(void *object TSRMLS_DC) { struct finfo_object *intern = (struct finfo_object *) object; @@ -108,7 +108,8 @@ intern->ptr = NULL; - retval.handle = zend_objects_store_put(intern, finfo_objects_dtor, NULL, NULL TSRMLS_CC); + retval.handle = zend_objects_store_put(intern, NULL, + finfo_objects_free, NULL TSRMLS_CC); retval.handlers = (zend_object_handlers *) &finfo_object_handlers; return retval; @@ -276,6 +277,15 @@ } /* }}} */ +#define FILEINFO_DESTROY_OBJECT(object) \ + do { \ + if (object) { \ + zend_object_store_ctor_failed(object TSRMLS_CC); \ + zval_dtor(object); \ + ZVAL_NULL(object); \ + } \ + } while (0) + /* {{{ proto resource finfo_open([int options [, string arg]]) Create a new fileinfo resource. */ PHP_FUNCTION(finfo_open) @@ -288,6 +298,7 @@ char resolved_path[MAXPATHLEN]; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|ls", &options, &file, &file_len) == FAILURE) { + FILEINFO_DESTROY_OBJECT(object); RETURN_FALSE; } @@ -305,9 +316,11 @@ 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; @@ -317,6 +330,7 @@ #else if (php_check_open_basedir(file TSRMLS_CC)) { #endif + FILEINFO_DESTROY_OBJECT(object); RETURN_FALSE; } } @@ -329,21 +343,23 @@ if (finfo->magic == NULL) { efree(finfo); php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid mode '%ld'.", options); - RETURN_FALSE; + FILEINFO_DESTROY_OBJECT(object); + RETURN_FALSE; } if (magic_load(finfo->magic, file) == -1) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to load magic database at '%s'.", file); magic_close(finfo->magic); efree(finfo); + FILEINFO_DESTROY_OBJECT(object); RETURN_FALSE; - } + } if (object) { FILEINFO_REGISTER_OBJECT(object, finfo); } else { ZEND_REGISTER_RESOURCE(return_value, finfo, le_fileinfo); - } + } } /* }}} */ Added: php/php-src/branches/PHP_5_3/ext/fileinfo/tests/bug61173.phpt =================================================================== --- php/php-src/branches/PHP_5_3/ext/fileinfo/tests/bug61173.phpt (rev 0) +++ php/php-src/branches/PHP_5_3/ext/fileinfo/tests/bug61173.phpt 2012-02-24 10:01:39 UTC (rev 323472) @@ -0,0 +1,14 @@ +--TEST-- +Bug #61173: Unable to detect error from finfo constructor +--SKIPIF-- +<?php +if (!class_exists('finfo')) + die('skip no fileinfo extension'); +--FILE-- +<?php + +$finfo = new finfo(1, '', false); +var_dump($finfo); +--EXPECTF-- +Warning: finfo::finfo() expects at most 2 parameters, 3 given in %s on line %d +NULL Property changes on: php/php-src/branches/PHP_5_3/ext/fileinfo/tests/bug61173.phpt ___________________________________________________________________ Added: svn:keywords + Id Rev Revision Added: svn:eol-style + native Modified: php/php-src/trunk/ext/fileinfo/fileinfo.c =================================================================== --- php/php-src/trunk/ext/fileinfo/fileinfo.c 2012-02-24 10:01:32 UTC (rev 323471) +++ php/php-src/trunk/ext/fileinfo/fileinfo.c 2012-02-24 10:01:39 UTC (rev 323472) @@ -76,9 +76,9 @@ } \ } -/* {{{ finfo_objects_dtor +/* {{{ finfo_objects_free */ -static void finfo_objects_dtor(void *object, zend_object_handle handle TSRMLS_DC) +static void finfo_objects_free(void *object TSRMLS_DC) { struct finfo_object *intern = (struct finfo_object *) object; @@ -107,7 +107,8 @@ intern->ptr = NULL; - retval.handle = zend_objects_store_put(intern, finfo_objects_dtor, NULL, NULL TSRMLS_CC); + retval.handle = zend_objects_store_put(intern, NULL, + finfo_objects_free, NULL TSRMLS_CC); retval.handlers = (zend_object_handlers *) &finfo_object_handlers; return retval; @@ -275,6 +276,15 @@ } /* }}} */ +#define FILEINFO_DESTROY_OBJECT(object) \ + do { \ + if (object) { \ + zend_object_store_ctor_failed(object TSRMLS_CC); \ + zval_dtor(object); \ + ZVAL_NULL(object); \ + } \ + } while (0) + /* {{{ proto resource finfo_open([int options [, string arg]]) Create a new fileinfo resource. */ PHP_FUNCTION(finfo_open) @@ -287,12 +297,13 @@ char resolved_path[MAXPATHLEN]; 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); @@ -309,9 +320,11 @@ #else if (php_check_open_basedir(file TSRMLS_CC)) { #endif + 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; @@ -325,21 +338,23 @@ if (finfo->magic == NULL) { efree(finfo); php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid mode '%ld'.", options); - RETURN_FALSE; + FILEINFO_DESTROY_OBJECT(object); + RETURN_FALSE; } if (magic_load(finfo->magic, file) == -1) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to load magic database at '%s'.", file); magic_close(finfo->magic); efree(finfo); + FILEINFO_DESTROY_OBJECT(object); RETURN_FALSE; - } + } if (object) { FILEINFO_REGISTER_OBJECT(object, finfo); } else { ZEND_REGISTER_RESOURCE(return_value, finfo, le_fileinfo); - } + } } /* }}} */ Added: php/php-src/trunk/ext/fileinfo/tests/bug61173.phpt =================================================================== --- php/php-src/trunk/ext/fileinfo/tests/bug61173.phpt (rev 0) +++ php/php-src/trunk/ext/fileinfo/tests/bug61173.phpt 2012-02-24 10:01:39 UTC (rev 323472) @@ -0,0 +1,14 @@ +--TEST-- +Bug #61173: Unable to detect error from finfo constructor +--SKIPIF-- +<?php +if (!class_exists('finfo')) + die('skip no fileinfo extension'); +--FILE-- +<?php + +$finfo = new finfo(1, '', false); +var_dump($finfo); +--EXPECTF-- +Warning: finfo::finfo() expects at most 2 parameters, 3 given in %s on line %d +NULL Property changes on: php/php-src/trunk/ext/fileinfo/tests/bug61173.phpt ___________________________________________________________________ Added: svn:keywords + Id Rev Revision Added: svn:eol-style + native
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php