From: Jani Taskinen Date: Sun, 31 Aug 2008 00:21:19 +0000 (+0000) Subject: [DOC]- Fixed bug #45956 (parse_ini_file() does not return false with syntax errors... X-Git-Tag: php-5.2.7RC1~77 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=69378b449cd810b410bfbf93d7285a331814306f;p=php [DOC]- Fixed bug #45956 (parse_ini_file() does not return false with syntax errors in parsed file) [DOC] note: change will be in since 5.2.7 --- diff --git a/NEWS b/NEWS index 5798e3e2a5..be0c340b80 100644 --- a/NEWS +++ b/NEWS @@ -19,6 +19,8 @@ PHP NEWS - Fixed a crash on invalid method in ReflectionParameter constructor. (Christian Seiler) +- Fixed bug #45956 (parse_ini_file() does not return false with syntax errors + in parsed file). (Jani) - Fixed bug #45862 (get_class_vars is inconsistent with 'protected' and 'private' variables). (ilewis at uk dot ibm dot com, Felipe) - Fixed bug #45805 (Crash on throwing exception from error handler). (Dmitry) diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c index 668d7cbc4b..50729fb909 100644 --- a/ext/standard/basic_functions.c +++ b/ext/standard/basic_functions.c @@ -6305,7 +6305,11 @@ PHP_FUNCTION(parse_ini_file) Z_TYPE(fh) = ZEND_HANDLE_FILENAME; array_init(return_value); - zend_parse_ini_file(&fh, 0, ini_parser_cb, return_value); + if (zend_parse_ini_file(&fh, 0, ini_parser_cb, return_value) == FAILURE) { + zend_hash_destroy(Z_ARRVAL_P(return_value)); + efree(Z_ARRVAL_P(return_value)); + RETURN_FALSE; + } } /* }}} */ diff --git a/ext/standard/tests/file/parse_ini_file_error.phpt b/ext/standard/tests/file/parse_ini_file_error.phpt index 65a6ac1d8a..599ae191a7 100644 --- a/ext/standard/tests/file/parse_ini_file_error.phpt +++ b/ext/standard/tests/file/parse_ini_file_error.phpt @@ -47,6 +47,5 @@ NULL -- Testing parse_ini_file() function with a non-existent file -- Warning: parse_ini_file(%s): failed to open stream: No such file or directory in %s on line %d -array(0) { -} +bool(false) Done diff --git a/ext/standard/tests/general_functions/parse_ini_file.phpt b/ext/standard/tests/general_functions/parse_ini_file.phpt index 399a224db9..156ccb0a9d 100644 --- a/ext/standard/tests/general_functions/parse_ini_file.phpt +++ b/ext/standard/tests/general_functions/parse_ini_file.phpt @@ -102,12 +102,10 @@ Warning: Wrong parameter count for parse_ini_file() in %s on line %d NULL Warning: parse_ini_file(%sparse_ini_file.dat): failed to open stream: No such file or directory in %s on line %d -array(0) { -} +bool(false) Warning: parse_ini_file(%sparse_ini_file.dat): failed to open stream: No such file or directory in %s on line %d -array(0) { -} +bool(false) array(1) { ["test"]=> string(0) "" @@ -115,17 +113,11 @@ array(1) { Warning: Error parsing %sparse_ini_file.dat on line 2 in %s on line %d -array(1) { - ["test"]=> - string(0) "" -} +bool(false) Warning: Error parsing %sparse_ini_file.dat on line 2 in %s on line %d -array(1) { - ["test"]=> - string(4) "test" -} +bool(false) array(1) { ["test"]=> string(8) "new diff --git a/tests/security/open_basedir_parse_ini_file.phpt b/tests/security/open_basedir_parse_ini_file.phpt index dadddac981..e2f9046352 100644 --- a/tests/security/open_basedir_parse_ini_file.phpt +++ b/tests/security/open_basedir_parse_ini_file.phpt @@ -34,41 +34,34 @@ bool(true) Warning: parse_ini_file(): open_basedir restriction in effect. File(../bad) is not within the allowed path(s): (.) in %s on line %d Warning: parse_ini_file(../bad): failed to open stream: Operation not permitted in %s on line %d -array(0) { -} +bool(false) Warning: parse_ini_file(): open_basedir restriction in effect. File(../bad/bad.txt) is not within the allowed path(s): (.) in %s on line %d Warning: parse_ini_file(../bad/bad.txt): failed to open stream: Operation not permitted in %s on line %d -array(0) { -} +bool(false) Warning: parse_ini_file(..): failed to open stream: Operation not permitted in %s on line %d -array(0) { -} +bool(false) Warning: parse_ini_file(): open_basedir restriction in effect. File(../) is not within the allowed path(s): (.) in %s on line %d Warning: parse_ini_file(../): failed to open stream: Operation not permitted in %s on line %d -array(0) { -} +bool(false) Warning: parse_ini_file(): open_basedir restriction in effect. File(../bad/.) is not within the allowed path(s): (.) in %s on line %d Warning: parse_ini_file(../bad/.): failed to open stream: Operation not permitted in %s on line %d -array(0) { -} +bool(false) Warning: parse_ini_file(): open_basedir restriction in effect. File(../bad/./bad.txt) is not within the allowed path(s): (.) in %s on line %d Warning: parse_ini_file(../bad/./bad.txt): failed to open stream: Operation not permitted in %s on line %d -array(0) { -} +bool(false) Warning: parse_ini_file(): open_basedir restriction in effect. File(./../.) is not within the allowed path(s): (.) in %s on line %d Warning: parse_ini_file(./../.): failed to open stream: Operation not permitted in %s on line %d -array(0) { -} +bool(false) *** Finished testing open_basedir configuration [parse_ini_file] ***