Skip to content

Commit 08f654b

Browse files
committed
Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1: Fix incorrect check in phar tar parsing
2 parents 5e1b966 + ec4939b commit 08f654b

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ PHP NEWS
2121
- Opcache:
2222
. Fix incorrect page_size check. (nielsdos)
2323

24+
- Phar:
25+
. Fix incorrect check in phar tar parsing. (nielsdos)
26+
2427
- Random:
2528
. Fix GH-10390 (Do not trust arc4random_buf() on glibc). (timwolla)
2629
. Fix GH-10292 (Made the default value of the first param of srand() and

ext/phar/tar.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -478,14 +478,15 @@ int phar_parse_tarfile(php_stream* fp, char *fname, size_t fname_len, char *alia
478478
return FAILURE;
479479
}
480480

481+
uint32_t entry_mode = phar_tar_number(hdr->mode, sizeof(hdr->mode));
481482
entry.tar_type = ((old & (hdr->typeflag == '\0')) ? TAR_FILE : hdr->typeflag);
482483
entry.offset = entry.offset_abs = pos; /* header_offset unused in tar */
483484
entry.fp_type = PHAR_FP;
484-
entry.flags = phar_tar_number(hdr->mode, sizeof(hdr->mode)) & PHAR_ENT_PERM_MASK;
485+
entry.flags = entry_mode & PHAR_ENT_PERM_MASK;
485486
entry.timestamp = phar_tar_number(hdr->mtime, sizeof(hdr->mtime));
486487
entry.is_persistent = myphar->is_persistent;
487488

488-
if (old && entry.tar_type == TAR_FILE && S_ISDIR(entry.flags)) {
489+
if (old && entry.tar_type == TAR_FILE && S_ISDIR(entry_mode)) {
489490
entry.tar_type = TAR_DIR;
490491
}
491492

0 commit comments

Comments
 (0)