diff options
Diffstat (limited to 'ext/zip/zip_stream.c')
-rw-r--r-- | ext/zip/zip_stream.c | 40 |
1 files changed, 27 insertions, 13 deletions
diff --git a/ext/zip/zip_stream.c b/ext/zip/zip_stream.c index 79b54cbbb0..c542340170 100644 --- a/ext/zip/zip_stream.c +++ b/ext/zip/zip_stream.c @@ -1,3 +1,21 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 7 | + +----------------------------------------------------------------------+ + | Copyright (c) 1997-2014 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 | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt. | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Author: Piere-Alain Joye <pierre@php.net> | + +----------------------------------------------------------------------+ +*/ + /* $Id$ */ #ifdef HAVE_CONFIG_H # include "config.h" @@ -6,8 +24,6 @@ #if HAVE_ZIP #ifdef ZEND_ENGINE_2 -#include "lib/zip.h" - #include "php_streams.h" #include "ext/standard/file.h" #include "ext/standard/php_string.h" @@ -102,13 +118,12 @@ static int php_zip_ops_stat(php_stream *stream, php_stream_statbuf *ssb TSRMLS_D struct zip_stat sb; const char *path = stream->orig_path; int path_len = strlen(stream->orig_path); - char *file_basename; - size_t file_basename_len; char file_dirname[MAXPATHLEN]; struct zip *za; char *fragment; int fragment_len; int err; + zend_string *file_basename; fragment = strchr(path, '#'); if (!fragment) { @@ -133,11 +148,11 @@ static int php_zip_ops_stat(php_stream *stream, php_stream_statbuf *ssb TSRMLS_D memcpy(file_dirname, path, path_len - fragment_len); file_dirname[path_len - fragment_len] = '\0'; - php_basename((char *)path, path_len - fragment_len, NULL, 0, &file_basename, &file_basename_len TSRMLS_CC); + file_basename = php_basename((char *)path, path_len - fragment_len, NULL, 0 TSRMLS_CC); fragment++; if (ZIP_OPENBASEDIR_CHECKPATH(file_dirname)) { - efree(file_basename); + zend_string_release(file_basename); return -1; } @@ -145,7 +160,7 @@ static int php_zip_ops_stat(php_stream *stream, php_stream_statbuf *ssb TSRMLS_D if (za) { memset(ssb, 0, sizeof(php_stream_statbuf)); if (zip_stat(za, fragment, ZIP_FL_NOCASE, &sb) != 0) { - efree(file_basename); + zend_string_release(file_basename); return -1; } zip_close(za); @@ -169,7 +184,7 @@ static int php_zip_ops_stat(php_stream *stream, php_stream_statbuf *ssb TSRMLS_D #endif ssb->sb.st_ino = -1; } - efree(file_basename); + zend_string_release(file_basename); return 0; } /* }}} */ @@ -243,8 +258,7 @@ php_stream *php_stream_zip_opener(php_stream_wrapper *wrapper, { int path_len; - char *file_basename; - size_t file_basename_len; + zend_string *file_basename; char file_dirname[MAXPATHLEN]; struct zip *za; @@ -278,11 +292,11 @@ php_stream *php_stream_zip_opener(php_stream_wrapper *wrapper, memcpy(file_dirname, path, path_len - fragment_len); file_dirname[path_len - fragment_len] = '\0'; - php_basename(path, path_len - fragment_len, NULL, 0, &file_basename, &file_basename_len TSRMLS_CC); + file_basename = php_basename(path, path_len - fragment_len, NULL, 0 TSRMLS_CC); fragment++; if (ZIP_OPENBASEDIR_CHECKPATH(file_dirname)) { - efree(file_basename); + zend_string_release(file_basename); return NULL; } @@ -306,7 +320,7 @@ php_stream *php_stream_zip_opener(php_stream_wrapper *wrapper, } } - efree(file_basename); + zend_string_release(file_basename); if (!stream) { return NULL; |