svn: /php/php-src/ branches/PHP_5_3/ext/zip/php_zip.c branches/PHP_5_3/ext/zip/tests/bug53603.phpt trunk/ext/zip/php_zip.c
trunk/ext/zip/tests/bug53603.phpt
| From: | Pierre Joye | Date: | Mon, 07 Feb 2011 16:20:16 +0000 |
| Subject: | svn: /php/php-src/ branches/PHP_5_3/ext/zip/php_zip.c branches/PHP_5_3/ext/zip/tests/bug53603.phpt trunk/ext/zip/php_zip.c trunk/ext/zip/tests/bug53603.phpt |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-64512@lists.php.net to get a copy of this message | ||
pajoye Mon, 07 Feb 2011 16:20:16 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=308107
Log:
- Fixed bug #53893 (Wrong return value for ZipArchive::extractTo())
Bug: http://bugs.php.net/53893 (Open) Wrong return value for
ZipArchive::extractTo()
Changed paths:
U php/php-src/branches/PHP_5_3/ext/zip/php_zip.c
U php/php-src/branches/PHP_5_3/ext/zip/tests/bug53603.phpt
U php/php-src/trunk/ext/zip/php_zip.c
U php/php-src/trunk/ext/zip/tests/bug53603.phpt
Modified: php/php-src/branches/PHP_5_3/ext/zip/php_zip.c
===================================================================
--- php/php-src/branches/PHP_5_3/ext/zip/php_zip.c 2011-02-07 16:08:44 UTC (rev 308106)
+++ php/php-src/branches/PHP_5_3/ext/zip/php_zip.c 2011-02-07 16:20:16 UTC (rev 308107)
@@ -232,9 +232,14 @@
efree(file_dirname_fullpath);
efree(file_basename);
free(new_state.cwd);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot build full extract path");
return 0;
} else if (len > MAXPATHLEN) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Full extraction path exceed MAXPATHLEN
(%i)", MAXPATHLEN);
+ efree(file_dirname_fullpath);
+ efree(file_basename);
+ free(new_state.cwd);
+ return 0;
}
/* check again the full path, not sure if it
@@ -249,27 +254,42 @@
return 0;
}
+#if PHP_API_VERSION < 20100412
+ stream = php_stream_open_wrapper(fullpath, "w+b", REPORT_ERRORS|ENFORCE_SAFE_MODE,
NULL);
+#else
+ stream = php_stream_open_wrapper(fullpath, "w+b", REPORT_ERRORS, NULL);
+#endif
+
+ if (stream == NULL) {
+ n = -1;
+ goto done;
+ }
+
zf = zip_fopen(za, file, 0);
if (zf == NULL) {
+ n = -1;
+ php_stream_close(stream);
+ goto done;
+ }
+
+ n = 0;
+ if (stream == NULL) {
+ int ret = zip_fclose(zf);
efree(fullpath);
+ efree(file_basename);
efree(file_dirname_fullpath);
- efree(file_basename);
free(new_state.cwd);
return 0;
}
-#if PHP_API_VERSION < 20100412
- stream = php_stream_open_wrapper(fullpath, "w+b", REPORT_ERRORS|ENFORCE_SAFE_MODE,
NULL);
-#else
- stream = php_stream_open_wrapper(fullpath, "w+b", REPORT_ERRORS, NULL);
-#endif
- n = 0;
- if (stream) {
- while ((n=zip_fread(zf, b, sizeof(b))) > 0) php_stream_write(stream, b, n);
- php_stream_close(stream);
+ while ((n=zip_fread(zf, b, sizeof(b))) > 0) {
+ php_stream_write(stream, b, n);
}
+
+ php_stream_close(stream);
n = zip_fclose(zf);
+done:
efree(fullpath);
efree(file_basename);
efree(file_dirname_fullpath);
Modified: php/php-src/branches/PHP_5_3/ext/zip/tests/bug53603.phpt
===================================================================
--- php/php-src/branches/PHP_5_3/ext/zip/tests/bug53603.phpt 2011-02-07 16:08:44 UTC (rev 308106)
+++ php/php-src/branches/PHP_5_3/ext/zip/tests/bug53603.phpt 2011-02-07 16:20:16 UTC (rev 308107)
@@ -29,10 +29,7 @@
var_dump($a);
--EXPECTF--
+
Warning: ZipArchive::extractTo(teststream://test/foo): failed to open stream:
"TestStream::stream_open" call failed in %s on line %d
+bool(false)
-Warning: ZipArchive::extractTo(teststream://test/bar): failed to open stream:
"TestStream::stream_open" call failed in %s on line %d
-
-Warning: ZipArchive::extractTo(teststream://test/foobar/baz): failed to open stream:
"TestStream::stream_open" call failed in %s on line %d
-bool(true)
-
Modified: php/php-src/trunk/ext/zip/php_zip.c
===================================================================
--- php/php-src/trunk/ext/zip/php_zip.c 2011-02-07 16:08:44 UTC (rev 308106)
+++ php/php-src/trunk/ext/zip/php_zip.c 2011-02-07 16:20:16 UTC (rev 308107)
@@ -235,6 +235,10 @@
return 0;
} else if (len > MAXPATHLEN) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Full extraction path exceed MAXPATHLEN
(%i)", MAXPATHLEN);
+ efree(file_dirname_fullpath);
+ efree(file_basename);
+ free(new_state.cwd);
+ return 0;
}
/* check again the full path, not sure if it
@@ -249,27 +253,42 @@
return 0;
}
+#if PHP_API_VERSION < 20100412
+ stream = php_stream_open_wrapper(fullpath, "w+b", REPORT_ERRORS|ENFORCE_SAFE_MODE,
NULL);
+#else
+ stream = php_stream_open_wrapper(fullpath, "w+b", REPORT_ERRORS, NULL);
+#endif
+
+ if (stream == NULL) {
+ n = -1;
+ goto done;
+ }
+
zf = zip_fopen(za, file, 0);
if (zf == NULL) {
+ n = -1;
+ php_stream_close(stream);
+ goto done;
+ }
+
+ n = 0;
+ if (stream == NULL) {
+ int ret = zip_fclose(zf);
efree(fullpath);
+ efree(file_basename);
efree(file_dirname_fullpath);
- efree(file_basename);
free(new_state.cwd);
return 0;
}
-#if PHP_API_VERSION < 20100412
- stream = php_stream_open_wrapper(fullpath, "w+b", REPORT_ERRORS|ENFORCE_SAFE_MODE,
NULL);
-#else
- stream = php_stream_open_wrapper(fullpath, "w+b", REPORT_ERRORS, NULL);
-#endif
- n = 0;
- if (stream) {
- while ((n=zip_fread(zf, b, sizeof(b))) > 0) php_stream_write(stream, b, n);
- php_stream_close(stream);
+ while ((n=zip_fread(zf, b, sizeof(b))) > 0) {
+ php_stream_write(stream, b, n);
}
+
+ php_stream_close(stream);
n = zip_fclose(zf);
+done:
efree(fullpath);
efree(file_basename);
efree(file_dirname_fullpath);
Modified: php/php-src/trunk/ext/zip/tests/bug53603.phpt
===================================================================
--- php/php-src/trunk/ext/zip/tests/bug53603.phpt 2011-02-07 16:08:44 UTC (rev 308106)
+++ php/php-src/trunk/ext/zip/tests/bug53603.phpt 2011-02-07 16:20:16 UTC (rev 308107)
@@ -29,10 +29,7 @@
var_dump($a);
--EXPECTF--
+
Warning: ZipArchive::extractTo(teststream://test/foo): failed to open stream:
"TestStream::stream_open" call failed in %s on line %d
+bool(false)
-Warning: ZipArchive::extractTo(teststream://test/bar): failed to open stream:
"TestStream::stream_open" call failed in %s on line %d
-
-Warning: ZipArchive::extractTo(teststream://test/foobar/baz): failed to open stream:
"TestStream::stream_open" call failed in %s on line %d
-bool(true)
-