diff options
Diffstat (limited to 'ext/phar/phar_object.c')
| -rw-r--r-- | ext/phar/phar_object.c | 121 |
1 files changed, 8 insertions, 113 deletions
diff --git a/ext/phar/phar_object.c b/ext/phar/phar_object.c index 22404dddbc..249fbff4de 100644 --- a/ext/phar/phar_object.c +++ b/ext/phar/phar_object.c @@ -25,16 +25,7 @@ static zend_class_entry *phar_ce_archive; static zend_class_entry *phar_ce_data; static zend_class_entry *phar_ce_PharException; - -#if HAVE_SPL static zend_class_entry *phar_ce_entry; -#endif - -#if PHP_VERSION_ID >= 50300 -# define PHAR_ARG_INFO -#else -# define PHAR_ARG_INFO static -#endif static int phar_file_type(HashTable *mimes, char *file, char **mime_type) /* {{{ */ { @@ -1071,7 +1062,6 @@ PHP_METHOD(Phar, isValidPharFilename) } /* }}} */ -#if HAVE_SPL /** * from spl_directory */ @@ -1104,7 +1094,6 @@ static spl_other_handler phar_spl_foreign_handler = { phar_spl_foreign_dtor, phar_spl_foreign_clone }; -#endif /* HAVE_SPL */ /* {{{ proto void Phar::__construct(string fname [, int flags [, string alias]]) * Construct a Phar archive object @@ -1117,9 +1106,6 @@ static spl_other_handler phar_spl_foreign_handler = { */ PHP_METHOD(Phar, __construct) { -#if !HAVE_SPL - zend_throw_exception_ex(zend_ce_exception, 0, "Cannot instantiate Phar object without SPL extension"); -#else char *fname, *alias = NULL, *error, *arch = NULL, *entry = NULL, *save_fname; size_t fname_len, alias_len = 0; int arch_len, entry_len, is_data; @@ -1244,7 +1230,6 @@ PHP_METHOD(Phar, __construct) phar_obj->spl.info_class = phar_ce_entry; efree(fname); -#endif /* HAVE_SPL */ } /* }}} */ @@ -1363,8 +1348,6 @@ PHP_METHOD(Phar, unlinkArchive) } /* }}} */ -#if HAVE_SPL - #define PHAR_ARCHIVE_OBJECT() \ zval *zobj = getThis(); \ phar_archive_object *phar_obj = (phar_archive_object*)((char*)Z_OBJ_P(zobj) - Z_OBJ_P(zobj)->handlers->offset); \ @@ -1588,21 +1571,6 @@ phar_spl_fileinfo: return ZEND_HASH_APPLY_STOP; } } -#if PHP_API_VERSION < 20100412 - if (PG(safe_mode) && (!php_checkuid(fname, NULL, CHECKUID_ALLOW_ONLY_FILE))) { - zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0, "Iterator %v returned a path \"%s\" that safe mode prevents opening", ZSTR_VAL(ce->name), fname); - - if (save) { - efree(save); - } - - if (temp) { - efree(temp); - } - - return ZEND_HASH_APPLY_STOP; - } -#endif if (php_check_open_basedir(fname)) { zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0, "Iterator %v returned a path \"%s\" that open_basedir prevents opening", ZSTR_VAL(ce->name), fname); @@ -2196,7 +2164,7 @@ its_ok: } /* }}} */ -static zend_object *phar_convert_to_other(phar_archive_data *source, int convert, char *ext, php_uint32 flags) /* {{{ */ +static zend_object *phar_convert_to_other(phar_archive_data *source, int convert, char *ext, uint32_t flags) /* {{{ */ { phar_archive_data *phar; phar_entry_info *entry, newentry; @@ -2320,7 +2288,7 @@ PHP_METHOD(Phar, convertToExecutable) char *ext = NULL; int is_data; size_t ext_len = 0; - php_uint32 flags; + uint32_t flags; zend_object *ret; /* a number that is not 0, 1 or 2 (Which is also Greg's birthday, so there) */ zend_long format = 9021976, method = 9021976; @@ -2424,7 +2392,7 @@ PHP_METHOD(Phar, convertToData) char *ext = NULL; int is_data; size_t ext_len = 0; - php_uint32 flags; + uint32_t flags; zend_object *ret; /* a number that is not 0, 1 or 2 (Which is also Greg's birthday so there) */ zend_long format = 9021976, method = 9021976; @@ -3098,7 +3066,7 @@ PHP_METHOD(Phar, getModified) static int phar_set_compression(zval *zv, void *argument) /* {{{ */ { phar_entry_info *entry = (phar_entry_info *)Z_PTR_P(zv); - php_uint32 compress = *(php_uint32 *)argument; + uint32_t compress = *(uint32_t *)argument; if (entry->is_deleted) { return ZEND_HASH_APPLY_KEEP; @@ -3136,7 +3104,7 @@ static int phar_test_compression(zval *zv, void *argument) /* {{{ */ } /* }}} */ -static void pharobj_set_compression(HashTable *manifest, php_uint32 compress) /* {{{ */ +static void pharobj_set_compression(HashTable *manifest, uint32_t compress) /* {{{ */ { zend_hash_apply_with_argument(manifest, phar_set_compression, &compress); } @@ -3162,7 +3130,7 @@ PHP_METHOD(Phar, compress) zend_long method; char *ext = NULL; size_t ext_len = 0; - php_uint32 flags; + uint32_t flags; zend_object *ret; PHAR_ARCHIVE_OBJECT(); @@ -3271,7 +3239,7 @@ PHP_METHOD(Phar, decompress) PHP_METHOD(Phar, compressFiles) { char *error; - php_uint32 flags; + uint32_t flags; zend_long method; PHAR_ARCHIVE_OBJECT(); @@ -3800,13 +3768,6 @@ PHP_METHOD(Phar, addFile) return; } -#if PHP_API_VERSION < 20100412 - if (PG(safe_mode) && (!php_checkuid(fname, NULL, CHECKUID_ALLOW_ONLY_FILE))) { - zend_throw_exception_ex(spl_ce_RuntimeException, 0, "phar error: unable to open file \"%s\" to add to phar archive, safe_mode restrictions prevent this", fname); - return; - } -#endif - if (!strstr(fname, "://") && php_check_open_basedir(fname)) { zend_throw_exception_ex(spl_ce_RuntimeException, 0, "phar error: unable to open file \"%s\" to add to phar archive, open_basedir restrictions prevent this", fname); return; @@ -4052,13 +4013,6 @@ PHP_METHOD(Phar, delMetadata) } } /* }}} */ -#if PHP_API_VERSION < 20100412 -#define PHAR_OPENBASEDIR_CHECKPATH(filename) \ - (PG(safe_mode) && (!php_checkuid(filename, NULL, CHECKUID_CHECK_FILE_AND_DIR))) || php_check_open_basedir(filename) -#else -#define PHAR_OPENBASEDIR_CHECKPATH(filename) \ - php_check_open_basedir(filename) -#endif static int phar_extract_file(zend_bool overwrite, phar_entry_info *entry, char *dest, int dest_len, char **error) /* {{{ */ { @@ -4137,7 +4091,7 @@ static int phar_extract_file(zend_bool overwrite, phar_entry_info *entry, char * return FAILURE; } - if (PHAR_OPENBASEDIR_CHECKPATH(fullpath)) { + if (php_check_open_basedir(fullpath)) { spprintf(error, 4096, "Cannot extract \"%s\" to \"%s\", openbasedir/safe mode restrictions in effect", entry->filename, fullpath); efree(fullpath); efree(new_state.cwd); @@ -4193,11 +4147,7 @@ static int phar_extract_file(zend_bool overwrite, phar_entry_info *entry, char * return SUCCESS; } -#if PHP_API_VERSION < 20100412 - fp = php_stream_open_wrapper(fullpath, "w+b", REPORT_ERRORS|ENFORCE_SAFE_MODE, NULL); -#else fp = php_stream_open_wrapper(fullpath, "w+b", REPORT_ERRORS, NULL); -#endif if (!fp) { spprintf(error, 4096, "Cannot extract \"%s\", could not open for writing \"%s\"", entry->filename, fullpath); @@ -5043,10 +4993,7 @@ PHP_METHOD(PharFileInfo, decompress) } /* }}} */ -#endif /* HAVE_SPL */ - /* {{{ phar methods */ -PHAR_ARG_INFO ZEND_BEGIN_ARG_INFO_EX(arginfo_phar___construct, 0, 0, 1) ZEND_ARG_INFO(0, filename) ZEND_ARG_INFO(0, flags) @@ -5054,47 +5001,39 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_phar___construct, 0, 0, 1) ZEND_ARG_INFO(0, fileformat) ZEND_END_ARG_INFO() -PHAR_ARG_INFO ZEND_BEGIN_ARG_INFO_EX(arginfo_phar_createDS, 0, 0, 0) ZEND_ARG_INFO(0, index) ZEND_ARG_INFO(0, webindex) 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) ZEND_END_ARG_INFO() -PHAR_ARG_INFO ZEND_BEGIN_ARG_INFO_EX(arginfo_phar_mapPhar, 0, 0, 0) ZEND_ARG_INFO(0, alias) ZEND_ARG_INFO(0, offset) ZEND_END_ARG_INFO() -PHAR_ARG_INFO ZEND_BEGIN_ARG_INFO_EX(arginfo_phar_mount, 0, 0, 2) ZEND_ARG_INFO(0, inphar) ZEND_ARG_INFO(0, externalfile) ZEND_END_ARG_INFO() -PHAR_ARG_INFO ZEND_BEGIN_ARG_INFO_EX(arginfo_phar_mungServer, 0, 0, 1) ZEND_ARG_INFO(0, munglist) ZEND_END_ARG_INFO() -PHAR_ARG_INFO ZEND_BEGIN_ARG_INFO_EX(arginfo_phar_webPhar, 0, 0, 0) ZEND_ARG_INFO(0, alias) ZEND_ARG_INFO(0, index) @@ -5103,141 +5042,112 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_phar_webPhar, 0, 0, 0) ZEND_ARG_INFO(0, rewrites) ZEND_END_ARG_INFO() -PHAR_ARG_INFO ZEND_BEGIN_ARG_INFO_EX(arginfo_phar_running, 0, 0, 1) ZEND_ARG_INFO(0, retphar) ZEND_END_ARG_INFO() -PHAR_ARG_INFO ZEND_BEGIN_ARG_INFO_EX(arginfo_phar_ua, 0, 0, 1) ZEND_ARG_INFO(0, archive) ZEND_END_ARG_INFO() -#if HAVE_SPL -PHAR_ARG_INFO ZEND_BEGIN_ARG_INFO_EX(arginfo_phar_build, 0, 0, 1) ZEND_ARG_INFO(0, iterator) ZEND_ARG_INFO(0, base_directory) ZEND_END_ARG_INFO() -PHAR_ARG_INFO ZEND_BEGIN_ARG_INFO_EX(arginfo_phar_conv, 0, 0, 0) ZEND_ARG_INFO(0, format) ZEND_ARG_INFO(0, compression_type) ZEND_ARG_INFO(0, file_ext) ZEND_END_ARG_INFO() -PHAR_ARG_INFO ZEND_BEGIN_ARG_INFO_EX(arginfo_phar_comps, 0, 0, 1) ZEND_ARG_INFO(0, compression_type) ZEND_ARG_INFO(0, file_ext) ZEND_END_ARG_INFO() -PHAR_ARG_INFO ZEND_BEGIN_ARG_INFO_EX(arginfo_phar_decomp, 0, 0, 0) ZEND_ARG_INFO(0, file_ext) ZEND_END_ARG_INFO() -PHAR_ARG_INFO ZEND_BEGIN_ARG_INFO_EX(arginfo_phar_comp, 0, 0, 1) ZEND_ARG_INFO(0, compression_type) ZEND_END_ARG_INFO() -PHAR_ARG_INFO ZEND_BEGIN_ARG_INFO_EX(arginfo_phar_compo, 0, 0, 0) ZEND_ARG_INFO(0, compression_type) ZEND_END_ARG_INFO() -PHAR_ARG_INFO ZEND_BEGIN_ARG_INFO_EX(arginfo_phar_copy, 0, 0, 2) ZEND_ARG_INFO(0, newfile) ZEND_ARG_INFO(0, oldfile) ZEND_END_ARG_INFO() -PHAR_ARG_INFO ZEND_BEGIN_ARG_INFO_EX(arginfo_phar_delete, 0, 0, 1) ZEND_ARG_INFO(0, entry) ZEND_END_ARG_INFO() -PHAR_ARG_INFO ZEND_BEGIN_ARG_INFO_EX(arginfo_phar_fromdir, 0, 0, 1) ZEND_ARG_INFO(0, base_dir) ZEND_ARG_INFO(0, regex) ZEND_END_ARG_INFO() -PHAR_ARG_INFO ZEND_BEGIN_ARG_INFO_EX(arginfo_phar_offsetExists, 0, 0, 1) ZEND_ARG_INFO(0, entry) ZEND_END_ARG_INFO() -PHAR_ARG_INFO ZEND_BEGIN_ARG_INFO_EX(arginfo_phar_offsetSet, 0, 0, 2) ZEND_ARG_INFO(0, entry) ZEND_ARG_INFO(0, value) ZEND_END_ARG_INFO() -PHAR_ARG_INFO ZEND_BEGIN_ARG_INFO_EX(arginfo_phar_setAlias, 0, 0, 1) ZEND_ARG_INFO(0, alias) ZEND_END_ARG_INFO() -PHAR_ARG_INFO ZEND_BEGIN_ARG_INFO_EX(arginfo_phar_setMetadata, 0, 0, 1) ZEND_ARG_INFO(0, metadata) ZEND_END_ARG_INFO() -PHAR_ARG_INFO ZEND_BEGIN_ARG_INFO_EX(arginfo_phar_setSigAlgo, 0, 0, 1) ZEND_ARG_INFO(0, algorithm) ZEND_ARG_INFO(0, privatekey) ZEND_END_ARG_INFO() -PHAR_ARG_INFO ZEND_BEGIN_ARG_INFO_EX(arginfo_phar_setStub, 0, 0, 1) ZEND_ARG_INFO(0, newstub) ZEND_ARG_INFO(0, maxlen) ZEND_END_ARG_INFO() -PHAR_ARG_INFO ZEND_BEGIN_ARG_INFO_EX(arginfo_phar_emptydir, 0, 0, 0) ZEND_ARG_INFO(0, dirname) ZEND_END_ARG_INFO() -PHAR_ARG_INFO ZEND_BEGIN_ARG_INFO_EX(arginfo_phar_extract, 0, 0, 1) ZEND_ARG_INFO(0, pathto) ZEND_ARG_INFO(0, files) ZEND_ARG_INFO(0, overwrite) ZEND_END_ARG_INFO() -PHAR_ARG_INFO ZEND_BEGIN_ARG_INFO_EX(arginfo_phar_addfile, 0, 0, 1) ZEND_ARG_INFO(0, filename) ZEND_ARG_INFO(0, localname) ZEND_END_ARG_INFO() -PHAR_ARG_INFO ZEND_BEGIN_ARG_INFO_EX(arginfo_phar_fromstring, 0, 0, 1) ZEND_ARG_INFO(0, localname) ZEND_ARG_INFO(0, contents) ZEND_END_ARG_INFO() -PHAR_ARG_INFO 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[] = { -#if !HAVE_SPL - 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, arginfo_phar__void, ZEND_ACC_PUBLIC) PHP_ME(Phar, addEmptyDir, arginfo_phar_emptydir, ZEND_ACC_PUBLIC) @@ -5279,7 +5189,6 @@ zend_function_entry php_archive_methods[] = { PHP_ME(Phar, setStub, arginfo_phar_setStub, 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, 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) @@ -5299,13 +5208,10 @@ zend_function_entry php_archive_methods[] = { PHP_FE_END }; -#if HAVE_SPL -PHAR_ARG_INFO ZEND_BEGIN_ARG_INFO_EX(arginfo_entry___construct, 0, 0, 1) ZEND_ARG_INFO(0, filename) ZEND_END_ARG_INFO() -PHAR_ARG_INFO ZEND_BEGIN_ARG_INFO_EX(arginfo_entry_chmod, 0, 0, 1) ZEND_ARG_INFO(0, perms) ZEND_END_ARG_INFO() @@ -5328,7 +5234,6 @@ zend_function_entry php_entry_methods[] = { PHP_ME(PharFileInfo, setMetadata, arginfo_phar_setMetadata, ZEND_ACC_PUBLIC) PHP_FE_END }; -#endif /* HAVE_SPL */ zend_function_entry phar_exception_methods[] = { PHP_FE_END @@ -5345,7 +5250,6 @@ void phar_object_init(void) /* {{{ */ INIT_CLASS_ENTRY(ce, "PharException", phar_exception_methods); phar_ce_PharException = zend_register_internal_class_ex(&ce, zend_ce_exception); -#if HAVE_SPL INIT_CLASS_ENTRY(ce, "Phar", php_archive_methods); phar_ce_archive = zend_register_internal_class_ex(&ce, spl_ce_RecursiveDirectoryIterator); @@ -5358,15 +5262,6 @@ void phar_object_init(void) /* {{{ */ INIT_CLASS_ENTRY(ce, "PharFileInfo", php_entry_methods); phar_ce_entry = zend_register_internal_class_ex(&ce, spl_ce_SplFileInfo); -#else - INIT_CLASS_ENTRY(ce, "Phar", php_archive_methods); - phar_ce_archive = zend_register_internal_class(&ce); - phar_ce_archive->ce_flags |= ZEND_ACC_FINAL; - - INIT_CLASS_ENTRY(ce, "PharData", php_archive_methods); - phar_ce_data = zend_register_internal_class(&ce); - phar_ce_data->ce_flags |= ZEND_ACC_FINAL; -#endif REGISTER_PHAR_CLASS_CONST_LONG(phar_ce_archive, "BZ2", PHAR_ENT_COMPRESSED_BZ2) REGISTER_PHAR_CLASS_CONST_LONG(phar_ce_archive, "GZ", PHAR_ENT_COMPRESSED_GZ) |
