diff options
author | Pierre Joye <pajoye@php.net> | 2011-02-07 16:20:16 +0000 |
---|---|---|
committer | Pierre Joye <pajoye@php.net> | 2011-02-07 16:20:16 +0000 |
commit | 5b521b71a2c58bc63e892981836414197b35c817 (patch) | |
tree | 4d7560e914b940423d67d29ced60ce000b5e785b /ext/zip/php_zip.c | |
parent | 44b9942ef39bde2772d06108529b430a2d0c137c (diff) | |
download | php-git-5b521b71a2c58bc63e892981836414197b35c817.tar.gz |
- Fixed bug #53893 (Wrong return value for ZipArchive::extractTo())
Diffstat (limited to 'ext/zip/php_zip.c')
-rw-r--r-- | ext/zip/php_zip.c | 40 |
1 files changed, 30 insertions, 10 deletions
diff --git a/ext/zip/php_zip.c b/ext/zip/php_zip.c index ec7c239162..078a9bc091 100644 --- a/ext/zip/php_zip.c +++ b/ext/zip/php_zip.c @@ -232,9 +232,14 @@ static int php_zip_extract_file(struct zip * za, char *dest, char *file, int fil 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 @@ static int php_zip_extract_file(struct zip * za, char *dest, char *file, int fil 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_dirname_fullpath); efree(file_basename); + efree(file_dirname_fullpath); 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); |