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/bug54291.phpt
trunk/ext/spl/spl_directory.c trunk/ext/spl/tests/bug54291.phpt
| From: | Gustavo André dos Santos Lopes | Date: | Sat, 19 Mar 2011 23:15: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/bug54291.phpt trunk/ext/spl/spl_directory.c trunk/ext/spl/tests/bug54291.phpt |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-64720@lists.php.net to get a copy of this message | ||
cataphract Sat, 19 Mar 2011 23:15:04 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=309456
Log:
- Fixed bug #54291 (Crash iterating DirectoryIterator for dir name starting
with \0).
Bug: http://bugs.php.net/54291 (Assigned) Crash in
spl_filesystem_object_get_path
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/bug54291.phpt
U php/php-src/trunk/ext/spl/spl_directory.c
A php/php-src/trunk/ext/spl/tests/bug54291.phpt
Modified: php/php-src/branches/PHP_5_3/NEWS
===================================================================
--- php/php-src/branches/PHP_5_3/NEWS 2011-03-19 22:41:42 UTC (rev 309455)
+++ php/php-src/branches/PHP_5_3/NEWS 2011-03-19 23:15:04 UTC (rev 309456)
@@ -30,6 +30,10 @@
- Sockets extension:
. Fixed bug #51958 (socket_accept() fails on IPv6 server sockets). (Gustavo)
+- SPL extension:
+ . Fixed bug #54291 (Crash iterating DirectoryIterator for dir name starting
+ with \0). (Gustavo)
+
17 Mar 2011, PHP 5.3.6
- Upgraded bundled Sqlite3 to version 3.7.4. (Ilia)
- Upgraded bundled PCRE to version 8.11. (Ilia)
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-19 22:41:42 UTC (rev 309455)
+++ php/php-src/branches/PHP_5_3/ext/spl/spl_directory.c 2011-03-19 23:15:04 UTC (rev 309456)
@@ -233,8 +233,12 @@
intern->u.dir.index = 0;
if (EG(exception) || intern->u.dir.dirp == NULL) {
- /* throw exception: should've been already happened */
intern->u.dir.entry.d_name[0] = '\0';
+ if (!EG(exception)) {
+ /* open failed w/out notice (turned to exception due to EH_THROW) */
+ zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0
+ TSRMLS_CC, "Failed to open directory \"%s\"", path);
+ }
} else {
do {
spl_filesystem_dir_read(intern TSRMLS_CC);
Added: php/php-src/branches/PHP_5_3/ext/spl/tests/bug54291.phpt
===================================================================
--- php/php-src/branches/PHP_5_3/ext/spl/tests/bug54291.phpt (rev 0)
+++ php/php-src/branches/PHP_5_3/ext/spl/tests/bug54291.phpt 2011-03-19 23:15:04 UTC (rev 309456)
@@ -0,0 +1,13 @@
+--TEST--
+Bug #54291 (Crash iterating DirectoryIterator for dir name starting with \0)
+--FILE--
+<?php
+$dir = new DirectoryIterator("\x00/abc");
+$dir->isFile();
+--EXPECTF--
+Fatal error: Uncaught exception 'UnexpectedValueException' with message 'Failed to
open directory ""' in %s:%d
+Stack trace:
+#0 %s(%d): DirectoryIterator->__construct('?/abc')
+#1 {main}
+ thrown in %s on line %d
+
Modified: php/php-src/trunk/ext/spl/spl_directory.c
===================================================================
--- php/php-src/trunk/ext/spl/spl_directory.c 2011-03-19 22:41:42 UTC (rev 309455)
+++ php/php-src/trunk/ext/spl/spl_directory.c 2011-03-19 23:15:04 UTC (rev 309456)
@@ -232,8 +232,12 @@
intern->u.dir.index = 0;
if (EG(exception) || intern->u.dir.dirp == NULL) {
- /* throw exception: should've been already happened */
intern->u.dir.entry.d_name[0] = '\0';
+ if (!EG(exception)) {
+ /* open failed w/out notice (turned to exception due to EH_THROW) */
+ zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0
+ TSRMLS_CC, "Failed to open directory \"%s\"", path);
+ }
} else {
do {
spl_filesystem_dir_read(intern TSRMLS_CC);
Added: php/php-src/trunk/ext/spl/tests/bug54291.phpt
===================================================================
--- php/php-src/trunk/ext/spl/tests/bug54291.phpt (rev 0)
+++ php/php-src/trunk/ext/spl/tests/bug54291.phpt 2011-03-19 23:15:04 UTC (rev 309456)
@@ -0,0 +1,13 @@
+--TEST--
+Bug #54291 (Crash iterating DirectoryIterator for dir name starting with \0)
+--FILE--
+<?php
+$dir = new DirectoryIterator("\x00/abc");
+$dir->isFile();
+--EXPECTF--
+Fatal error: Uncaught exception 'UnexpectedValueException' with message 'Failed to
open directory ""' in %s:%d
+Stack trace:
+#0 %s(%d): DirectoryIterator->__construct('?/abc')
+#1 {main}
+ thrown in %s on line %d
+