diff options
| author | Greg Beaver <cellog@php.net> | 2008-04-16 04:34:25 +0000 |
|---|---|---|
| committer | Greg Beaver <cellog@php.net> | 2008-04-16 04:34:25 +0000 |
| commit | 4e584728e5763f3791262626b1f5b8e5b4eceef6 (patch) | |
| tree | 51e65a13877fa1ad5d4f972fdf7132ee8cfbcb74 | |
| parent | 398bcf4dd0171472be6442729891451a365197d1 (diff) | |
| download | php-git-4e584728e5763f3791262626b1f5b8e5b4eceef6.tar.gz | |
fix end of directory locator detection code, add failing test for large zips
| -rw-r--r-- | ext/phar/tests/zip/largezip.phpt | 29 | ||||
| -rw-r--r-- | ext/phar/zip.c | 4 |
2 files changed, 33 insertions, 0 deletions
diff --git a/ext/phar/tests/zip/largezip.phpt b/ext/phar/tests/zip/largezip.phpt new file mode 100644 index 0000000000..93cbaca256 --- /dev/null +++ b/ext/phar/tests/zip/largezip.phpt @@ -0,0 +1,29 @@ +--TEST-- +Phar: large zip file (zip edge cases) +--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.zip.php'; +$fname2 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.2.phar.zip.php'; +$pname = 'phar://' . $fname; +$pname2 = 'phar://' . $fname2; + +$p = new Phar($fname); +$p['big'] = str_repeat(str_repeat('hi', 100), 1000); +$p['big2'] = str_repeat(str_repeat('hi', 100), 1000); + +copy($fname, $fname2); +$p2 = new Phar($fname2); +var_dump(strlen($p2['big'])); +?> +===DONE=== +--CLEAN-- +<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.zip.php'); ?> +<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.2.phar.zip.php'); ?> +--EXPECT-- +int(100000) +===DONE=== diff --git a/ext/phar/zip.c b/ext/phar/zip.c index c77273dafe..9e0ddce9e7 100644 --- a/ext/phar/zip.c +++ b/ext/phar/zip.c @@ -168,6 +168,9 @@ int phar_open_zipfile(php_stream *fp, char *fname, int fname_len, char *alias, i php_stream_close(fp); return FAILURE; } + if (*p == 'P' && !memcmp(p + 1, "K\5\6", 3)) { + goto copybuf; + } while ((p=(char *) memchr(p + 1, 'P', (size_t)(buf - (p+1) + 8192 - 4 + 1))) != NULL) { if (!memcmp(p + 1, "K\5\6", 3)) { if (p - buf < sizeof(locator)) { @@ -178,6 +181,7 @@ int phar_open_zipfile(php_stream *fp, char *fname, int fname_len, char *alias, i return FAILURE; } } else { +copybuf: memcpy((void *)&locator, (void *) p, sizeof(locator)); } goto foundit; |
