svn: /php/php-src/ branches/PHP_5_3/NEWS branches/PHP_5_3/ext/spl/spl_directory.c branches/PHP_5_3/ext/spl/tests/bug54292.phpt
trunk/ext/spl/spl_directory.c trunk/ext/spl/tests/bug54292.phpt
| From: | Felipe Pena | Date: | Wed, 23 Mar 2011 22:46:04 +0000 |
| Subject: | svn: /php/php-src/ branches/PHP_5_3/NEWS branches/PHP_5_3/ext/spl/spl_directory.c branches/PHP_5_3/ext/spl/tests/bug54292.phpt trunk/ext/spl/spl_directory.c trunk/ext/spl/tests/bug54292.phpt |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-64749@lists.php.net to get a copy of this message | ||
felipe Wed, 23 Mar 2011 22:46:04 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=309611
Log:
- Fixed bug #54292 (Wrong parameter causes crash in SplFileObject::__construct())
Bug: http://bugs.php.net/54292 (error getting bug
information)
Changed paths:
U php/php-src/branches/PHP_5_3/NEWS
U php/php-src/branches/PHP_5_3/ext/spl/spl_directory.c
A php/php-src/branches/PHP_5_3/ext/spl/tests/bug54292.phpt
U php/php-src/trunk/ext/spl/spl_directory.c
A php/php-src/trunk/ext/spl/tests/bug54292.phpt
Modified: php/php-src/branches/PHP_5_3/NEWS
===================================================================
--- php/php-src/branches/PHP_5_3/NEWS 2011-03-23 18:56:47 UTC (rev 309610)
+++ php/php-src/branches/PHP_5_3/NEWS 2011-03-23 22:46:04 UTC (rev 309611)
@@ -43,6 +43,8 @@
. Fixed bug #51958 (socket_accept() fails on IPv6 server sockets). (Gustavo)
- SPL extension:
+ . Fixed bug #54292 (Wrong parameter causes crash in
+ SplFileObject::__construct()). (Felipe)
. Fixed bug #54291 (Crash iterating DirectoryIterator for dir name starting
with \0). (Gustavo)
. Fixed bug #54281 (Crash in non-initialized RecursiveIteratorIterator).
Modified: php/php-src/branches/PHP_5_3/ext/spl/spl_directory.c
===================================================================
--- php/php-src/branches/PHP_5_3/ext/spl/spl_directory.c 2011-03-23 18:56:47 UTC (rev 309610)
+++ php/php-src/branches/PHP_5_3/ext/spl/spl_directory.c 2011-03-23 22:46:04 UTC (rev 309611)
@@ -2209,17 +2209,24 @@
zend_replace_error_handling(EH_THROW, spl_ce_RuntimeException, &error_handling TSRMLS_CC);
- intern->u.file.open_mode = "r";
- intern->u.file.open_mode_len = 1;
+ intern->u.file.open_mode = NULL;
+ intern->u.file.open_mode_len = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|sbr",
&intern->file_name, &intern->file_name_len,
&intern->u.file.open_mode, &intern->u.file.open_mode_len,
- &use_include_path, &intern->u.file.zcontext) == FAILURE) {
+ &use_include_path, &intern->u.file.zcontext) == FAILURE) {
+ intern->u.file.open_mode = NULL;
+ intern->file_name = NULL;
zend_restore_error_handling(&error_handling TSRMLS_CC);
return;
}
+ if (intern->u.file.open_mode == NULL) {
+ intern->u.file.open_mode = "r";
+ intern->u.file.open_mode_len = 1;
+ }
+
if (spl_filesystem_file_open(intern, use_include_path, 0 TSRMLS_CC) == SUCCESS) {
tmp_path_len = strlen(intern->u.file.stream->orig_path);
Added: php/php-src/branches/PHP_5_3/ext/spl/tests/bug54292.phpt
===================================================================
--- php/php-src/branches/PHP_5_3/ext/spl/tests/bug54292.phpt (rev 0)
+++ php/php-src/branches/PHP_5_3/ext/spl/tests/bug54292.phpt 2011-03-23 22:46:04 UTC (rev 309611)
@@ -0,0 +1,14 @@
+--TEST--
+Bug #54292 (Wrong parameter causes crash in SplFileObject::__construct())
+--FILE--
+<?php
+
+try {
+ new SplFileObject('foo', array());
+} catch (Exception $e) {
+ var_dump($e->getMessage());
+}
+
+?>
+--EXPECTF--
+string(74) "SplFileObject::__construct() expects parameter 2 to be string, array given"
Modified: php/php-src/trunk/ext/spl/spl_directory.c
===================================================================
--- php/php-src/trunk/ext/spl/spl_directory.c 2011-03-23 18:56:47 UTC (rev 309610)
+++ php/php-src/trunk/ext/spl/spl_directory.c 2011-03-23 22:46:04 UTC (rev 309611)
@@ -2211,17 +2211,24 @@
zend_replace_error_handling(EH_THROW, spl_ce_RuntimeException, &error_handling TSRMLS_CC);
- intern->u.file.open_mode = "r";
- intern->u.file.open_mode_len = 1;
+ intern->u.file.open_mode = NULL;
+ intern->u.file.open_mode_len = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|sbr",
&intern->file_name, &intern->file_name_len,
&intern->u.file.open_mode, &intern->u.file.open_mode_len,
- &use_include_path, &intern->u.file.zcontext) == FAILURE) {
+ &use_include_path, &intern->u.file.zcontext) == FAILURE) {
+ intern->u.file.open_mode = NULL;
+ intern->file_name = NULL;
zend_restore_error_handling(&error_handling TSRMLS_CC);
return;
}
+ if (intern->u.file.open_mode == NULL) {
+ intern->u.file.open_mode = "r";
+ intern->u.file.open_mode_len = 1;
+ }
+
if (spl_filesystem_file_open(intern, use_include_path, 0 TSRMLS_CC) == SUCCESS) {
tmp_path_len = strlen(intern->u.file.stream->orig_path);
Added: php/php-src/trunk/ext/spl/tests/bug54292.phpt
===================================================================
--- php/php-src/trunk/ext/spl/tests/bug54292.phpt (rev 0)
+++ php/php-src/trunk/ext/spl/tests/bug54292.phpt 2011-03-23 22:46:04 UTC (rev 309611)
@@ -0,0 +1,14 @@
+--TEST--
+Bug #54292 (Wrong parameter causes crash in SplFileObject::__construct())
+--FILE--
+<?php
+
+try {
+ new SplFileObject('foo', array());
+} catch (Exception $e) {
+ var_dump($e->getMessage());
+}
+
+?>
+--EXPECTF--
+string(74) "SplFileObject::__construct() expects parameter 2 to be string, array given"