diff options
author | Ilia Alshanetsky <iliaa@php.net> | 2007-05-19 19:29:37 +0000 |
---|---|---|
committer | Ilia Alshanetsky <iliaa@php.net> | 2007-05-19 19:29:37 +0000 |
commit | c009fc8915497dfbdec23a8d016e6ba2a4c2c350 (patch) | |
tree | 2d645510b3300bf18f9e4f662bea562a4ee85a3f /ext/zip/php_zip.c | |
parent | a3899eda3e69781a6bcf9d1a37a6b021c9596a0e (diff) | |
download | php-git-c009fc8915497dfbdec23a8d016e6ba2a4c2c350.tar.gz |
CS fixes
Fixed a possible crash in the event directory cannot be created, due to a
double free.
Diffstat (limited to 'ext/zip/php_zip.c')
-rw-r--r-- | ext/zip/php_zip.c | 51 |
1 files changed, 23 insertions, 28 deletions
diff --git a/ext/zip/php_zip.c b/ext/zip/php_zip.c index be071bed42..75ffeba106 100644 --- a/ext/zip/php_zip.c +++ b/ext/zip/php_zip.c @@ -1699,7 +1699,6 @@ static ZIPARCHIVE_METHOD(extractTo) zval **zval_file = NULL; php_stream_statbuf ssb; char *pathto; - char *file; int pathto_len; int ret, i; @@ -1713,24 +1712,22 @@ static ZIPARCHIVE_METHOD(extractTo) return; } - if (pathto_len<1) { + if (pathto_len < 1) { RETURN_FALSE; } - if (php_stream_stat_path(pathto, &ssb) < 0) { - ret = php_stream_mkdir(pathto, 0777, PHP_STREAM_MKDIR_RECURSIVE, NULL); - if (!ret) { - efree(pathto); - RETURN_FALSE; - } - } + if (php_stream_stat_path(pathto, &ssb) < 0) { + ret = php_stream_mkdir(pathto, 0777, PHP_STREAM_MKDIR_RECURSIVE, NULL); + if (!ret) { + RETURN_FALSE; + } + } ZIP_FROM_OBJECT(intern, this); if (zval_files) { switch (Z_TYPE_P(zval_files)) { case IS_STRING: - file = Z_STRVAL_P(zval_files); - if (!php_zip_extract_file(intern, pathto, file, Z_STRLEN_P(zval_files) TSRMLS_CC)) { + if (!php_zip_extract_file(intern, pathto, Z_STRVAL_P(zval_files), Z_STRLEN_P(zval_files) TSRMLS_CC)) { RETURN_FALSE; } break; @@ -1745,8 +1742,7 @@ static ZIPARCHIVE_METHOD(extractTo) case IS_LONG: break; case IS_STRING: - file = Z_STRVAL_PP(zval_file); - if (!php_zip_extract_file(intern, pathto, file, Z_STRLEN_PP(zval_file) TSRMLS_CC)) { + if (!php_zip_extract_file(intern, pathto, Z_STRVAL_PP(zval_file), Z_STRLEN_PP(zval_file) TSRMLS_CC)) { RETURN_FALSE; } break; @@ -1760,22 +1756,21 @@ static ZIPARCHIVE_METHOD(extractTo) break; } } else { - /* Extract all files */ - int filecount = zip_get_num_files(intern); - - if (filecount == -1) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Illegal archive"); - RETURN_FALSE; - } - - for (i = 0; i < filecount; i++) { - file = (char*)zip_get_name(intern, i, ZIP_FL_UNCHANGED); - if (!php_zip_extract_file(intern, pathto, file, strlen(file) TSRMLS_CC)) { - RETURN_FALSE; - } - } - } + /* Extract all files */ + int filecount = zip_get_num_files(intern); + + if (filecount == -1) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Illegal archive"); + RETURN_FALSE; + } + for (i = 0; i < filecount; i++) { + char *file = (char*)zip_get_name(intern, i, ZIP_FL_UNCHANGED); + if (!php_zip_extract_file(intern, pathto, file, strlen(file) TSRMLS_CC)) { + RETURN_FALSE; + } + } + } RETURN_TRUE; } /* }}} */ |