diff options
Diffstat (limited to 'ext/phar/phar_object.c')
-rw-r--r-- | ext/phar/phar_object.c | 56 |
1 files changed, 21 insertions, 35 deletions
diff --git a/ext/phar/phar_object.c b/ext/phar/phar_object.c index 5fe9e26af0..f67855af18 100644 --- a/ext/phar/phar_object.c +++ b/ext/phar/phar_object.c @@ -247,13 +247,12 @@ static int phar_file_action(phar_archive_data *phar, phar_entry_info *info, char if (!new_op_array) { zend_hash_str_del(&EG(included_files), name, name_len); } - - zend_destroy_file_handle(&file_handle); - } else { efree(name); new_op_array = NULL; } + + zend_destroy_file_handle(&file_handle); #ifdef PHP_WIN32 efree(arch); #endif @@ -395,7 +394,7 @@ PHP_METHOD(Phar, running) { char *fname, *arch, *entry; size_t fname_len, arch_len, entry_len; - zend_bool retphar = 1; + bool retphar = 1; if (zend_parse_parameters(ZEND_NUM_ARGS(), "|b", &retphar) == FAILURE) { RETURN_THROWS(); @@ -1049,7 +1048,7 @@ PHP_METHOD(Phar, isValidPharFilename) size_t fname_len; size_t ext_len; int is_executable; - zend_bool executable = 1; + bool executable = 1; if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|b", &fname, &fname_len, &executable) == FAILURE) { RETURN_THROWS(); @@ -1106,7 +1105,7 @@ PHP_METHOD(Phar, __construct) char *fname, *alias = NULL, *error, *arch = NULL, *entry = NULL, *save_fname; size_t fname_len, alias_len = 0; size_t arch_len, entry_len; - zend_bool is_data; + bool is_data; zend_long flags = SPL_FILE_DIR_SKIPDOTS|SPL_FILE_DIR_UNIXPATHS; zend_long format = 0; phar_archive_object *phar_obj; @@ -1376,7 +1375,7 @@ struct _phar_t { static int phar_build(zend_object_iterator *iter, void *puser) /* {{{ */ { zval *value; - zend_bool close_fp = 1; + bool close_fp = 1; struct _phar_t *p_obj = (struct _phar_t*) puser; size_t str_key_len, base_len = p_obj->l; phar_entry_data *data; @@ -1443,7 +1442,6 @@ static int phar_build(zend_object_iterator *iter, void *puser) /* {{{ */ case IS_OBJECT: if (instanceof_function(Z_OBJCE_P(value), spl_ce_SplFileInfo)) { char *test = NULL; - zval dummy; spl_filesystem_object *intern = (spl_filesystem_object*)((char*)Z_OBJ_P(value) - Z_OBJ_P(value)->handlers->offset); if (!base_len) { @@ -1455,9 +1453,7 @@ static int phar_build(zend_object_iterator *iter, void *puser) /* {{{ */ case SPL_FS_DIR: test = spl_filesystem_object_get_path(intern, NULL); fname_len = spprintf(&fname, 0, "%s%c%s", test, DEFAULT_SLASH, intern->u.dir.entry.d_name); - php_stat(fname, fname_len, FS_IS_DIR, &dummy); - - if (Z_TYPE(dummy) == IS_TRUE) { + if (php_stream_stat_path(fname, &ssb) == 0 && S_ISDIR(ssb.sb.st_mode)) { /* ignore directories */ efree(fname); return ZEND_HASH_APPLY_KEEP; @@ -1478,7 +1474,7 @@ static int phar_build(zend_object_iterator *iter, void *puser) /* {{{ */ goto phar_spl_fileinfo; case SPL_FS_INFO: case SPL_FS_FILE: - fname = expand_filepath(intern->file_name, NULL); + fname = expand_filepath(ZSTR_VAL(intern->file_name), NULL); if (!fname) { zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0, "Could not resolve file path"); return ZEND_HASH_APPLY_STOP; @@ -1698,7 +1694,7 @@ PHP_METHOD(Phar, buildFromDirectory) { char *dir, *error, *regex = NULL; size_t dir_len, regex_len = 0; - zend_bool apply_reg = 0; + bool apply_reg = 0; zval arg, arg2, iter, iteriter, regexiter; struct _phar_t pass; @@ -2341,7 +2337,7 @@ PHP_METHOD(Phar, convertToExecutable) uint32_t flags; zend_object *ret; zend_long format, method; - zend_bool format_is_null = 1, method_is_null = 1; + bool format_is_null = 1, method_is_null = 1; if (zend_parse_parameters(ZEND_NUM_ARGS(), "|l!l!s!", &format, &format_is_null, &method, &method_is_null, &ext, &ext_len) == FAILURE) { RETURN_THROWS(); @@ -2452,7 +2448,7 @@ PHP_METHOD(Phar, convertToData) uint32_t flags; zend_object *ret; zend_long format, method; - zend_bool format_is_null = 1, method_is_null = 1; + bool format_is_null = 1, method_is_null = 1; if (zend_parse_parameters(ZEND_NUM_ARGS(), "|l!l!s!", &format, &format_is_null, &method, &method_is_null, &ext, &ext_len) == FAILURE) { RETURN_THROWS(); @@ -4097,7 +4093,7 @@ PHP_METHOD(Phar, delMetadata) } /* }}} */ -static int phar_extract_file(zend_bool overwrite, phar_entry_info *entry, char *dest, size_t dest_len, char **error) /* {{{ */ +static int phar_extract_file(bool overwrite, phar_entry_info *entry, char *dest, size_t dest_len, char **error) /* {{{ */ { php_stream_statbuf ssb; size_t len; @@ -4279,7 +4275,7 @@ static int phar_extract_file(zend_bool overwrite, phar_entry_info *entry, char * } /* }}} */ -static int extract_helper(phar_archive_data *archive, zend_string *search, char *pathto, size_t pathto_len, zend_bool overwrite, char **error) { /* {{{ */ +static int extract_helper(phar_archive_data *archive, zend_string *search, char *pathto, size_t pathto_len, bool overwrite, char **error) { /* {{{ */ int extracted = 0; phar_entry_info *entry; @@ -4319,7 +4315,7 @@ PHP_METHOD(Phar, extractTo) int ret; zval *zval_file; HashTable *files_ht = NULL; - zend_bool overwrite = 0; + bool overwrite = 0; char *error = NULL; ZEND_PARSE_PARAMETERS_START(1, 3) @@ -4524,7 +4520,7 @@ PHP_METHOD(PharFileInfo, getCompressedSize) PHP_METHOD(PharFileInfo, isCompressed) { zend_long method; - zend_bool method_is_null = 1; + bool method_is_null = 1; if (zend_parse_parameters(ZEND_NUM_ARGS(), "|l!", &method, &method_is_null) == FAILURE) { RETURN_THROWS(); @@ -4644,11 +4640,11 @@ PHP_METHOD(PharFileInfo, chmod) /* hackish cache in php_stat needs to be cleared */ /* if this code fails to work, check main/streams/streams.c, _php_stream_stat_path */ if (BG(CurrentLStatFile)) { - efree(BG(CurrentLStatFile)); + zend_string_release(BG(CurrentLStatFile)); } if (BG(CurrentStatFile)) { - efree(BG(CurrentStatFile)); + zend_string_release(BG(CurrentStatFile)); } BG(CurrentLStatFile) = NULL; @@ -5074,23 +5070,13 @@ PHP_METHOD(PharFileInfo, decompress) void phar_object_init(void) /* {{{ */ { - zend_class_entry ce; - - INIT_CLASS_ENTRY(ce, "PharException", class_PharException_methods); - phar_ce_PharException = zend_register_internal_class_ex(&ce, zend_ce_exception); - - INIT_CLASS_ENTRY(ce, "Phar", class_Phar_methods); - phar_ce_archive = zend_register_internal_class_ex(&ce, spl_ce_RecursiveDirectoryIterator); - - zend_class_implements(phar_ce_archive, 2, zend_ce_countable, zend_ce_arrayaccess); + phar_ce_PharException = register_class_PharException(zend_ce_exception); - INIT_CLASS_ENTRY(ce, "PharData", class_PharData_methods); - phar_ce_data = zend_register_internal_class_ex(&ce, spl_ce_RecursiveDirectoryIterator); + phar_ce_archive = register_class_Phar(spl_ce_RecursiveDirectoryIterator, zend_ce_countable, zend_ce_arrayaccess); - zend_class_implements(phar_ce_data, 2, zend_ce_countable, zend_ce_arrayaccess); + phar_ce_data = register_class_PharData(spl_ce_RecursiveDirectoryIterator, zend_ce_countable, zend_ce_arrayaccess); - INIT_CLASS_ENTRY(ce, "PharFileInfo", class_PharFileInfo_methods); - phar_ce_entry = zend_register_internal_class_ex(&ce, spl_ce_SplFileInfo); + phar_ce_entry = register_class_PharFileInfo(spl_ce_SplFileInfo); 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) |