diff --git a/NEWS b/NEWS index 6fbe29aae41..cd40429f3d4 100644 --- a/NEWS +++ b/NEWS @@ -21,6 +21,9 @@ PHP NEWS - Opcache: . Fix incorrect page_size check. (nielsdos) +- Phar: + . Fix incorrect check in phar tar parsing. (nielsdos) + - Random: . Fix GH-10390 (Do not trust arc4random_buf() on glibc). (timwolla) . Fix GH-10292 (Made the default value of the first param of srand() and diff --git a/ext/phar/tar.c b/ext/phar/tar.c index 3b2e4c2ca76..1edc0083449 100644 --- a/ext/phar/tar.c +++ b/ext/phar/tar.c @@ -478,14 +478,15 @@ bail: return FAILURE; } + uint32_t entry_mode = phar_tar_number(hdr->mode, sizeof(hdr->mode)); entry.tar_type = ((old & (hdr->typeflag == '\0')) ? TAR_FILE : hdr->typeflag); entry.offset = entry.offset_abs = pos; /* header_offset unused in tar */ entry.fp_type = PHAR_FP; - entry.flags = phar_tar_number(hdr->mode, sizeof(hdr->mode)) & PHAR_ENT_PERM_MASK; + entry.flags = entry_mode & PHAR_ENT_PERM_MASK; entry.timestamp = phar_tar_number(hdr->mtime, sizeof(hdr->mtime)); entry.is_persistent = myphar->is_persistent; - if (old && entry.tar_type == TAR_FILE && S_ISDIR(entry.flags)) { + if (old && entry.tar_type == TAR_FILE && S_ISDIR(entry_mode)) { entry.tar_type = TAR_DIR; }