diff options
Diffstat (limited to 'ext/phar')
| -rw-r--r-- | ext/phar/dirstream.c | 2 | ||||
| -rw-r--r-- | ext/phar/phar.c | 13 | ||||
| -rw-r--r-- | ext/phar/phar_object.c | 230 | ||||
| -rw-r--r-- | ext/phar/stream.c | 2 | ||||
| -rw-r--r-- | ext/phar/tests/bug52013.phpt | 5 | ||||
| -rw-r--r-- | ext/phar/tests/bug54395.phpt | 16 | ||||
| -rw-r--r-- | ext/phar/util.c | 7 | ||||
| -rw-r--r-- | ext/phar/zip.c | 3 |
8 files changed, 225 insertions, 53 deletions
diff --git a/ext/phar/dirstream.c b/ext/phar/dirstream.c index f0fe1be45..4b6fd586f 100644 --- a/ext/phar/dirstream.c +++ b/ext/phar/dirstream.c @@ -503,7 +503,7 @@ int phar_wrapper_mkdir(php_stream_wrapper *wrapper, char *url_from, int mode, in return 0; } - if ((e = phar_get_entry_info_dir(phar, resource->path + 1, strlen(resource->path + 1), 0, &error, 1 TSRMLS_CC))) { + if (phar_get_entry_info_dir(phar, resource->path + 1, strlen(resource->path + 1), 0, &error, 1 TSRMLS_CC)) { /* entry exists as a file */ php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar error: cannot create directory \"%s\" in phar \"%s\", file already exists", resource->path+1, resource->host); php_url_free(resource); diff --git a/ext/phar/phar.c b/ext/phar/phar.c index 2a69b59d6..46a8e34e1 100644 --- a/ext/phar/phar.c +++ b/ext/phar/phar.c @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: phar.c 307915 2011-02-01 14:01:00Z iliaa $ */ +/* $Id: phar.c 314419 2011-08-07 11:13:27Z laruence $ */ #define PHAR_MAIN 1 #include "phar_internal.h" @@ -667,7 +667,7 @@ static int phar_parse_pharfile(php_stream *fp, char *fname, int fname_len, char php_uint32 manifest_len, manifest_count, manifest_flags, manifest_index, tmp_len, sig_flags; php_uint16 manifest_ver; long offset; - int register_alias, sig_len, temp_alias = 0; + int sig_len, register_alias = 0, temp_alias = 0; char *signature = NULL; if (pphar) { @@ -3292,8 +3292,8 @@ ZEND_GET_MODULE(phar) * * Every user visible function must have an entry in phar_functions[]. */ -function_entry phar_functions[] = { - {NULL, NULL, NULL} /* Must be the last line in phar_functions[] */ +zend_function_entry phar_functions[] = { + PHP_FE_END }; /* }}}*/ @@ -3393,6 +3393,7 @@ static zend_op_array *phar_compile_file(zend_file_handle *file_handle, int type res = phar_orig_compile_file(file_handle, type TSRMLS_CC); } zend_catch { failed = 1; + res = NULL; } zend_end_try(); if (name) { @@ -3668,7 +3669,7 @@ PHP_MINFO_FUNCTION(phar) /* {{{ */ php_info_print_table_header(2, "Phar: PHP Archive support", "enabled"); php_info_print_table_row(2, "Phar EXT version", PHP_PHAR_VERSION); php_info_print_table_row(2, "Phar API version", PHP_PHAR_API_VERSION); - php_info_print_table_row(2, "SVN revision", "$Revision: 307915 $"); + php_info_print_table_row(2, "SVN revision", "$Revision: 314419 $"); php_info_print_table_row(2, "Phar-based phar archives", "enabled"); php_info_print_table_row(2, "Tar-based phar archives", "enabled"); php_info_print_table_row(2, "ZIP-based phar archives", "enabled"); @@ -3721,7 +3722,7 @@ static const zend_module_dep phar_deps[] = { #if HAVE_SPL ZEND_MOD_REQUIRED("spl") #endif - {NULL, NULL, NULL} + ZEND_MOD_END }; zend_module_entry phar_module_entry = { diff --git a/ext/phar/phar_object.c b/ext/phar/phar_object.c index e5ffe0887..f7dbc209c 100644 --- a/ext/phar/phar_object.c +++ b/ext/phar/phar_object.c @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: phar_object.c 309222 2011-03-14 14:12:42Z felipe $ */ +/* $Id: phar_object.c 314653 2011-08-09 14:11:56Z iliaa $ */ #include "phar_internal.h" #include "func_interceptors.h" @@ -628,7 +628,7 @@ carry_on: } return; - } else if (SUCCESS == zend_hash_find(&(PHAR_GLOBALS->phar_fname_map), fname, fname_len, (void **)&pphar)) { + } else if (PHAR_GLOBALS->phar_fname_map.arBuckets && SUCCESS == zend_hash_find(&(PHAR_GLOBALS->phar_fname_map), fname, fname_len, (void **)&pphar)) { goto carry_on; } else if (PHAR_G(manifest_cached) && SUCCESS == zend_hash_find(&cached_phars, fname, fname_len, (void **)&pphar)) { if (SUCCESS == phar_copy_on_write(pphar TSRMLS_CC)) { @@ -661,7 +661,7 @@ PHP_METHOD(Phar, webPhar) char *fname, *basename, *path_info, *mime_type = NULL, *entry, *pt; int fname_len, entry_len, code, index_php_len = 0, not_cgi; phar_archive_data *phar = NULL; - phar_entry_info *info; + phar_entry_info *info = NULL; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s!s!saz", &alias, &alias_len, &index_php, &index_php_len, &f404, &f404_len, &mimeoverride, &rewrite) == FAILURE) { return; @@ -888,7 +888,7 @@ PHP_METHOD(Phar, webPhar) zend_bailout(); } else { - char *tmp, sa; + char *tmp = NULL, sa = '\0'; sapi_header_line ctr = {0}; ctr.response_code = 301; ctr.line_len = sizeof("HTTP/1.1 301 Moved Permanently")+1; @@ -1073,6 +1073,9 @@ PHP_METHOD(Phar, mungServer) */ PHP_METHOD(Phar, interceptFileFuncs) { + if (zend_parse_parameters_none() == FAILURE) { + return; + } phar_intercept_functions(TSRMLS_C); } /* }}} */ @@ -1150,6 +1153,9 @@ PHP_METHOD(Phar, loadPhar) * Returns the api version */ PHP_METHOD(Phar, apiVersion) { + if (zend_parse_parameters_none() == FAILURE) { + return; + } RETURN_STRINGL(PHP_PHAR_API_VERSION, sizeof(PHP_PHAR_API_VERSION)-1, 1); } /* }}}*/ @@ -1192,6 +1198,9 @@ PHP_METHOD(Phar, canCompress) * Returns whether phar extension supports writing and creating phars */ PHP_METHOD(Phar, canWrite) { + if (zend_parse_parameters_none() == FAILURE) { + return; + } RETURN_BOOL(!PHAR_G(readonly)); } /* }}} */ @@ -1399,6 +1408,10 @@ PHP_METHOD(Phar, __construct) */ PHP_METHOD(Phar, getSupportedSignatures) { + if (zend_parse_parameters_none() == FAILURE) { + return; + } + array_init(return_value); add_next_index_stringl(return_value, "MD5", 3, 1); @@ -1422,6 +1435,10 @@ PHP_METHOD(Phar, getSupportedSignatures) */ PHP_METHOD(Phar, getSupportedCompression) { + if (zend_parse_parameters_none() == FAILURE) { + return; + } + array_init(return_value); phar_request_initialize(TSRMLS_C); @@ -1647,11 +1664,14 @@ static int phar_build(zend_object_iterator *iter, void *puser TSRMLS_DC) /* {{{ } test = expand_filepath(fname, NULL TSRMLS_CC); + efree(fname); if (test) { - efree(fname); fname = test; fname_len = strlen(fname); + } else { + zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC, "Could not resolve file path"); + return ZEND_HASH_APPLY_STOP; } save = fname; @@ -1677,6 +1697,11 @@ static int phar_build(zend_object_iterator *iter, void *puser TSRMLS_DC) /* {{{ #else fname = expand_filepath(intern->file_name, NULL TSRMLS_CC); #endif + if (!fname) { + zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC, "Could not resolve file path"); + return ZEND_HASH_APPLY_STOP; + } + fname_len = strlen(fname); save = fname; goto phar_spl_fileinfo; @@ -1694,6 +1719,14 @@ static int phar_build(zend_object_iterator *iter, void *puser TSRMLS_DC) /* {{{ phar_spl_fileinfo: if (base_len) { temp = expand_filepath(base, NULL TSRMLS_CC); + if (!temp) { + zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC, "Could not resolve file path"); + if (save) { + efree(save); + } + return ZEND_HASH_APPLY_STOP; + } + base = temp; base_len = strlen(base); @@ -2085,6 +2118,10 @@ PHP_METHOD(Phar, buildFromIterator) PHP_METHOD(Phar, count) { PHAR_ARCHIVE_OBJECT(); + + if (zend_parse_parameters_none() == FAILURE) { + return; + } RETURN_LONG(zend_hash_num_elements(&phar_obj->arc.archive->manifest)); } @@ -2707,6 +2744,10 @@ PHP_METHOD(Phar, convertToData) PHP_METHOD(Phar, isCompressed) { PHAR_ARCHIVE_OBJECT(); + + if (zend_parse_parameters_none() == FAILURE) { + return; + } if (phar_obj->arc.archive->flags & PHAR_FILE_COMPRESSED_GZ) { RETURN_LONG(PHAR_ENT_COMPRESSED_GZ); @@ -2727,6 +2768,10 @@ PHP_METHOD(Phar, isWritable) { php_stream_statbuf ssb; PHAR_ARCHIVE_OBJECT(); + + if (zend_parse_parameters_none() == FAILURE) { + return; + } if (!phar_obj->arc.archive->is_writeable) { RETURN_FALSE; @@ -2801,6 +2846,10 @@ PHP_METHOD(Phar, delete) PHP_METHOD(Phar, getAlias) { PHAR_ARCHIVE_OBJECT(); + + if (zend_parse_parameters_none() == FAILURE) { + return; + } if (phar_obj->arc.archive->alias && phar_obj->arc.archive->alias != phar_obj->arc.archive->fname) { RETURN_STRINGL(phar_obj->arc.archive->alias, phar_obj->arc.archive->alias_len, 1); @@ -2814,6 +2863,10 @@ PHP_METHOD(Phar, getAlias) PHP_METHOD(Phar, getPath) { PHAR_ARCHIVE_OBJECT(); + + if (zend_parse_parameters_none() == FAILURE) { + return; + } RETURN_STRINGL(phar_obj->arc.archive->fname, phar_obj->arc.archive->fname_len, 1); } @@ -2926,6 +2979,10 @@ valid_alias: PHP_METHOD(Phar, getVersion) { PHAR_ARCHIVE_OBJECT(); + + if (zend_parse_parameters_none() == FAILURE) { + return; + } RETURN_STRING(phar_obj->arc.archive->version, 1); } @@ -2937,6 +2994,10 @@ PHP_METHOD(Phar, getVersion) PHP_METHOD(Phar, startBuffering) { PHAR_ARCHIVE_OBJECT(); + + if (zend_parse_parameters_none() == FAILURE) { + return; + } phar_obj->arc.archive->donotflush = 1; } @@ -2948,6 +3009,10 @@ PHP_METHOD(Phar, startBuffering) PHP_METHOD(Phar, isBuffering) { PHAR_ARCHIVE_OBJECT(); + + if (zend_parse_parameters_none() == FAILURE) { + return; + } RETURN_BOOL(phar_obj->arc.archive->donotflush); } @@ -2961,6 +3026,10 @@ PHP_METHOD(Phar, stopBuffering) char *error; PHAR_ARCHIVE_OBJECT(); + + if (zend_parse_parameters_none() == FAILURE) { + return; + } if (PHAR_G(readonly) && !phar_obj->arc.archive->is_data) { zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC, @@ -3192,6 +3261,10 @@ PHP_METHOD(Phar, setSignatureAlgorithm) PHP_METHOD(Phar, getSignature) { PHAR_ARCHIVE_OBJECT(); + + if (zend_parse_parameters_none() == FAILURE) { + return; + } if (phar_obj->arc.archive->signature) { char *unknown; @@ -3232,6 +3305,10 @@ PHP_METHOD(Phar, getSignature) PHP_METHOD(Phar, getModified) { PHAR_ARCHIVE_OBJECT(); + + if (zend_parse_parameters_none() == FAILURE) { + return; + } RETURN_BOOL(phar_obj->arc.archive->is_modified); } @@ -3490,6 +3567,10 @@ PHP_METHOD(Phar, decompressFiles) { char *error; PHAR_ARCHIVE_OBJECT(); + + if (zend_parse_parameters_none() == FAILURE) { + return; + } if (PHAR_G(readonly) && !phar_obj->arc.archive->is_data) { zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, @@ -4007,6 +4088,10 @@ PHP_METHOD(Phar, getStub) phar_entry_info *stub; PHAR_ARCHIVE_OBJECT(); + + if (zend_parse_parameters_none() == FAILURE) { + return; + } if (phar_obj->arc.archive->is_tar || phar_obj->arc.archive->is_zip) { @@ -4014,7 +4099,10 @@ PHP_METHOD(Phar, getStub) if (phar_obj->arc.archive->fp && !phar_obj->arc.archive->is_brandnew && !(stub->flags & PHAR_ENT_COMPRESSION_MASK)) { fp = phar_obj->arc.archive->fp; } else { - fp = php_stream_open_wrapper(phar_obj->arc.archive->fname, "rb", 0, NULL); + if (!(fp = php_stream_open_wrapper(phar_obj->arc.archive->fname, "rb", 0, NULL))) { + zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC, "phar error: unable to open phar \"%s\"", phar_obj->arc.archive->fname); + return; + } if (stub->flags & PHAR_ENT_COMPRESSION_MASK) { char *filter_name; @@ -4103,6 +4191,10 @@ PHP_METHOD(Phar, hasMetadata) PHP_METHOD(Phar, getMetadata) { PHAR_ARCHIVE_OBJECT(); + + if (zend_parse_parameters_none() == FAILURE) { + return; + } if (phar_obj->arc.archive->metadata) { if (phar_obj->arc.archive->is_persistent) { @@ -4594,6 +4686,10 @@ PHP_METHOD(PharFileInfo, __destruct) PHP_METHOD(PharFileInfo, getCompressedSize) { PHAR_ENTRY_OBJECT(); + + if (zend_parse_parameters_none() == FAILURE) { + return; + } RETURN_LONG(entry_obj->ent.entry->compressed_filesize); } @@ -4632,6 +4728,10 @@ PHP_METHOD(PharFileInfo, isCompressed) PHP_METHOD(PharFileInfo, getCRC32) { PHAR_ENTRY_OBJECT(); + + if (zend_parse_parameters_none() == FAILURE) { + return; + } if (entry_obj->ent.entry->is_dir) { zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, \ @@ -4654,6 +4754,10 @@ PHP_METHOD(PharFileInfo, getCRC32) PHP_METHOD(PharFileInfo, isCRCChecked) { PHAR_ENTRY_OBJECT(); + + if (zend_parse_parameters_none() == FAILURE) { + return; + } RETURN_BOOL(entry_obj->ent.entry->is_crc_checked); } @@ -4665,6 +4769,10 @@ PHP_METHOD(PharFileInfo, isCRCChecked) PHP_METHOD(PharFileInfo, getPharFlags) { PHAR_ENTRY_OBJECT(); + + if (zend_parse_parameters_none() == FAILURE) { + return; + } RETURN_LONG(entry_obj->ent.entry->flags & ~(PHAR_ENT_PERM_MASK|PHAR_ENT_COMPRESSION_MASK)); } @@ -4739,6 +4847,10 @@ PHP_METHOD(PharFileInfo, chmod) PHP_METHOD(PharFileInfo, hasMetadata) { PHAR_ENTRY_OBJECT(); + + if (zend_parse_parameters_none() == FAILURE) { + return; + } RETURN_BOOL(entry_obj->ent.entry->metadata != NULL); } @@ -4750,6 +4862,10 @@ PHP_METHOD(PharFileInfo, hasMetadata) PHP_METHOD(PharFileInfo, getMetadata) { PHAR_ENTRY_OBJECT(); + + if (zend_parse_parameters_none() == FAILURE) { + return; + } if (entry_obj->ent.entry->metadata) { if (entry_obj->ent.entry->is_persistent) { @@ -4827,6 +4943,10 @@ PHP_METHOD(PharFileInfo, delMetadata) char *error; PHAR_ENTRY_OBJECT(); + + if (zend_parse_parameters_none() == FAILURE) { + return; + } if (PHAR_G(readonly) && !entry_obj->ent.entry->phar->is_data) { zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, "Write operations disabled by the php.ini setting phar.readonly"); @@ -4881,6 +5001,10 @@ PHP_METHOD(PharFileInfo, getContent) phar_entry_info *link; PHAR_ENTRY_OBJECT(); + + if (zend_parse_parameters_none() == FAILURE) { + return; + } if (entry_obj->ent.entry->is_dir) { zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, @@ -5055,6 +5179,10 @@ PHP_METHOD(PharFileInfo, decompress) { char *error; PHAR_ENTRY_OBJECT(); + + if (zend_parse_parameters_none() == FAILURE) { + return; + } if (entry_obj->ent.entry->is_dir) { zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, \ @@ -5140,6 +5268,17 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_phar_createDS, 0, 0, 0) ZEND_END_ARG_INFO() PHAR_ARG_INFO +ZEND_BEGIN_ARG_INFO_EX(arginfo_phar_cancompress, 0, 0, 0) + ZEND_ARG_INFO(0, method) +ZEND_END_ARG_INFO() + +PHAR_ARG_INFO +ZEND_BEGIN_ARG_INFO_EX(arginfo_phar_isvalidpharfilename, 0, 0, 1) + ZEND_ARG_INFO(0, filename) + ZEND_ARG_INFO(0, executable) +ZEND_END_ARG_INFO() + +PHAR_ARG_INFO ZEND_BEGIN_ARG_INFO_EX(arginfo_phar_loadPhar, 0, 0, 1) ZEND_ARG_INFO(0, filename) ZEND_ARG_INFO(0, alias) @@ -5295,6 +5434,11 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_phar_isff, 0, 0, 1) ZEND_ARG_INFO(0, fileformat) ZEND_END_ARG_INFO() +PHAR_ARG_INFO +ZEND_BEGIN_ARG_INFO(arginfo_phar__void, 0) +ZEND_END_ARG_INFO() + + #endif /* HAVE_SPL */ zend_function_entry php_archive_methods[] = { @@ -5302,35 +5446,35 @@ zend_function_entry php_archive_methods[] = { PHP_ME(Phar, __construct, arginfo_phar___construct, ZEND_ACC_PRIVATE) #else PHP_ME(Phar, __construct, arginfo_phar___construct, ZEND_ACC_PUBLIC) - PHP_ME(Phar, __destruct, NULL, ZEND_ACC_PUBLIC) + PHP_ME(Phar, __destruct, arginfo_phar__void, ZEND_ACC_PUBLIC) PHP_ME(Phar, addEmptyDir, arginfo_phar_emptydir, ZEND_ACC_PUBLIC) PHP_ME(Phar, addFile, arginfo_phar_addfile, ZEND_ACC_PUBLIC) PHP_ME(Phar, addFromString, arginfo_phar_fromstring, ZEND_ACC_PUBLIC) PHP_ME(Phar, buildFromDirectory, arginfo_phar_fromdir, ZEND_ACC_PUBLIC) PHP_ME(Phar, buildFromIterator, arginfo_phar_build, ZEND_ACC_PUBLIC) PHP_ME(Phar, compressFiles, arginfo_phar_comp, ZEND_ACC_PUBLIC) - PHP_ME(Phar, decompressFiles, NULL, ZEND_ACC_PUBLIC) + PHP_ME(Phar, decompressFiles, arginfo_phar__void, ZEND_ACC_PUBLIC) PHP_ME(Phar, compress, arginfo_phar_comps, ZEND_ACC_PUBLIC) PHP_ME(Phar, decompress, arginfo_phar_decomp, ZEND_ACC_PUBLIC) PHP_ME(Phar, convertToExecutable, arginfo_phar_conv, ZEND_ACC_PUBLIC) PHP_ME(Phar, convertToData, arginfo_phar_conv, ZEND_ACC_PUBLIC) PHP_ME(Phar, copy, arginfo_phar_copy, ZEND_ACC_PUBLIC) - PHP_ME(Phar, count, NULL, ZEND_ACC_PUBLIC) + PHP_ME(Phar, count, arginfo_phar__void, ZEND_ACC_PUBLIC) PHP_ME(Phar, delete, arginfo_phar_delete, ZEND_ACC_PUBLIC) - PHP_ME(Phar, delMetadata, NULL, ZEND_ACC_PUBLIC) + PHP_ME(Phar, delMetadata, arginfo_phar__void, ZEND_ACC_PUBLIC) PHP_ME(Phar, extractTo, arginfo_phar_extract, ZEND_ACC_PUBLIC) - PHP_ME(Phar, getAlias, NULL, ZEND_ACC_PUBLIC) - PHP_ME(Phar, getPath, NULL, ZEND_ACC_PUBLIC) - PHP_ME(Phar, getMetadata, NULL, ZEND_ACC_PUBLIC) - PHP_ME(Phar, getModified, NULL, ZEND_ACC_PUBLIC) - PHP_ME(Phar, getSignature, NULL, ZEND_ACC_PUBLIC) - PHP_ME(Phar, getStub, NULL, ZEND_ACC_PUBLIC) - PHP_ME(Phar, getVersion, NULL, ZEND_ACC_PUBLIC) - PHP_ME(Phar, hasMetadata, NULL, ZEND_ACC_PUBLIC) - PHP_ME(Phar, isBuffering, NULL, ZEND_ACC_PUBLIC) - PHP_ME(Phar, isCompressed, NULL, ZEND_ACC_PUBLIC) + PHP_ME(Phar, getAlias, arginfo_phar__void, ZEND_ACC_PUBLIC) + PHP_ME(Phar, getPath, arginfo_phar__void, ZEND_ACC_PUBLIC) + PHP_ME(Phar, getMetadata, arginfo_phar__void, ZEND_ACC_PUBLIC) + PHP_ME(Phar, getModified, arginfo_phar__void, ZEND_ACC_PUBLIC) + PHP_ME(Phar, getSignature, arginfo_phar__void, ZEND_ACC_PUBLIC) + PHP_ME(Phar, getStub, arginfo_phar__void, ZEND_ACC_PUBLIC) + PHP_ME(Phar, getVersion, arginfo_phar__void, ZEND_ACC_PUBLIC) + PHP_ME(Phar, hasMetadata, arginfo_phar__void, ZEND_ACC_PUBLIC) + PHP_ME(Phar, isBuffering, arginfo_phar__void, ZEND_ACC_PUBLIC) + PHP_ME(Phar, isCompressed, arginfo_phar__void, ZEND_ACC_PUBLIC) PHP_ME(Phar, isFileFormat, arginfo_phar_isff, ZEND_ACC_PUBLIC) - PHP_ME(Phar, isWritable, NULL, ZEND_ACC_PUBLIC) + PHP_ME(Phar, isWritable, arginfo_phar__void, ZEND_ACC_PUBLIC) PHP_ME(Phar, offsetExists, arginfo_phar_offsetExists, ZEND_ACC_PUBLIC) PHP_ME(Phar, offsetGet, arginfo_phar_offsetExists, ZEND_ACC_PUBLIC) PHP_ME(Phar, offsetSet, arginfo_phar_offsetSet, ZEND_ACC_PUBLIC) @@ -5340,18 +5484,18 @@ zend_function_entry php_archive_methods[] = { PHP_ME(Phar, setMetadata, arginfo_phar_setMetadata, ZEND_ACC_PUBLIC) PHP_ME(Phar, setSignatureAlgorithm, arginfo_phar_setSigAlgo, ZEND_ACC_PUBLIC) PHP_ME(Phar, setStub, arginfo_phar_setStub, ZEND_ACC_PUBLIC) - PHP_ME(Phar, startBuffering, NULL, ZEND_ACC_PUBLIC) - PHP_ME(Phar, stopBuffering, NULL, ZEND_ACC_PUBLIC) + PHP_ME(Phar, startBuffering, arginfo_phar__void, ZEND_ACC_PUBLIC) + PHP_ME(Phar, stopBuffering, arginfo_phar__void, ZEND_ACC_PUBLIC) #endif /* static member functions */ - PHP_ME(Phar, apiVersion, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC|ZEND_ACC_FINAL) - PHP_ME(Phar, canCompress, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC|ZEND_ACC_FINAL) - PHP_ME(Phar, canWrite, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC|ZEND_ACC_FINAL) + PHP_ME(Phar, apiVersion, arginfo_phar__void, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC|ZEND_ACC_FINAL) + PHP_ME(Phar, canCompress, arginfo_phar_cancompress, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC|ZEND_ACC_FINAL) + PHP_ME(Phar, canWrite, arginfo_phar__void, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC|ZEND_ACC_FINAL) PHP_ME(Phar, createDefaultStub, arginfo_phar_createDS, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC|ZEND_ACC_FINAL) - PHP_ME(Phar, getSupportedCompression,NULL, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC|ZEND_ACC_FINAL) - PHP_ME(Phar, getSupportedSignatures,NULL, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC|ZEND_ACC_FINAL) - PHP_ME(Phar, interceptFileFuncs, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC|ZEND_ACC_FINAL) - PHP_ME(Phar, isValidPharFilename, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC|ZEND_ACC_FINAL) + PHP_ME(Phar, getSupportedCompression,arginfo_phar__void, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC|ZEND_ACC_FINAL) + PHP_ME(Phar, getSupportedSignatures,arginfo_phar__void, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC|ZEND_ACC_FINAL) + PHP_ME(Phar, interceptFileFuncs, arginfo_phar__void, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC|ZEND_ACC_FINAL) + PHP_ME(Phar, isValidPharFilename, arginfo_phar_isvalidpharfilename, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC|ZEND_ACC_FINAL) PHP_ME(Phar, loadPhar, arginfo_phar_loadPhar, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC|ZEND_ACC_FINAL) PHP_ME(Phar, mapPhar, arginfo_phar_mapPhar, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC|ZEND_ACC_FINAL) PHP_ME(Phar, running, arginfo_phar_running, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC|ZEND_ACC_FINAL) @@ -5359,7 +5503,7 @@ zend_function_entry php_archive_methods[] = { PHP_ME(Phar, mungServer, arginfo_phar_mungServer, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC|ZEND_ACC_FINAL) PHP_ME(Phar, unlinkArchive, arginfo_phar_ua, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC|ZEND_ACC_FINAL) PHP_ME(Phar, webPhar, arginfo_phar_webPhar, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC|ZEND_ACC_FINAL) - {NULL, NULL, NULL} + PHP_FE_END }; #if HAVE_SPL @@ -5375,26 +5519,26 @@ ZEND_END_ARG_INFO() zend_function_entry php_entry_methods[] = { PHP_ME(PharFileInfo, __construct, arginfo_entry___construct, ZEND_ACC_PUBLIC) - PHP_ME(PharFileInfo, __destruct, NULL, ZEND_ACC_PUBLIC) + PHP_ME(PharFileInfo, __destruct, arginfo_phar__void, ZEND_ACC_PUBLIC) PHP_ME(PharFileInfo, chmod, arginfo_entry_chmod, ZEND_ACC_PUBLIC) PHP_ME(PharFileInfo, compress, arginfo_phar_comp, ZEND_ACC_PUBLIC) - PHP_ME(PharFileInfo, decompress, NULL, ZEND_ACC_PUBLIC) - PHP_ME(PharFileInfo, delMetadata, NULL, ZEND_ACC_PUBLIC) - PHP_ME(PharFileInfo, getCompressedSize, NULL, ZEND_ACC_PUBLIC) - PHP_ME(PharFileInfo, getCRC32, NULL, ZEND_ACC_PUBLIC) - PHP_ME(PharFileInfo, getContent, NULL, ZEND_ACC_PUBLIC) - PHP_ME(PharFileInfo, getMetadata, NULL, ZEND_ACC_PUBLIC) - PHP_ME(PharFileInfo, getPharFlags, NULL, ZEND_ACC_PUBLIC) - PHP_ME(PharFileInfo, hasMetadata, NULL, ZEND_ACC_PUBLIC) + PHP_ME(PharFileInfo, decompress, arginfo_phar__void, ZEND_ACC_PUBLIC) + PHP_ME(PharFileInfo, delMetadata, arginfo_phar__void, ZEND_ACC_PUBLIC) + PHP_ME(PharFileInfo, getCompressedSize, arginfo_phar__void, ZEND_ACC_PUBLIC) + PHP_ME(PharFileInfo, getCRC32, arginfo_phar__void, ZEND_ACC_PUBLIC) + PHP_ME(PharFileInfo, getContent, arginfo_phar__void, ZEND_ACC_PUBLIC) + PHP_ME(PharFileInfo, getMetadata, arginfo_phar__void, ZEND_ACC_PUBLIC) + PHP_ME(PharFileInfo, getPharFlags, arginfo_phar__void, ZEND_ACC_PUBLIC) + PHP_ME(PharFileInfo, hasMetadata, arginfo_phar__void, ZEND_ACC_PUBLIC) PHP_ME(PharFileInfo, isCompressed, arginfo_phar_compo, ZEND_ACC_PUBLIC) - PHP_ME(PharFileInfo, isCRCChecked, NULL, ZEND_ACC_PUBLIC) + PHP_ME(PharFileInfo, isCRCChecked, arginfo_phar__void, ZEND_ACC_PUBLIC) PHP_ME(PharFileInfo, setMetadata, arginfo_phar_setMetadata, ZEND_ACC_PUBLIC) - {NULL, NULL, NULL} + PHP_FE_END }; #endif /* HAVE_SPL */ zend_function_entry phar_exception_methods[] = { - {NULL, NULL, NULL} + PHP_FE_END }; /* }}} */ diff --git a/ext/phar/stream.c b/ext/phar/stream.c index f9bf3f3e0..cf2c53620 100644 --- a/ext/phar/stream.c +++ b/ext/phar/stream.c @@ -421,6 +421,8 @@ static int phar_stream_seek(php_stream *stream, off_t offset, int whence, off_t case SEEK_SET : temp = data->zero + offset; break; + default : + temp = 0; } if (temp > data->zero + (off_t) entry->uncompressed_filesize) { *newoffset = -1; diff --git a/ext/phar/tests/bug52013.phpt b/ext/phar/tests/bug52013.phpt index f4635a466..5ee37e7d4 100644 --- a/ext/phar/tests/bug52013.phpt +++ b/ext/phar/tests/bug52013.phpt @@ -6,7 +6,10 @@ http://bugs.php.net/bug.php?id=52013 --CREDITS-- Frederic Hardy frederic.hardy@mageekbox.net --SKIPIF-- -<?php if (!extension_loaded("phar")) die("skip"); ?> +<?php +if (!extension_loaded("phar")) die("skip"); +if (!extension_loaded("zlib")) die("skip test needs zlib extension enabled to compress archives with gzip"); +?> --INI-- phar.require_hash=0 phar.readonly=0 diff --git a/ext/phar/tests/bug54395.phpt b/ext/phar/tests/bug54395.phpt new file mode 100644 index 000000000..091ed326a --- /dev/null +++ b/ext/phar/tests/bug54395.phpt @@ -0,0 +1,16 @@ +--TEST-- +Bug #54395 (Phar::mount() crashes when calling with wrong parameters) +--SKIPIF-- +<?php if (!extension_loaded("phar")) die("skip"); ?> +--FILE-- +<?php + +try { + phar::mount(1,1); +} catch (Exception $e) { + var_dump($e->getMessage()); +} + +?> +--EXPECTF-- +string(25) "Mounting of 1 to 1 failed" diff --git a/ext/phar/util.c b/ext/phar/util.c index 9bc704d89..983ca38d1 100644 --- a/ext/phar/util.c +++ b/ext/phar/util.c @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: util.c 306941 2011-01-01 02:48:19Z felipe $ */ +/* $Id: util.c 314419 2011-08-07 11:13:27Z laruence $ */ #include "phar_internal.h" #ifdef PHAR_HASH_OK @@ -154,6 +154,9 @@ int phar_seek_efp(phar_entry_info *entry, off_t offset, int whence, off_t positi case SEEK_SET: temp = eoffset + offset; break; + default: + temp = 0; + break; } if (temp > eoffset + (off_t) entry->uncompressed_filesize) { @@ -1203,7 +1206,7 @@ int phar_get_archive(phar_archive_data **archive, char *fname, int fname_len, ch phar_archive_data *fd, **fd_ptr; char *my_realpath, *save; int save_len; - ulong fhash, ahash; + ulong fhash, ahash = 0; phar_request_initialize(TSRMLS_C); diff --git a/ext/phar/zip.c b/ext/phar/zip.c index fa3642f5c..a8ac63aeb 100644 --- a/ext/phar/zip.c +++ b/ext/phar/zip.c @@ -411,6 +411,9 @@ foundit: now = php_stream_tell(fp); pefree(entry.filename, entry.is_persistent); sigfile = php_stream_fopen_tmpfile(); + if (!sigfile) { + PHAR_ZIP_FAIL("couldn't open temporary file"); + } php_stream_seek(fp, 0, SEEK_SET); /* copy file contents + local headers and zip comment, if any, to be hashed for signature */ |
