Skip to content

Commit 231ffaf

Browse files
committed
Merge branch 'PHP-8.2'
* PHP-8.2: Fix incorrect check in phar tar parsing
2 parents ff84598 + 08f654b commit 231ffaf

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

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)