1
0
mirror of https://github.com/php/php-src.git synced 2026-04-05 07:02:33 +02:00

- MFB fix offset detection in tar files

This commit is contained in:
Steph Fox
2008-05-24 13:59:56 +00:00
parent fa3ae04c28
commit bdca5a12b0
4 changed files with 13 additions and 3 deletions

View File

@@ -101,7 +101,7 @@ PHP_INI_END()
* When all uses of a phar have been concluded, this frees the manifest
* and the phar slot
*/
static void phar_destroy_phar_data(phar_archive_data *phar TSRMLS_DC) /* {{{ */
void phar_destroy_phar_data(phar_archive_data *phar TSRMLS_DC) /* {{{ */
{
if (phar->alias && phar->alias != phar->fname) {
efree(phar->alias);

View File

@@ -395,6 +395,7 @@ static inline int phar_validate_alias(const char *alias, int alias_len) /* {{{ *
void phar_request_initialize(TSRMLS_D);
void phar_object_init(TSRMLS_D);
void phar_destroy_phar_data(phar_archive_data *phar TSRMLS_DC);
int phar_open_entry_file(phar_archive_data *phar, phar_entry_info *entry, char **error TSRMLS_DC);
int phar_open_filename(char *fname, int fname_len, char *alias, int alias_len, int options, phar_archive_data** pphar, char **error TSRMLS_DC);

View File

@@ -1918,6 +1918,15 @@ static zval *phar_rename_archive(phar_archive_data *phar, char *ext, zend_bool c
if (SUCCESS == zend_hash_find(&(PHAR_GLOBALS->phar_fname_map), newpath, phar->fname_len, (void **) &pphar)) {
if ((*pphar)->fname_len == phar->fname_len && !memcmp((*pphar)->fname, phar->fname, phar->fname_len)) {
if (!zend_hash_num_elements(&phar->manifest)) {
(*pphar)->is_tar = phar->is_tar;
(*pphar)->is_zip = phar->is_zip;
(*pphar)->is_data = phar->is_data;
(*pphar)->flags = phar->flags;
(*pphar)->fp = phar->fp;
phar->fp = NULL;
phar_destroy_phar_data(phar TSRMLS_CC);
phar = *pphar;
newpath = oldpath;
goto its_ok;
}
}

View File

@@ -225,10 +225,11 @@ int phar_open_tarfile(php_stream* fp, char *fname, int fname_len, char *alias, i
entry.is_tar = 1;
entry.is_crc_checked = 1;
entry.phar = myphar;
pos += sizeof(buf);
do {
phar_entry_info *newentry;
pos += sizeof(buf);
pos = php_stream_tell(fp);
hdr = (tar_header*) buf;
sum1 = phar_tar_number(hdr->checksum, sizeof(hdr->checksum));
if (sum1 == 0 && phar_tar_checksum(buf, sizeof(buf)) == 0) {
@@ -385,7 +386,6 @@ int phar_open_tarfile(php_stream* fp, char *fname, int fname_len, char *alias, i
}
}
size = (size+511)&~511;
pos += size;
if (((hdr->typeflag == 0) || (hdr->typeflag == TAR_FILE)) && size > 0) {
/* this is not good enough - seek succeeds even on truncated tars */
php_stream_seek(fp, size, SEEK_CUR);