cellog          Tue Feb  3 18:29:46 2009 UTC

  Modified files:              
    /php-src/ext/phar   stream.c 
    /php-src/ext/phar/tests     bug47085.phpt 
  Log:
  MFB: fix bug #47085:rename() returns true even if the file in PHAR does not 
exist
  
http://cvs.php.net/viewvc.cgi/php-src/ext/phar/stream.c?r1=1.39&r2=1.40&diff_format=u
Index: php-src/ext/phar/stream.c
diff -u php-src/ext/phar/stream.c:1.39 php-src/ext/phar/stream.c:1.40
--- php-src/ext/phar/stream.c:1.39      Wed Dec 31 11:12:35 2008
+++ php-src/ext/phar/stream.c   Tue Feb  3 18:29:46 2009
@@ -888,6 +888,14 @@
                is_dir = entry->is_dir;
        } else {
                is_dir = zend_hash_exists(&(phar->virtual_dirs), 
resource_from->path+1, strlen(resource_from->path)-1);
+               if (!is_dir) {
+                       /* file does not exist */
+                       php_url_free(resource_from);
+                       php_url_free(resource_to);
+                       php_error_docref(NULL TSRMLS_CC, E_WARNING, "phar 
error: cannot rename \"%s\" to \"%s\" from extracted phar archive, source does 
not exist", url_from, url_to);
+                       return 0;
+
+               }
        }
 
        /* Rename directory. Update all nested paths */
http://cvs.php.net/viewvc.cgi/php-src/ext/phar/tests/bug47085.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/phar/tests/bug47085.phpt
diff -u /dev/null php-src/ext/phar/tests/bug47085.phpt:1.2
--- /dev/null   Tue Feb  3 18:29:46 2009
+++ php-src/ext/phar/tests/bug47085.phpt        Tue Feb  3 18:29:46 2009
@@ -0,0 +1,24 @@
+--TEST--
+Phar: PHP bug #47085: "rename() returns true even if the file in PHAR does not 
exist"
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.require_hash=0
+phar.readonly=0
+--FILE--
+<?php
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar';
+
+$phar = new Phar($fname, 0, 'a.phar');
+$phar['x'] = 'hi';
+unset($phar);
+rename("phar://a.phar/x", "phar://a.phar/y");
+var_dump(rename("phar://a.phar/x", "phar://a.phar/y"));
+?>
+===DONE===
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . 
'.phar');?>
+--EXPECTF--
+Warning: rename(): phar error: cannot rename "phar://a.phar/x" to 
"phar://a.phar/y" from extracted phar archive, source does not exist in 
%sbug47085.php on line %d
+bool(false)
+===DONE===
\ No newline at end of file



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

Reply via email to