felipe                                   Fri, 11 Nov 2011 21:39:11 +0000

Revision: http://svn.php.net/viewvc?view=revision&revision=319075

Log:
- Fixed bug #60261 (phar dos null pointer)

Bug: https://bugs.php.net/60261 (Open) phar dos null pointer
      
Changed paths:
    U   php/php-src/branches/PHP_5_3/NEWS
    A   php/php-src/branches/PHP_5_3/ext/phar/tests/bug60261.phpt
    U   php/php-src/branches/PHP_5_3/ext/spl/spl_directory.c
    A   php/php-src/branches/PHP_5_4/ext/phar/tests/bug60261.phpt
    U   php/php-src/branches/PHP_5_4/ext/spl/spl_directory.c
    A   php/php-src/trunk/ext/phar/tests/bug60261.phpt
    U   php/php-src/trunk/ext/spl/spl_directory.c

Modified: php/php-src/branches/PHP_5_3/NEWS
===================================================================
--- php/php-src/branches/PHP_5_3/NEWS   2011-11-11 21:18:37 UTC (rev 319074)
+++ php/php-src/branches/PHP_5_3/NEWS   2011-11-11 21:39:11 UTC (rev 319075)
@@ -16,6 +16,9 @@
 - Oracle Database extension (OCI8):
   . Fixed bug #59985 (show normal warning text for OCI_NO_DATA)
     (Chris Jones)
+
+- Phar:
+  . Fixed bug #60261 (phar dos null pointer). (Felipe)

 03 Nov 2011, PHP 5.3.9RC1


Added: php/php-src/branches/PHP_5_3/ext/phar/tests/bug60261.phpt
===================================================================
--- php/php-src/branches/PHP_5_3/ext/phar/tests/bug60261.phpt                   
        (rev 0)
+++ php/php-src/branches/PHP_5_3/ext/phar/tests/bug60261.phpt   2011-11-11 
21:39:11 UTC (rev 319075)
@@ -0,0 +1,19 @@
+--TEST--
+Bug #60261 (phar dos null pointer)
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--FILE--
+<?php
+
+$nx = new Phar();
+try {
+       $nx->getLinkTarget();
+} catch (Exception $e) {
+       echo $e->getMessage(), "\n";
+}
+
+?>
+--EXPECTF--
+
+Warning: Phar::__construct() expects at least 1 parameter, 0 given in %s on 
line %d
+SplFileInfo::getLinkTarget(): Empty filename

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-11-11 
21:18:37 UTC (rev 319074)
+++ php/php-src/branches/PHP_5_3/ext/spl/spl_directory.c        2011-11-11 
21:39:11 UTC (rev 319075)
@@ -1215,7 +1215,10 @@
        zend_replace_error_handling(EH_THROW, spl_ce_RuntimeException, 
&error_handling TSRMLS_CC);

 #if defined(PHP_WIN32) || HAVE_SYMLINK
-       if (!IS_ABSOLUTE_PATH(intern->file_name, intern->file_name_len)) {
+       if (intern->file_name == NULL) {
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Empty filename");
+               RETURN_FALSE;
+       } else if (!IS_ABSOLUTE_PATH(intern->file_name, intern->file_name_len)) 
{
                char expanded_path[MAXPATHLEN];

                /* TODO: Fix expand_filepath to do not resolve links but only 
expand the path

Added: php/php-src/branches/PHP_5_4/ext/phar/tests/bug60261.phpt
===================================================================
--- php/php-src/branches/PHP_5_4/ext/phar/tests/bug60261.phpt                   
        (rev 0)
+++ php/php-src/branches/PHP_5_4/ext/phar/tests/bug60261.phpt   2011-11-11 
21:39:11 UTC (rev 319075)
@@ -0,0 +1,19 @@
+--TEST--
+Bug #60261 (phar dos null pointer)
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--FILE--
+<?php
+
+$nx = new Phar();
+try {
+       $nx->getLinkTarget();
+} catch (Exception $e) {
+       echo $e->getMessage(), "\n";
+}
+
+?>
+--EXPECTF--
+
+Warning: Phar::__construct() expects at least 1 parameter, 0 given in %s on 
line %d
+SplFileInfo::getLinkTarget(): Empty filename

Modified: php/php-src/branches/PHP_5_4/ext/spl/spl_directory.c
===================================================================
--- php/php-src/branches/PHP_5_4/ext/spl/spl_directory.c        2011-11-11 
21:18:37 UTC (rev 319074)
+++ php/php-src/branches/PHP_5_4/ext/spl/spl_directory.c        2011-11-11 
21:39:11 UTC (rev 319075)
@@ -1230,7 +1230,10 @@
        zend_replace_error_handling(EH_THROW, spl_ce_RuntimeException, 
&error_handling TSRMLS_CC);

 #if defined(PHP_WIN32) || HAVE_SYMLINK
-       if (!IS_ABSOLUTE_PATH(intern->file_name, intern->file_name_len)) {
+       if (intern->file_name == NULL) {
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Empty filename");
+               RETURN_FALSE;
+       } else if (!IS_ABSOLUTE_PATH(intern->file_name, intern->file_name_len)) 
{
                char expanded_path[MAXPATHLEN];
                if (!expand_filepath_with_mode(intern->file_name, 
expanded_path, NULL, 0, CWD_EXPAND  TSRMLS_CC)) {
                        php_error_docref(NULL TSRMLS_CC, E_WARNING, "No such 
file or directory");

Added: php/php-src/trunk/ext/phar/tests/bug60261.phpt
===================================================================
--- php/php-src/trunk/ext/phar/tests/bug60261.phpt                              
(rev 0)
+++ php/php-src/trunk/ext/phar/tests/bug60261.phpt      2011-11-11 21:39:11 UTC 
(rev 319075)
@@ -0,0 +1,19 @@
+--TEST--
+Bug #60261 (phar dos null pointer)
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--FILE--
+<?php
+
+$nx = new Phar();
+try {
+       $nx->getLinkTarget();
+} catch (Exception $e) {
+       echo $e->getMessage(), "\n";
+}
+
+?>
+--EXPECTF--
+
+Warning: Phar::__construct() expects at least 1 parameter, 0 given in %s on 
line %d
+SplFileInfo::getLinkTarget(): Empty filename

Modified: php/php-src/trunk/ext/spl/spl_directory.c
===================================================================
--- php/php-src/trunk/ext/spl/spl_directory.c   2011-11-11 21:18:37 UTC (rev 
319074)
+++ php/php-src/trunk/ext/spl/spl_directory.c   2011-11-11 21:39:11 UTC (rev 
319075)
@@ -1230,7 +1230,10 @@
        zend_replace_error_handling(EH_THROW, spl_ce_RuntimeException, 
&error_handling TSRMLS_CC);

 #if defined(PHP_WIN32) || HAVE_SYMLINK
-       if (!IS_ABSOLUTE_PATH(intern->file_name, intern->file_name_len)) {
+       if (intern->file_name == NULL) {
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Empty filename");
+               RETURN_FALSE;
+       } else if (!IS_ABSOLUTE_PATH(intern->file_name, intern->file_name_len)) 
{
                char expanded_path[MAXPATHLEN];
                if (!expand_filepath_with_mode(intern->file_name, 
expanded_path, NULL, 0, CWD_EXPAND  TSRMLS_CC)) {
                        php_error_docref(NULL TSRMLS_CC, E_WARNING, "No such 
file or directory");

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to