summaryrefslogtreecommitdiff
path: root/ext/zip
diff options
context:
space:
mode:
authorChristoph M. Becker <cmbecker69@gmx.de>2016-09-06 01:07:15 +0200
committerChristoph M. Becker <cmbecker69@gmx.de>2016-09-06 01:15:36 +0200
commit81ec843d0ee6a7e236cfab15f1908953d7247677 (patch)
tree91e2b688d203e8693ef174404b8ce22fdc4ed675 /ext/zip
parent009ee6e503fd2f354f6eda2b6a74f13344dca3b0 (diff)
parent8aad3131a1d00e191db1b3b27aed6e7fae269f13 (diff)
downloadphp-git-81ec843d0ee6a7e236cfab15f1908953d7247677.tar.gz
Merge branch 'PHP-5.6' into PHP-7.0
Diffstat (limited to 'ext/zip')
-rw-r--r--ext/zip/php_zip.c12
-rw-r--r--ext/zip/tests/bug70752.phpt31
-rw-r--r--ext/zip/tests/bug70752.zipbin0 -> 175 bytes
3 files changed, 37 insertions, 6 deletions
diff --git a/ext/zip/php_zip.c b/ext/zip/php_zip.c
index b9f0bb73ac..cfac566506 100644
--- a/ext/zip/php_zip.c
+++ b/ext/zip/php_zip.c
@@ -238,17 +238,17 @@ static int php_zip_extract_file(struct zip * za, char *dest, char *file, int fil
return 0;
}
- stream = php_stream_open_wrapper(fullpath, "w+b", REPORT_ERRORS, NULL);
-
- if (stream == NULL) {
+ zf = zip_fopen(za, file, 0);
+ if (zf == NULL) {
n = -1;
goto done;
}
- zf = zip_fopen(za, file, 0);
- if (zf == NULL) {
+ stream = php_stream_open_wrapper(fullpath, "w+b", REPORT_ERRORS, NULL);
+
+ if (stream == NULL) {
n = -1;
- php_stream_close(stream);
+ zip_fclose(zf);
goto done;
}
diff --git a/ext/zip/tests/bug70752.phpt b/ext/zip/tests/bug70752.phpt
new file mode 100644
index 0000000000..f006fbee9a
--- /dev/null
+++ b/ext/zip/tests/bug70752.phpt
@@ -0,0 +1,31 @@
+--TEST--
+Bug #70752 (Depacking with wrong password leaves 0 length files)
+--SKIPIF--
+<?php
+if (!extension_loaded('zip')) die('skip zip extension not available');
+?>
+--FILE--
+<?php
+$filename = __DIR__ . DIRECTORY_SEPARATOR . 'bug70752.zip';
+$zip = new ZipArchive();
+$zip->open($filename);
+
+$filename = __DIR__ . DIRECTORY_SEPARATOR . 'bug70752.txt';
+var_dump(file_exists($filename));
+
+$zip->setPassword('bar'); // correct password would be 'foo'
+$zip->extractTo(__DIR__);
+$zip->close();
+
+var_dump(file_exists($filename));
+?>
+===DONE===
+--EXPECT--
+bool(false)
+bool(false)
+===DONE===
+--CLEAN--
+<?php
+$filename = __DIR__ . DIRECTORY_SEPARATOR . 'bug70752.txt';
+unlink($filename);
+?>
diff --git a/ext/zip/tests/bug70752.zip b/ext/zip/tests/bug70752.zip
new file mode 100644
index 0000000000..9bec61bc18
--- /dev/null
+++ b/ext/zip/tests/bug70752.zip
Binary files differ