diff --git a/ext/phar/dirstream.c b/ext/phar/dirstream.c index f37599e7db11..dccc803b2985 100644 --- a/ext/phar/dirstream.c +++ b/ext/phar/dirstream.c @@ -452,7 +452,8 @@ int phar_wrapper_mkdir(php_stream_wrapper *wrapper, const char *url_from, int mo return 0; } - phar_flush(phar, &error); + time_t now = time(NULL); + phar_flush(phar, now, &error); if (error) { php_stream_wrapper_log_error(wrapper, options, "phar error: cannot create directory \"%s\" in phar \"%s\", %s", ZSTR_VAL(entry.filename), phar->fname, error); @@ -573,7 +574,9 @@ int phar_wrapper_rmdir(php_stream_wrapper *wrapper, const char *url, int options } else { entry->is_deleted = 1; entry->is_modified = 1; - phar_flush(phar, &error); + // TODO: get timestamp from context? + time_t now = time(NULL); + phar_flush(phar, now, &error); if (error) { php_stream_wrapper_log_error(wrapper, options, "phar error: cannot remove directory \"%s\" in phar \"%s\", %s", ZSTR_VAL(entry->filename), phar->fname, error); diff --git a/ext/phar/phar.c b/ext/phar/phar.c index 23624ce6bcc7..6070b648c616 100644 --- a/ext/phar/phar.c +++ b/ext/phar/phar.c @@ -414,7 +414,7 @@ void phar_entry_delref(phar_entry_data *idata) /* {{{ */ /** * Removes an entry, either by actually removing it or by marking it. */ -ZEND_ATTRIBUTE_NONNULL void phar_entry_remove(phar_entry_data *idata, char **error) /* {{{ */ +ZEND_ATTRIBUTE_NONNULL void phar_entry_remove(phar_entry_data *idata, time_t timestamp, char **error) /* {{{ */ { phar_archive_data *phar; @@ -433,7 +433,7 @@ ZEND_ATTRIBUTE_NONNULL void phar_entry_remove(phar_entry_data *idata, char **err } if (!phar->donotflush) { - phar_flush(phar, error); + phar_flush(phar, timestamp, error); } } /* }}} */ @@ -1715,7 +1715,8 @@ static zend_result phar_open_from_fp(php_stream* fp, char *fname, size_t fname_l if (!memcmp(pos, zip_magic, 4)) { php_stream_seek(fp, 0, SEEK_END); - return phar_parse_zipfile(fp, fname, fname_len, alias, alias_len, pphar, error); + time_t now = time(NULL); + return phar_parse_zipfile(fp, fname, fname_len, alias, alias_len, pphar, now, error); } if (got >= 512) { @@ -2459,8 +2460,8 @@ zend_string *phar_create_default_stub(const zend_string *php_index_str, const ze } /* }}} */ -ZEND_ATTRIBUTE_NONNULL int phar_flush(phar_archive_data *phar, char **error) { - return phar_flush_ex(phar, NULL, false, error); +ZEND_ATTRIBUTE_NONNULL int phar_flush(phar_archive_data *phar, time_t timestamp, char **error) { + return phar_flush_ex(phar, NULL, false, timestamp, error); } /** @@ -2468,7 +2469,7 @@ ZEND_ATTRIBUTE_NONNULL int phar_flush(phar_archive_data *phar, char **error) { * * if user_stub is NULL the default or existing stub should be used */ -ZEND_ATTRIBUTE_NONNULL_ARGS(1, 4) int phar_flush_ex(phar_archive_data *phar, zend_string *user_stub, bool is_default_stub, char **error) /* {{{ */ +ZEND_ATTRIBUTE_NONNULL_ARGS(1, 5) int phar_flush_ex(phar_archive_data *phar, zend_string *user_stub, bool is_default_stub, time_t timestamp, char **error) /* {{{ */ { static const char halt_stub[] = "__HALT_COMPILER();"; @@ -2482,7 +2483,7 @@ ZEND_ATTRIBUTE_NONNULL_ARGS(1, 4) int phar_flush_ex(phar_archive_data *phar, zen zend_off_t manifest_ftell; zend_long offset; size_t wrote; - uint32_t manifest_len, mytime, new_manifest_count; + uint32_t manifest_len, new_manifest_count; uint32_t newcrc32; php_stream *file, *oldfile, *newfile; php_stream_filter *filter; @@ -2507,11 +2508,11 @@ ZEND_ATTRIBUTE_NONNULL_ARGS(1, 4) int phar_flush_ex(phar_archive_data *phar, zen zend_hash_clean(&phar->virtual_dirs); if (phar->is_zip) { - return phar_zip_flush(phar, user_stub, is_default_stub, error); + return phar_zip_flush(phar, user_stub, is_default_stub, timestamp, error); } if (phar->is_tar) { - return phar_tar_flush(phar, user_stub, is_default_stub, error); + return phar_tar_flush(phar, user_stub, is_default_stub, timestamp, error); } if (PHAR_G(readonly)) { @@ -2871,9 +2872,8 @@ ZEND_ATTRIBUTE_NONNULL_ARGS(1, 4) int phar_flush_ex(phar_archive_data *phar, zen 4: metadata-len +: metadata */ - mytime = time(NULL); phar_set_32(entry_buffer, entry->uncompressed_filesize); - phar_set_32(entry_buffer+4, mytime); + phar_set_32(entry_buffer+4, timestamp); phar_set_32(entry_buffer+8, entry->compressed_filesize); phar_set_32(entry_buffer+12, entry->crc32); phar_set_32(entry_buffer+16, entry->flags); diff --git a/ext/phar/phar_internal.h b/ext/phar/phar_internal.h index 46e45ec61b72..fc28250b699e 100644 --- a/ext/phar/phar_internal.h +++ b/ext/phar/phar_internal.h @@ -446,12 +446,12 @@ zend_result phar_copy_on_write(phar_archive_data **pphar); bool phar_is_tar(const char *buf, const char *fname); zend_result phar_parse_tarfile(php_stream* fp, char *fname, size_t fname_len, char *alias, size_t alias_len, phar_archive_data** pphar, uint32_t compression, char **error); ZEND_ATTRIBUTE_NONNULL_ARGS(1, 7, 8) zend_result phar_open_or_create_tar(char *fname, size_t fname_len, char *alias, size_t alias_len, bool is_data, uint32_t options, phar_archive_data** pphar, char **error); -ZEND_ATTRIBUTE_NONNULL_ARGS(1, 4) int phar_tar_flush(phar_archive_data *phar, zend_string *user_stub, bool is_default_stub, char **error); +ZEND_ATTRIBUTE_NONNULL_ARGS(1, 5) int phar_tar_flush(phar_archive_data *phar, zend_string *user_stub, bool is_default_stub, time_t timestamp, char **error); /* zip functions in zip.c */ -zend_result phar_parse_zipfile(php_stream *fp, char *fname, size_t fname_len, char *alias, size_t alias_len, phar_archive_data** pphar, char **error); +zend_result phar_parse_zipfile(php_stream *fp, char *fname, size_t fname_len, char *alias, size_t alias_len, phar_archive_data** pphar, time_t timestamp, char **error); ZEND_ATTRIBUTE_NONNULL_ARGS(1, 7, 8) zend_result phar_open_or_create_zip(char *fname, size_t fname_len, char *alias, size_t alias_len, bool is_data, uint32_t options, phar_archive_data** pphar, char **error); -ZEND_ATTRIBUTE_NONNULL_ARGS(1, 4) int phar_zip_flush(phar_archive_data *archive, zend_string *user_stub, bool is_default_stub, char **error); +ZEND_ATTRIBUTE_NONNULL_ARGS(1, 5) int phar_zip_flush(phar_archive_data *archive, zend_string *user_stub, bool is_default_stub, time_t timestamp, char **error); #ifdef PHAR_MAIN extern const php_stream_wrapper php_stream_phar_wrapper; @@ -465,10 +465,10 @@ void phar_entry_delref(phar_entry_data *idata); phar_entry_info *phar_get_entry_info(phar_archive_data *phar, char *path, size_t path_len, char **error, bool security); phar_entry_info *phar_get_entry_info_dir(phar_archive_data *phar, char *path, size_t path_len, char dir, char **error, bool security); -ZEND_ATTRIBUTE_NONNULL phar_entry_data *phar_get_or_create_entry_data(char *fname, size_t fname_len, char *path, size_t path_len, const char *mode, char allow_dir, char **error, bool security); +ZEND_ATTRIBUTE_NONNULL phar_entry_data *phar_get_or_create_entry_data(char *fname, size_t fname_len, char *path, size_t path_len, const char *mode, char allow_dir, time_t timestamp, char **error, bool security); ZEND_ATTRIBUTE_NONNULL zend_result phar_get_entry_data(phar_entry_data **ret, char *fname, size_t fname_len, char *path, size_t path_len, const char *mode, char allow_dir, char **error, bool security); -ZEND_ATTRIBUTE_NONNULL_ARGS(1, 4) int phar_flush_ex(phar_archive_data *archive, zend_string *user_stub, bool is_default_stub, char **error); -ZEND_ATTRIBUTE_NONNULL int phar_flush(phar_archive_data *archive, char **error); +ZEND_ATTRIBUTE_NONNULL_ARGS(1, 5) int phar_flush_ex(phar_archive_data *archive, zend_string *user_stub, bool is_default_stub, time_t timestamp, char **error); +ZEND_ATTRIBUTE_NONNULL int phar_flush(phar_archive_data *archive, time_t timestamp, char **error); zend_result phar_detect_phar_fname_ext(const char *filename, size_t filename_len, const char **ext_str, size_t *ext_len, int executable, int for_create, bool is_complete); zend_result phar_split_fname(const char *filename, size_t filename_len, char **arch, size_t *arch_len, char **entry, size_t *entry_len, int executable, int for_create); diff --git a/ext/phar/phar_object.c b/ext/phar/phar_object.c index acd9aa0cff65..33004d9076e0 100644 --- a/ext/phar/phar_object.c +++ b/ext/phar/phar_object.c @@ -1586,7 +1586,9 @@ static int phar_build(zend_object_iterator *iter, void *puser) /* {{{ */ return ZEND_HASH_APPLY_KEEP; } - if (!(data = phar_get_or_create_entry_data(phar_obj->archive->fname, phar_obj->archive->fname_len, str_key, str_key_len, "w+b", 0, &error, true))) { + // TODO: Get timestamp from puser data? + time_t timestamp = time(NULL); + if (!(data = phar_get_or_create_entry_data(phar_obj->archive->fname, phar_obj->archive->fname_len, str_key, str_key_len, "w+b", 0, timestamp, &error, true))) { zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Entry %s cannot be created: %s", str_key, error); efree(error); @@ -1744,7 +1746,9 @@ PHP_METHOD(Phar, buildFromDirectory) } phar_obj->archive->ufp = pass.fp; - phar_flush(phar_obj->archive, &error); + // TODO: Set to &pass; struct? + time_t now = time(NULL); + phar_flush(phar_obj->archive, now, &error); if (error) { zend_throw_exception_ex(phar_ce_PharException, 0, "%s", error); @@ -1809,7 +1813,9 @@ PHP_METHOD(Phar, buildFromIterator) if (SUCCESS == spl_iterator_apply(obj, (spl_iterator_apply_func_t) phar_build, (void *) &pass)) { phar_obj->archive->ufp = pass.fp; - phar_flush(phar_obj->archive, &error); + // TODO: Set to &pass; struct? + time_t now = time(NULL); + phar_flush(phar_obj->archive, now, &error); if (error) { zend_throw_exception_ex(phar_ce_PharException, 0, "%s", error); efree(error); @@ -2116,7 +2122,8 @@ static zend_object *phar_rename_archive(phar_archive_data **sphar, char *ext) /* goto err_oldpath; } - phar_flush_ex(phar, NULL, true, &error); + time_t now = time(NULL); + phar_flush_ex(phar, NULL, true, now, &error); if (error) { zend_hash_str_del(&(PHAR_G(phar_fname_map)), newpath, phar->fname_len); @@ -2574,7 +2581,8 @@ PHP_METHOD(Phar, delete) RETURN_THROWS(); } - phar_flush(phar_obj->archive, &error); + time_t now = time(NULL); + phar_flush(phar_obj->archive, now, &error); if (error) { zend_throw_exception_ex(phar_ce_PharException, 0, "%s", error); efree(error); @@ -2683,7 +2691,8 @@ PHP_METHOD(Phar, setAlias) } phar_obj->archive->is_temporary_alias = 0; - phar_flush(phar_obj->archive, &error); + time_t now = time(NULL); + phar_flush(phar_obj->archive, now, &error); if (error) { efree(phar_obj->archive->alias); @@ -2757,7 +2766,8 @@ PHP_METHOD(Phar, stopBuffering) } phar_obj->archive->donotflush = 0; - phar_flush(phar_obj->archive, &error); + time_t now = time(NULL); + phar_flush(phar_obj->archive, now, &error); if (error) { zend_throw_exception_ex(phar_ce_PharException, 0, "%s", error); @@ -2796,6 +2806,7 @@ PHP_METHOD(Phar, setStub) RETURN_THROWS(); } + time_t now = time(NULL); if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "r|l", &zstub, &len) == SUCCESS) { zend_string *method_name = get_active_function_or_method_name(); zend_error(E_DEPRECATED, "Calling %s(resource $stub, int $length) is deprecated", ZSTR_VAL(method_name)); @@ -2822,7 +2833,7 @@ PHP_METHOD(Phar, setStub) RETURN_THROWS(); } - phar_flush_ex(phar_obj->archive, stub_file_content, /* is_default_stub */ false, &error); + phar_flush_ex(phar_obj->archive, stub_file_content, /* is_default_stub */ false, now, &error); zend_string_release_ex(stub_file_content, false); if (error) { @@ -2839,7 +2850,7 @@ PHP_METHOD(Phar, setStub) zend_throw_exception_ex(phar_ce_PharException, 0, "phar \"%s\" is persistent, unable to copy on write", phar_obj->archive->fname); RETURN_THROWS(); } - phar_flush_ex(phar_obj->archive, stub, /* is_default_stub */ false, &error); + phar_flush_ex(phar_obj->archive, stub, /* is_default_stub */ false, now, &error); if (error) { zend_throw_exception_ex(phar_ce_PharException, 0, "%s", error); @@ -2920,7 +2931,9 @@ PHP_METHOD(Phar, setDefaultStub) zend_throw_exception_ex(phar_ce_PharException, 0, "phar \"%s\" is persistent, unable to copy on write", phar_obj->archive->fname); RETURN_THROWS(); } - phar_flush_ex(phar_obj->archive, stub, /* is_default_stub */ true, &error); + + time_t now = time(NULL); + phar_flush_ex(phar_obj->archive, stub, /* is_default_stub */ true, now, &error); if (created_stub) { zend_string_free(stub); @@ -2976,7 +2989,8 @@ PHP_METHOD(Phar, setSignatureAlgorithm) PHAR_G(openssl_privatekey) = key; PHAR_G(openssl_privatekey_len) = key_len; - phar_flush(phar_obj->archive, &error); + time_t now = time(NULL); + phar_flush(phar_obj->archive, now, &error); if (error) { zend_throw_exception_ex(phar_ce_PharException, 0, "%s", error); efree(error); @@ -3283,7 +3297,8 @@ PHP_METHOD(Phar, compressFiles) } pharobj_set_compression(&phar_obj->archive->manifest, flags); phar_obj->archive->is_modified = 1; - phar_flush(phar_obj->archive, &error); + time_t now = time(NULL); + phar_flush(phar_obj->archive, now, &error); if (error) { zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "%s", error); @@ -3324,7 +3339,8 @@ PHP_METHOD(Phar, decompressFiles) } phar_obj->archive->is_modified = 1; - phar_flush(phar_obj->archive, &error); + time_t now = time(NULL); + phar_flush(phar_obj->archive, now, &error); if (error) { zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "%s", error); @@ -3418,7 +3434,8 @@ PHP_METHOD(Phar, copy) zend_hash_add_mem(&oldentry->phar->manifest, newentry.filename, &newentry, sizeof(phar_entry_info)); phar_obj->archive->is_modified = 1; - phar_flush(phar_obj->archive, &error); + time_t now = time(NULL); + phar_flush(phar_obj->archive, now, &error); if (error) { zend_throw_exception_ex(phar_ce_PharException, 0, "%s", error); @@ -3546,7 +3563,8 @@ static void phar_add_file(phar_archive_data **pphar, zend_string *file_name, con } #endif - if (!(data = phar_get_or_create_entry_data((*pphar)->fname, (*pphar)->fname_len, filename, filename_len, "w+b", 0, &error, true))) { + time_t now = time(NULL); + if (!(data = phar_get_or_create_entry_data((*pphar)->fname, (*pphar)->fname_len, filename, filename_len, "w+b", 0, now, &error, true))) { if (error) { zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Entry %s does not exist and cannot be created: %s", filename, error); efree(error); @@ -3594,7 +3612,7 @@ static void phar_add_file(phar_archive_data **pphar, zend_string *file_name, con *pphar = data->phar; } phar_entry_delref(data); - phar_flush(*pphar, &error); + phar_flush(*pphar, now, &error); if (error) { zend_throw_exception_ex(phar_ce_PharException, 0, "%s", error); @@ -3613,12 +3631,12 @@ finish: ; /* }}} */ /* {{{ create a directory within the phar archive */ -static void phar_mkdir(phar_archive_data **pphar, zend_string *dir_name) +static void phar_mkdir(phar_archive_data **pphar, zend_string *dir_name, time_t timestamp) { char *error; phar_entry_data *data; - if (!(data = phar_get_or_create_entry_data((*pphar)->fname, (*pphar)->fname_len, ZSTR_VAL(dir_name), ZSTR_LEN(dir_name), "w+b", 2, &error, true))) { + if (!(data = phar_get_or_create_entry_data((*pphar)->fname, (*pphar)->fname_len, ZSTR_VAL(dir_name), ZSTR_LEN(dir_name), "w+b", 2, timestamp, &error, true))) { if (error) { zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Directory %s does not exist and cannot be created: %s", ZSTR_VAL(dir_name), error); efree(error); @@ -3637,7 +3655,7 @@ static void phar_mkdir(phar_archive_data **pphar, zend_string *dir_name) *pphar = data->phar; } phar_entry_delref(data); - phar_flush(*pphar, &error); + phar_flush(*pphar, timestamp, &error); if (error) { zend_throw_exception_ex(phar_ce_PharException, 0, "%s", error); @@ -3721,7 +3739,8 @@ PHP_METHOD(Phar, offsetUnset) entry->is_modified = 0; entry->is_deleted = 1; /* we need to "flush" the stream to save the newly deleted file on disk */ - phar_flush(phar_obj->archive, &error); + time_t now = time(NULL); + phar_flush(phar_obj->archive, now, &error); if (error) { zend_throw_exception_ex(phar_ce_PharException, 0, "%s", error); @@ -3748,7 +3767,8 @@ PHP_METHOD(Phar, addEmptyDir) RETURN_THROWS(); } - phar_mkdir(&phar_obj->archive, dir_name); + time_t now = time(NULL); + phar_mkdir(&phar_obj->archive, dir_name, now); } /* }}} */ @@ -3987,7 +4007,8 @@ PHP_METHOD(Phar, setMetadata) } phar_obj->archive->is_modified = 1; - phar_flush(phar_obj->archive, &error); + time_t now = time(NULL); + phar_flush(phar_obj->archive, now, &error); if (error) { zend_throw_exception_ex(phar_ce_PharException, 0, "%s", error); @@ -4016,7 +4037,8 @@ PHP_METHOD(Phar, delMetadata) phar_metadata_tracker_free(&phar_obj->archive->metadata_tracker, phar_obj->archive->is_persistent); phar_obj->archive->is_modified = 1; - phar_flush(phar_obj->archive, &error); + time_t now = time(NULL); + phar_flush(phar_obj->archive, now, &error); if (error) { zend_throw_exception_ex(phar_ce_PharException, 0, "%s", error); @@ -4582,7 +4604,8 @@ PHP_METHOD(PharFileInfo, chmod) BG(CurrentLStatFile) = NULL; BG(CurrentStatFile) = NULL; - phar_flush(entry_obj->entry->phar, &error); + time_t now = time(NULL); + phar_flush(entry_obj->entry->phar, now, &error); if (error) { zend_throw_exception_ex(phar_ce_PharException, 0, "%s", error); @@ -4663,7 +4686,8 @@ PHP_METHOD(PharFileInfo, setMetadata) entry_obj->entry->is_modified = 1; entry_obj->entry->phar->is_modified = 1; - phar_flush(entry_obj->entry->phar, &error); + time_t now = time(NULL); + phar_flush(entry_obj->entry->phar, now, &error); if (error) { zend_throw_exception_ex(phar_ce_PharException, 0, "%s", error); @@ -4708,7 +4732,8 @@ PHP_METHOD(PharFileInfo, delMetadata) entry_obj->entry->is_modified = 1; entry_obj->entry->phar->is_modified = 1; - phar_flush(entry_obj->entry->phar, &error); + time_t now = time(NULL); + phar_flush(entry_obj->entry->phar, now, &error); if (error) { zend_throw_exception_ex(phar_ce_PharException, 0, "%s", error); @@ -4886,7 +4911,8 @@ PHP_METHOD(PharFileInfo, compress) entry_obj->entry->phar->is_modified = 1; entry_obj->entry->is_modified = 1; - phar_flush(entry_obj->entry->phar, &error); + time_t now = time(NULL); + phar_flush(entry_obj->entry->phar, now, &error); if (error) { zend_throw_exception_ex(phar_ce_PharException, 0, "%s", error); @@ -4976,7 +5002,8 @@ PHP_METHOD(PharFileInfo, decompress) entry_obj->entry->flags &= ~PHAR_ENT_COMPRESSION_MASK; entry_obj->entry->phar->is_modified = 1; entry_obj->entry->is_modified = 1; - phar_flush(entry_obj->entry->phar, &error); + time_t now = time(NULL); + phar_flush(entry_obj->entry->phar, now, &error); if (error) { zend_throw_exception_ex(phar_ce_PharException, 0, "%s", error); diff --git a/ext/phar/stream.c b/ext/phar/stream.c index bb60f00d8f16..ee68e741ecd9 100644 --- a/ext/phar/stream.c +++ b/ext/phar/stream.c @@ -188,10 +188,13 @@ static php_stream * phar_wrapper_open_url(php_stream_wrapper *wrapper, const cha phar_request_initialize(); + // TODO: get from context? + time_t now = time(NULL); /* strip leading "/" */ internal_file = estrndup(ZSTR_VAL(resource->path) + 1, ZSTR_LEN(resource->path) - 1); + size_t internal_file_len = ZSTR_LEN(resource->path) - 1; if (mode[0] == 'w' || (mode[0] == 'r' && mode[1] == '+')) { - if (NULL == (idata = phar_get_or_create_entry_data(ZSTR_VAL(resource->host), ZSTR_LEN(resource->host), internal_file, strlen(internal_file), mode, 0, &error, true))) { + if (NULL == (idata = phar_get_or_create_entry_data(ZSTR_VAL(resource->host), ZSTR_LEN(resource->host), internal_file, internal_file_len, mode, 0, now, &error, true))) { if (error) { php_stream_wrapper_log_error(wrapper, options, "%s", error); efree(error); @@ -469,8 +472,9 @@ static int phar_stream_flush(php_stream *stream) /* {{{ */ phar_entry_data *data = (phar_entry_data *) stream->abstract; if (data->internal_file->is_modified) { - data->internal_file->timestamp = time(0); - ret = phar_flush(data->phar, &error); + time_t now = time(NULL); + data->internal_file->timestamp = now; + ret = phar_flush(data->phar, now, &error); if (error) { php_stream_wrapper_log_error(stream->wrapper, REPORT_ERRORS, "%s", error); efree(error); @@ -717,7 +721,10 @@ static int phar_wrapper_unlink(php_stream_wrapper *wrapper, const char *url, int } php_url_free(resource); efree(internal_file); - phar_entry_remove(idata, &error); + + // TODO: Get from stream context? + time_t now = time(NULL); + phar_entry_remove(idata, now, &error); if (error) { php_stream_wrapper_log_error(wrapper, options, "%s", error); efree(error); @@ -938,7 +945,9 @@ static int phar_wrapper_rename(php_stream_wrapper *wrapper, const char *url_from } if (is_modified) { - phar_flush(phar, &error); + // TODO: Get from stream context? + time_t now = time(NULL); + phar_flush(phar, now, &error); if (error) { php_url_free(resource_from); php_url_free(resource_to); diff --git a/ext/phar/stream.h b/ext/phar/stream.h index 83b395b4cfca..e3dedeb148c4 100644 --- a/ext/phar/stream.h +++ b/ext/phar/stream.h @@ -21,7 +21,7 @@ BEGIN_EXTERN_C() #include "ext/standard/url.h" php_url* phar_parse_url(php_stream_wrapper *wrapper, const char *filename, const char *mode, int options); -ZEND_ATTRIBUTE_NONNULL void phar_entry_remove(phar_entry_data *idata, char **error); +ZEND_ATTRIBUTE_NONNULL void phar_entry_remove(phar_entry_data *idata, time_t timestamp, char **error); static php_stream* phar_wrapper_open_url(php_stream_wrapper *wrapper, const char *path, const char *mode, int options, zend_string **opened_path, php_stream_context *context STREAMS_DC); static int phar_wrapper_rename(php_stream_wrapper *wrapper, const char *url_from, const char *url_to, int options, php_stream_context *context); diff --git a/ext/phar/tar.c b/ext/phar/tar.c index 01ab3f2dd47f..3b008a825543 100644 --- a/ext/phar/tar.c +++ b/ext/phar/tar.c @@ -960,7 +960,7 @@ ZEND_ATTRIBUTE_NONNULL static int phar_tar_setupmetadata(zval *zv, void *argumen } /* }}} */ -ZEND_ATTRIBUTE_NONNULL_ARGS(1, 4) int phar_tar_flush(phar_archive_data *phar, zend_string *user_stub, bool is_default_stub, char **error) /* {{{ */ +ZEND_ATTRIBUTE_NONNULL_ARGS(1, 5) int phar_tar_flush(phar_archive_data *phar, zend_string *user_stub, bool is_default_stub, time_t timestamp, char **error) /* {{{ */ { static const char newstub[] = "tm_year = ((ddate>>9)&127) + 1980 - 1900; tm->tm_mon = ((ddate>>5)&15) - 1; @@ -226,7 +224,7 @@ static char *phar_find_eocd(const char *s, size_t n) * This is used by phar_open_from_fp to process a zip-based phar, but can be called * directly. */ -zend_result phar_parse_zipfile(php_stream *fp, char *fname, size_t fname_len, char *alias, size_t alias_len, phar_archive_data** pphar, char **error) /* {{{ */ +zend_result phar_parse_zipfile(php_stream *fp, char *fname, size_t fname_len, char *alias, size_t alias_len, phar_archive_data** pphar, time_t timestamp, char **error) /* {{{ */ { phar_zip_dir_end locator; char buf[sizeof(locator) + 65536]; @@ -391,7 +389,7 @@ zend_result phar_parse_zipfile(php_stream *fp, char *fname, size_t fname_len, ch entry.uncompressed_filesize = PHAR_GET_32(zipentry.uncompsize); entry.crc32 = PHAR_GET_32(zipentry.crc32); /* do not PHAR_GET_16 either on the next line */ - entry.timestamp = phar_zip_d2u_time(zipentry.timestamp, zipentry.datestamp); + entry.timestamp = phar_zip_d2u_time(zipentry.timestamp, zipentry.datestamp, timestamp); entry.flags = PHAR_ENT_PERM_DEF_FILE; entry.header_offset = PHAR_GET_32(zipentry.offset); @@ -1224,7 +1222,7 @@ static zend_result phar_zip_applysignature(phar_archive_data *phar, struct _phar } /* }}} */ -ZEND_ATTRIBUTE_NONNULL_ARGS(1, 4) int phar_zip_flush(phar_archive_data *phar, zend_string *user_stub, bool is_default_stub, char **error) /* {{{ */ +ZEND_ATTRIBUTE_NONNULL_ARGS(1, 5) int phar_zip_flush(phar_archive_data *phar, zend_string *user_stub, bool is_default_stub, time_t timestamp, char **error) /* {{{ */ { static const char newstub[] = "