diff options
| author | Ondřej Surý <ondrej@sury.org> | 2012-01-11 15:43:42 +0100 |
|---|---|---|
| committer | Ondřej Surý <ondrej@sury.org> | 2012-01-11 15:43:42 +0100 |
| commit | 8f1428d29ef91d74b4d272af171675f2971eb15b (patch) | |
| tree | a1f4f4d7dc5bfe8096806dd5c5266634e19fa07a /ext/phar | |
| parent | c6e4182351e0173fe58de141e143aac2eacf5efe (diff) | |
| download | php-upstream/5.3.9.tar.gz | |
Imported Upstream version 5.3.9upstream/5.3.9
Diffstat (limited to 'ext/phar')
32 files changed, 212 insertions, 47 deletions
diff --git a/ext/phar/dirstream.c b/ext/phar/dirstream.c index 4b6fd586f..a1c5b09ab 100644 --- a/ext/phar/dirstream.c +++ b/ext/phar/dirstream.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | phar:// stream wrapper support | +----------------------------------------------------------------------+ - | Copyright (c) 2005-2011 The PHP Group | + | Copyright (c) 2005-2012 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | diff --git a/ext/phar/dirstream.h b/ext/phar/dirstream.h index eed6e6677..b4a05c463 100644 --- a/ext/phar/dirstream.h +++ b/ext/phar/dirstream.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | phar php single-file executable PHP extension | +----------------------------------------------------------------------+ - | Copyright (c) 2006-2011 The PHP Group | + | Copyright (c) 2006-2012 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: dirstream.h 306941 2011-01-01 02:48:19Z felipe $ */ +/* $Id: dirstream.h 321634 2012-01-01 13:15:04Z felipe $ */ BEGIN_EXTERN_C() int phar_wrapper_mkdir(php_stream_wrapper *wrapper, char *url_from, int mode, int options, php_stream_context *context TSRMLS_DC); diff --git a/ext/phar/func_interceptors.c b/ext/phar/func_interceptors.c index 216cb05e3..b2582bc39 100644 --- a/ext/phar/func_interceptors.c +++ b/ext/phar/func_interceptors.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | phar php single-file executable PHP extension | +----------------------------------------------------------------------+ - | Copyright (c) 2005-2011 The PHP Group | + | Copyright (c) 2005-2012 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: func_interceptors.c 306941 2011-01-01 02:48:19Z felipe $ */ +/* $Id: func_interceptors.c 321634 2012-01-01 13:15:04Z felipe $ */ #include "phar_internal.h" diff --git a/ext/phar/func_interceptors.h b/ext/phar/func_interceptors.h index 3f738a9a7..9a8378a8b 100644 --- a/ext/phar/func_interceptors.h +++ b/ext/phar/func_interceptors.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | phar php single-file executable PHP extension | +----------------------------------------------------------------------+ - | Copyright (c) 2006-2011 The PHP Group | + | Copyright (c) 2006-2012 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: func_interceptors.h 306941 2011-01-01 02:48:19Z felipe $ */ +/* $Id: func_interceptors.h 321634 2012-01-01 13:15:04Z felipe $ */ BEGIN_EXTERN_C() void phar_intercept_functions(TSRMLS_D); diff --git a/ext/phar/phar.c b/ext/phar/phar.c index 46a8e34e1..d16576a2d 100644 --- a/ext/phar/phar.c +++ b/ext/phar/phar.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | phar php single-file executable PHP extension | +----------------------------------------------------------------------+ - | Copyright (c) 2005-2011 The PHP Group | + | Copyright (c) 2005-2012 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: phar.c 314419 2011-08-07 11:13:27Z laruence $ */ +/* $Id: phar.c 321634 2012-01-01 13:15:04Z felipe $ */ #define PHAR_MAIN 1 #include "phar_internal.h" @@ -1569,7 +1569,9 @@ static int phar_open_from_fp(php_stream* fp, char *fname, int fname_len, char *a const char zip_magic[] = "PK\x03\x04"; const char gz_magic[] = "\x1f\x8b\x08"; const char bz_magic[] = "BZh"; - char *pos, buffer[1024 + sizeof(token)], test = '\0'; + char *pos, test = '\0'; + const int window_size = 1024; + char buffer[1024 + sizeof(token)]; /* a 1024 byte window + the size of the halt_compiler token (moving window) */ const long readsize = sizeof(buffer) - sizeof(token); const long tokenlen = sizeof(token) - 1; long halt_offset; @@ -1717,7 +1719,7 @@ static int phar_open_from_fp(php_stream* fp, char *fname, int fname_len, char *a } halt_offset += got; - memmove(buffer, buffer + tokenlen, got + 1); + memmove(buffer, buffer + window_size, tokenlen); /* move the memory buffer by the size of the window */ } MAPPHAR_ALLOC_FAIL("internal corruption of phar \"%s\" (__HALT_COMPILER(); not found)") @@ -3103,9 +3105,7 @@ int phar_flush(phar_archive_data *phar, char *user_stub, long len, int convert, /* this will have changed for all files that have either changed compression or been modified */ entry->offset = entry->offset_abs = offset; offset += entry->compressed_filesize; - phar_stream_copy_to_stream(file, newfile, entry->compressed_filesize, &wrote); - - if (entry->compressed_filesize != wrote) { + if (phar_stream_copy_to_stream(file, newfile, entry->compressed_filesize, &wrote) == FAILURE) { if (closeoldfile) { php_stream_close(oldfile); } @@ -3669,7 +3669,7 @@ PHP_MINFO_FUNCTION(phar) /* {{{ */ php_info_print_table_header(2, "Phar: PHP Archive support", "enabled"); php_info_print_table_row(2, "Phar EXT version", PHP_PHAR_VERSION); php_info_print_table_row(2, "Phar API version", PHP_PHAR_API_VERSION); - php_info_print_table_row(2, "SVN revision", "$Revision: 314419 $"); + php_info_print_table_row(2, "SVN revision", "$Revision: 321634 $"); php_info_print_table_row(2, "Phar-based phar archives", "enabled"); php_info_print_table_row(2, "Tar-based phar archives", "enabled"); php_info_print_table_row(2, "ZIP-based phar archives", "enabled"); diff --git a/ext/phar/phar_internal.h b/ext/phar/phar_internal.h index 0b4b08395..ef9a7fa65 100644 --- a/ext/phar/phar_internal.h +++ b/ext/phar/phar_internal.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | phar php single-file executable PHP extension | +----------------------------------------------------------------------+ - | Copyright (c) 2006-2011 The PHP Group | + | Copyright (c) 2006-2012 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: phar_internal.h 308657 2011-02-25 09:32:17Z nlopess $ */ +/* $Id: phar_internal.h 321634 2012-01-01 13:15:04Z felipe $ */ #ifdef HAVE_CONFIG_H #include "config.h" diff --git a/ext/phar/phar_object.c b/ext/phar/phar_object.c index f7dbc209c..959a2b483 100644 --- a/ext/phar/phar_object.c +++ b/ext/phar/phar_object.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | phar php single-file executable PHP extension | +----------------------------------------------------------------------+ - | Copyright (c) 2005-2011 The PHP Group | + | Copyright (c) 2005-2012 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: phar_object.c 314653 2011-08-09 14:11:56Z iliaa $ */ +/* $Id: phar_object.c 321634 2012-01-01 13:15:04Z felipe $ */ #include "phar_internal.h" #include "func_interceptors.h" diff --git a/ext/phar/phar_path_check.c b/ext/phar/phar_path_check.c index c33d75f8b..cb73e7a82 100644 --- a/ext/phar/phar_path_check.c +++ b/ext/phar/phar_path_check.c @@ -4,7 +4,7 @@ +----------------------------------------------------------------------+ | phar php single-file executable PHP extension | +----------------------------------------------------------------------+ - | Copyright (c) 2007-2011 The PHP Group | + | Copyright (c) 2007-2012 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: phar_path_check.c 308657 2011-02-25 09:32:17Z nlopess $ */ +/* $Id: phar_path_check.c 321634 2012-01-01 13:15:04Z felipe $ */ #include "phar_internal.h" diff --git a/ext/phar/phar_path_check.re b/ext/phar/phar_path_check.re index 19da87cd0..46431749a 100644 --- a/ext/phar/phar_path_check.re +++ b/ext/phar/phar_path_check.re @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | phar php single-file executable PHP extension | +----------------------------------------------------------------------+ - | Copyright (c) 2007-2011 The PHP Group | + | Copyright (c) 2007-2012 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: phar_path_check.re 308657 2011-02-25 09:32:17Z nlopess $ */ +/* $Id: phar_path_check.re 321634 2012-01-01 13:15:04Z felipe $ */ #include "phar_internal.h" diff --git a/ext/phar/pharzip.h b/ext/phar/pharzip.h index afc3ea2a9..e7471a5e8 100644 --- a/ext/phar/pharzip.h +++ b/ext/phar/pharzip.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | phar php single-file executable PHP extension | +----------------------------------------------------------------------+ - | Copyright (c) 2006-2011 The PHP Group | + | Copyright (c) 2006-2012 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: pharzip.h 306941 2011-01-01 02:48:19Z felipe $ */ +/* $Id: pharzip.h 321634 2012-01-01 13:15:04Z felipe $ */ typedef struct _phar_zip_file_header { char signature[4]; /* local file header signature 4 bytes (0x04034b50) */ diff --git a/ext/phar/php_phar.h b/ext/phar/php_phar.h index 0dc642967..87bc0a2bc 100644 --- a/ext/phar/php_phar.h +++ b/ext/phar/php_phar.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | phar php single-file executable PHP extension | +----------------------------------------------------------------------+ - | Copyright (c) 2005-2011 The PHP Group | + | Copyright (c) 2005-2012 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_phar.h 306941 2011-01-01 02:48:19Z felipe $ */ +/* $Id: php_phar.h 321634 2012-01-01 13:15:04Z felipe $ */ #ifndef PHP_PHAR_H #define PHP_PHAR_H diff --git a/ext/phar/stream.c b/ext/phar/stream.c index cf2c53620..7e74ed60f 100644 --- a/ext/phar/stream.c +++ b/ext/phar/stream.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | phar:// stream wrapper support | +----------------------------------------------------------------------+ - | Copyright (c) 2005-2011 The PHP Group | + | Copyright (c) 2005-2012 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | diff --git a/ext/phar/stream.h b/ext/phar/stream.h index 045186c54..138285997 100644 --- a/ext/phar/stream.h +++ b/ext/phar/stream.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | phar php single-file executable PHP extension | +----------------------------------------------------------------------+ - | Copyright (c) 2006-2011 The PHP Group | + | Copyright (c) 2006-2012 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: stream.h 306941 2011-01-01 02:48:19Z felipe $ */ +/* $Id: stream.h 321634 2012-01-01 13:15:04Z felipe $ */ BEGIN_EXTERN_C() diff --git a/ext/phar/stub.h b/ext/phar/stub.h index 6a68464b4..cf20f25c8 100644 --- a/ext/phar/stub.h +++ b/ext/phar/stub.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | phar php single-file executable PHP extension generated stub | +----------------------------------------------------------------------+ - | Copyright (c) 2005-2011 The PHP Group | + | Copyright (c) 2005-2012 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: stub.h 306941 2011-01-01 02:48:19Z felipe $ */ +/* $Id: stub.h 321634 2012-01-01 13:15:04Z felipe $ */ static inline void phar_get_stub(const char *index_php, const char *web, size_t *len, char **stub, const int name_len, const int web_len TSRMLS_DC) { diff --git a/ext/phar/tar.c b/ext/phar/tar.c index 38c3f4f85..9d1e5bcb1 100644 --- a/ext/phar/tar.c +++ b/ext/phar/tar.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | TAR archive support for Phar | +----------------------------------------------------------------------+ - | Copyright (c) 2005-2011 The PHP Group | + | Copyright (c) 2005-2012 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | diff --git a/ext/phar/tar.h b/ext/phar/tar.h index 950cace9f..ed9934647 100644 --- a/ext/phar/tar.h +++ b/ext/phar/tar.h @@ -4,7 +4,7 @@ +----------------------------------------------------------------------+ | TAR archive support for Phar | +----------------------------------------------------------------------+ - | Copyright (c) 2005-2011 The PHP Group | + | Copyright (c) 2005-2012 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | diff --git a/ext/phar/tests/bug53872.phpt b/ext/phar/tests/bug53872.phpt new file mode 100644 index 000000000..fd332fdf0 --- /dev/null +++ b/ext/phar/tests/bug53872.phpt @@ -0,0 +1,28 @@ +--TEST--
+bug#53872 (internal corruption of phar)
+--SKIPIF--
+<?php
+if (!extension_loaded("phar")) die("skip");
+if (!extension_loaded("zlib")) die("skip Test needs ext/zlib");
+?>
+--INI--
+phar.readonly=0
+--FILE--
+<?php
+$p=new Phar('bug53872-phar.phar');
+$p->buildFromDirectory(__DIR__ . "/bug53872/");
+$p->setStub('<?php __HALT_COMPILER();?\>');
+$p->compressFiles(Phar::GZ);
+
+print(file_get_contents('phar://bug53872-phar.phar/first.txt'));
+print(file_get_contents('phar://bug53872-phar.phar/second.txt'));
+print(file_get_contents('phar://bug53872-phar.phar/third.txt'));
+?>
+--CLEAN--
+<?php
+unlink("bug53872-phar.phar");
+?>
+--EXPECT--
+content of first.txt
+content of third.txt
+
diff --git a/ext/phar/tests/bug53872/first.txt b/ext/phar/tests/bug53872/first.txt new file mode 100644 index 000000000..90a4d1f09 --- /dev/null +++ b/ext/phar/tests/bug53872/first.txt @@ -0,0 +1 @@ +content of first.txt diff --git a/ext/phar/tests/bug53872/second.txt b/ext/phar/tests/bug53872/second.txt new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/ext/phar/tests/bug53872/second.txt diff --git a/ext/phar/tests/bug53872/third.txt b/ext/phar/tests/bug53872/third.txt new file mode 100644 index 000000000..4f283cd78 --- /dev/null +++ b/ext/phar/tests/bug53872/third.txt @@ -0,0 +1 @@ +content of third.txt diff --git a/ext/phar/tests/bug60164.phpt b/ext/phar/tests/bug60164.phpt new file mode 100644 index 000000000..8fd5de514 --- /dev/null +++ b/ext/phar/tests/bug60164.phpt @@ -0,0 +1,21 @@ +--TEST-- +Phar: verify stub of specific length does not break __HALT_COMPILER(); scanning in php +--SKIPIF-- +<?php +if (!extension_loaded("phar")) die("skip"); +?> +--INI-- +phar.require_hash=0 +phar.readonly=0 +--FILE-- +<?php +$phar = __DIR__ . '/files/stuboflength1041.phar'; +foreach (new RecursiveIteratorIterator(new Phar($phar, null, 'stuboflength1041.phar')) as $item) { + var_dump($item->getFileName()); +} +?> +===DONE=== +--EXPECT-- +string(5) "a.php" +string(5) "b.php" +===DONE===
\ No newline at end of file diff --git a/ext/phar/tests/bug60261.phpt b/ext/phar/tests/bug60261.phpt new file mode 100644 index 000000000..1b6cd7a7c --- /dev/null +++ b/ext/phar/tests/bug60261.phpt @@ -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 diff --git a/ext/phar/tests/files/stuboflength1041.phar b/ext/phar/tests/files/stuboflength1041.phar Binary files differnew file mode 100644 index 000000000..d90fb8f10 --- /dev/null +++ b/ext/phar/tests/files/stuboflength1041.phar diff --git a/ext/phar/tests/files/stuboflength1041.phar.inc b/ext/phar/tests/files/stuboflength1041.phar.inc new file mode 100644 index 000000000..4a26a41a0 --- /dev/null +++ b/ext/phar/tests/files/stuboflength1041.phar.inc @@ -0,0 +1,42 @@ +<?php + +@unlink(__DIR__ . '/stuboflength1041.phar'); + +$phar = new Phar('./stuboflength1041.phar'); +$phar['a.php'] = 'hi1'; +$phar['b.php'] = 'hi2'; + +$phar->setStub('<?php +/***stub of length 1041 including the halt compiler********************************************* +************************************************************************************************ +************************************************************************************************ +************************************************************************************************ +************************************************************************************************ +************************************************************************************************ +************************************************************************************************ +************************************************************************************************ +************************************************************************************************ +************************************************************************************************ +*********************************************/ +__HALT_COMPILER();'); +<?php + +@unlink(__DIR__ . '/stuboflength1041.phar'); + +$phar = new Phar('./stuboflength1041.phar'); +$phar['a.php'] = 'hi1'; +$phar['b.php'] = 'hi2'; + +$phar->setStub('<?php +/***stub of length 1041 including the halt compiler********************************************* +************************************************************************************************ +************************************************************************************************ +************************************************************************************************ +************************************************************************************************ +************************************************************************************************ +************************************************************************************************ +************************************************************************************************ +************************************************************************************************ +************************************************************************************************ +*********************************************/ +__HALT_COMPILER();');
\ No newline at end of file diff --git a/ext/phar/tests/fopen_edgecases2.phpt b/ext/phar/tests/fopen_edgecases2.phpt index 6c5ac7b45..c7ccd34af 100644 --- a/ext/phar/tests/fopen_edgecases2.phpt +++ b/ext/phar/tests/fopen_edgecases2.phpt @@ -2,7 +2,7 @@ Phar: test edge cases of fopen() function interception #2 --SKIPIF-- <?php if (!extension_loaded("phar")) die("skip"); ?> -<?php if (version_compare(php_version(), '6.0', '>=')) die('skip parameter parsing changed in 6.0'); ?> +<?php if (version_compare(phpversion(), '6.0', '>=')) die('skip parameter parsing changed in 6.0'); ?> --INI-- phar.readonly=0 --FILE-- diff --git a/ext/phar/tests/phar_commitwrite.phpt b/ext/phar/tests/phar_commitwrite.phpt index 36d473e5c..8e3668133 100644 --- a/ext/phar/tests/phar_commitwrite.phpt +++ b/ext/phar/tests/phar_commitwrite.phpt @@ -39,4 +39,4 @@ Phar::mapPhar('brandnewphar.phar'); include 'phar://brandnewphar.phar/startup.php'; __HALT_COMPILER(); ?> " -===DONE===
\ No newline at end of file +===DONE=== diff --git a/ext/phar/tests/phar_create_in_cwd.phpt b/ext/phar/tests/phar_create_in_cwd.phpt index 4b0e6594f..1828fe745 100644 --- a/ext/phar/tests/phar_create_in_cwd.phpt +++ b/ext/phar/tests/phar_create_in_cwd.phpt @@ -42,4 +42,4 @@ Phar::mapPhar('brandnewphar.phar'); include 'phar://brandnewphar.phar/startup.php'; __HALT_COMPILER(); ?> " -===DONE===
\ No newline at end of file +===DONE=== diff --git a/ext/phar/tests/phar_gobyebye-win32.phpt b/ext/phar/tests/phar_gobyebye-win32.phpt new file mode 100644 index 000000000..43c8c7782 --- /dev/null +++ b/ext/phar/tests/phar_gobyebye-win32.phpt @@ -0,0 +1,48 @@ +--TEST--
+Phar: test edge cases of intercepted functions when the underlying phar archive has been unlinkArchive()d
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip");
+if (strpos(PHP_OS, 'WIN') === false) die("skip Extra warning on Windows.");
+?>
+--INI--
+phar.readonly=0
+--FILE--
+<?php
+Phar::interceptFileFuncs();
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
+$fname2 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.2.php';
+$pname = 'phar://' . $fname;
+file_put_contents($fname2, '<?php Phar::unlinkArchive("' . addslashes($fname) . '");');
+file_put_contents($pname . '/foo/hi', '<?php
+include "' . addslashes($fname2) . '";
+readfile("foo/hi");
+fopen("foo/hi", "r");
+echo file_get_contents("foo/hi");
+var_dump(is_file("foo/hi"),is_link("foo/hi"),is_dir("foo/hi"),file_exists("foo/hi"),stat("foo/hi"));
+opendir("foo/hi");
+?>
+');
+include $pname . '/foo/hi';
+?>
+===DONE===
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.2.php'); ?>
+--EXPECTF--
+Warning: readfile(foo/hi): failed to open stream: No such file or directory in phar://%sphar_gobyebye-win32.phar.php/foo/hi on line %d
+
+Warning: fopen(foo/hi): failed to open stream: No such file or directory in phar://%sphar_gobyebye-win32.phar.php/foo/hi on line %d
+
+Warning: file_get_contents(foo/hi): failed to open stream: No such file or directory in phar://%sphar_gobyebye-win32.phar.php/foo/hi on line %d
+
+Warning: stat(): stat failed for foo/hi in phar://%sphar_gobyebye-win32.phar.php/foo/hi on line %d
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+
+Warning: opendir(foo/hi,foo/hi): The system cannot find the path specified. (code: 3) in phar://%sphar_gobyebye-win32.phar.php/foo/hi on line %d
+
+Warning: opendir(foo/hi): failed to open dir: No such file or directory in phar://%sphar_gobyebye-win32.phar.php/foo/hi on line %d
+===DONE===
diff --git a/ext/phar/tests/phar_gobyebye.phpt b/ext/phar/tests/phar_gobyebye.phpt index d55bef0c3..608e95076 100644 --- a/ext/phar/tests/phar_gobyebye.phpt +++ b/ext/phar/tests/phar_gobyebye.phpt @@ -1,7 +1,10 @@ --TEST-- Phar: test edge cases of intercepted functions when the underlying phar archive has been unlinkArchive()d --SKIPIF-- -<?php if (!extension_loaded("phar")) die("skip");?> +<?php +if (defined('PHP_WINDOWS_VERSION_MAJOR')) die("skip"); +if (!extension_loaded("phar")) die("skip"); +?> --INI-- phar.readonly=0 --FILE-- diff --git a/ext/phar/tests/phar_oo_001.phpt b/ext/phar/tests/phar_oo_001.phpt index f211394e5..7a81bbb4b 100755 --- a/ext/phar/tests/phar_oo_001.phpt +++ b/ext/phar/tests/phar_oo_001.phpt @@ -30,14 +30,14 @@ try $phar = new MyPhar(); var_dump($phar->getVersion()); } -catch (BadMethodCallException $e) +catch (LogicException $e) { var_dump($e->getMessage()); } try { $phar = new Phar('test.phar'); $phar->__construct('oops'); -} catch (BadMethodCallException $e) +} catch (LogicException $e) { var_dump($e->getMessage()); } diff --git a/ext/phar/util.c b/ext/phar/util.c index 983ca38d1..c92d796eb 100644 --- a/ext/phar/util.c +++ b/ext/phar/util.c @@ -3,7 +3,7 @@ | phar php single-file executable PHP extension | | utility functions | +----------------------------------------------------------------------+ - | Copyright (c) 2005-2011 The PHP Group | + | Copyright (c) 2005-2012 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: util.c 314419 2011-08-07 11:13:27Z laruence $ */ +/* $Id: util.c 321634 2012-01-01 13:15:04Z felipe $ */ #include "phar_internal.h" #ifdef PHAR_HASH_OK @@ -1000,10 +1000,12 @@ int phar_open_entry_fp(phar_entry_info *entry, char **error, int follow_links TS php_stream_filter_append(&ufp->writefilters, filter); php_stream_seek(phar_get_entrypfp(entry TSRMLS_CC), phar_get_fp_offset(entry TSRMLS_CC), SEEK_SET); - if (SUCCESS != phar_stream_copy_to_stream(phar_get_entrypfp(entry TSRMLS_CC), ufp, entry->compressed_filesize, NULL)) { - spprintf(error, 4096, "phar error: internal corruption of phar \"%s\" (actual filesize mismatch on file \"%s\")", phar->fname, entry->filename); - php_stream_filter_remove(filter, 1 TSRMLS_CC); - return FAILURE; + if (entry->uncompressed_filesize) { + if (SUCCESS != phar_stream_copy_to_stream(phar_get_entrypfp(entry TSRMLS_CC), ufp, entry->compressed_filesize, NULL)) { + spprintf(error, 4096, "phar error: internal corruption of phar \"%s\" (actual filesize mismatch on file \"%s\")", phar->fname, entry->filename); + php_stream_filter_remove(filter, 1 TSRMLS_CC); + return FAILURE; + } } php_stream_filter_flush(filter, 1); diff --git a/ext/phar/zip.c b/ext/phar/zip.c index a8ac63aeb..ced975cb3 100644 --- a/ext/phar/zip.c +++ b/ext/phar/zip.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | ZIP archive support for Phar | +----------------------------------------------------------------------+ - | Copyright (c) 2007-2011 The PHP Group | + | Copyright (c) 2007-2012 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | |
