Skip to content

Fix persistent local flag on filename zend_strings in phar #17353

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions ext/phar/phar.c
Original file line number Diff line number Diff line change
Expand Up @@ -1182,6 +1182,9 @@ static zend_result phar_parse_pharfile(php_stream *fp, char *fname, size_t fname
}

entry.filename = zend_string_init(filename_raw, filename_len, entry.is_persistent);
if (entry.is_persistent) {
GC_MAKE_PERSISTENT_LOCAL(entry.filename);
}

PHAR_GET_32(buffer, len);
if (len > (size_t)(endbuffer - buffer)) {
Expand Down
9 changes: 9 additions & 0 deletions ext/phar/tar.c
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,9 @@ zend_result phar_parse_tarfile(php_stream* fp, char *fname, size_t fname_len, ch
return FAILURE;
}
entry.filename = zend_string_alloc(entry.uncompressed_filesize, myphar->is_persistent);
if (myphar->is_persistent) {
GC_MAKE_PERSISTENT_LOCAL(entry.filename);
}
ZSTR_VAL(entry.filename)[entry.uncompressed_filesize] = '\0';

read = php_stream_read(fp, ZSTR_VAL(entry.filename), entry.uncompressed_filesize);
Expand Down Expand Up @@ -440,6 +443,9 @@ zend_result phar_parse_tarfile(php_stream* fp, char *fname, size_t fname_len, ch
}

entry.filename = zend_string_init(name, filename_len, myphar->is_persistent);
if (myphar->is_persistent) {
GC_MAKE_PERSISTENT_LOCAL(entry.filename);
}
} else if (!last_was_longlink) {
/* calculate strlen, which can be no longer than 100 */
uint32_t filename_len;
Expand All @@ -455,6 +461,9 @@ zend_result phar_parse_tarfile(php_stream* fp, char *fname, size_t fname_len, ch
}

entry.filename = zend_string_init(hdr->name, filename_len, myphar->is_persistent);
if (myphar->is_persistent) {
GC_MAKE_PERSISTENT_LOCAL(entry.filename);
}
}
last_was_longlink = 0;

Expand Down
Loading