ndossche
0155b50984
phar: Fix const-generic compile warnings
2026-03-09 20:45:07 +01:00
David Carlier
77925b971a
Merge branch 'PHP-8.5'
...
* PHP-8.5:
Fix GH-21333: use-after-free when unlinking entries during iteration of a compressed phar.
2026-03-05 22:32:38 +00:00
David Carlier
449361afbf
Fix GH-21333: use-after-free when unlinking entries during iteration of a compressed phar.
...
close GH-21334
2026-03-05 22:31:49 +00:00
Niels Dossche
0880433e61
Merge branch 'PHP-8.5'
...
* PHP-8.5:
phar: Fix SplFileInfo::openFile() in write mode
2025-12-21 13:18:47 +01:00
Niels Dossche
38e8aca77d
Merge branch 'PHP-8.4' into PHP-8.5
...
* PHP-8.4:
phar: Fix SplFileInfo::openFile() in write mode
2025-12-21 13:18:39 +01:00
Niels Dossche
cf4e8e0ef6
Merge branch 'PHP-8.3' into PHP-8.4
...
* PHP-8.3:
phar: Fix SplFileInfo::openFile() in write mode
2025-12-21 13:18:23 +01:00
Niels Dossche
efde160ef4
phar: Fix SplFileInfo::openFile() in write mode
...
This stopped working after e735d2bc3b because fp_refcount is increased,
making phar think that the file has open read pointers.
To fix this, the refcount shouldn't be increased but that would
re-introduce the previous bug.
Instead, we need to add a field that "locks" the existence of the
internal entry separate from the refcount.
Closes GH-20473.
2025-12-21 13:17:54 +01:00
Niels Dossche
40ff6e0592
Merge branch 'PHP-8.5'
...
* PHP-8.5:
Revert "ext/phar: Voidify flush function as it always returns EOL"
phar: Fix broken return value of fflush() for phar file entries
2025-11-15 14:05:32 +01:00
Niels Dossche
7809d51918
Merge branch 'PHP-8.4' into PHP-8.5
...
* PHP-8.4:
Revert "ext/phar: Voidify flush function as it always returns EOL"
phar: Fix broken return value of fflush() for phar file entries
2025-11-15 13:59:38 +01:00
Niels Dossche
08ec409f1b
Merge branch 'PHP-8.3' into PHP-8.4
...
* PHP-8.3:
phar: Fix broken return value of fflush() for phar file entries
2025-11-15 13:58:17 +01:00
Niels Dossche
fd5c14e682
Revert "ext/phar: Voidify flush function as it always returns EOL"
...
This reverts commit 2513258a2b .
2025-11-15 13:57:47 +01:00
Niels Dossche
2f9d86b677
phar: Fix broken return value of fflush() for phar file entries
...
The flush functions always return EOF, even in the success path.
The success path should return 0 to indicate success.
Closes GH-20474.
2025-11-15 13:56:06 +01:00
Niels Dossche
a596e05cf3
phar: Make phar_is_tar() and referenced functions const correct ( #20451 )
2025-11-11 13:44:13 +01:00
Niels Dossche
86a15f9a1b
phar: Remove redundant *error check ( #20288 )
...
The failure of the iterator is already checked above at line 1157.
2025-10-25 21:01:41 +02:00
Niels Dossche
63e534d7ca
phar: Remove no-op bool casts ( #20227 )
...
The field in this struct is already a bool.
2025-10-19 23:29:08 +02:00
Gina Peter Banyard
9a24c6a89f
ext/phar: assert function are not passed NULL pointers
...
This simplifies some of the logic and makes the assumptions clear
2025-10-16 21:02:39 +01:00
Gina Peter Banyard
2e62399fc7
ext/phar: use bool type instead of int
2025-10-15 22:36:09 +01:00
Niels Dossche
f65dcb9fbf
Merge branch 'PHP-8.5'
...
* PHP-8.5:
Fix build
2025-10-01 10:54:52 +02:00
Niels Dossche
64d2a3fe94
Merge branch 'PHP-8.4' into PHP-8.5
...
* PHP-8.4:
Fix build
2025-10-01 10:54:46 +02:00
Niels Dossche
9bd9e3a1f9
Fix build
2025-10-01 10:54:41 +02:00
Niels Dossche
49a5331d43
Merge branch 'PHP-8.5'
...
* PHP-8.5:
Fix memory leak and invalid continuation after tar header writing fails
2025-10-01 10:47:52 +02:00
Niels Dossche
fced2d8ff4
Merge branch 'PHP-8.4' into PHP-8.5
...
* PHP-8.4:
Fix memory leak and invalid continuation after tar header writing fails
2025-10-01 10:47:43 +02:00
Niels Dossche
c3d17d93d3
Merge branch 'PHP-8.3' into PHP-8.4
...
* PHP-8.3:
Fix memory leak and invalid continuation after tar header writing fails
2025-10-01 10:47:28 +02:00
Niels Dossche
7c859268c0
Fix memory leak and invalid continuation after tar header writing fails
...
Closes GH-20003.
2025-10-01 10:46:33 +02:00
Tim Düsterhus
11d10607bc
phar: Use true / false instead of 1 / 0 when assigning to bool
...
Changes done with Coccinelle:
@@
bool b;
@@
- b = 0
+ b = false
@@
bool b;
@@
- b = 1
+ b = true
2025-09-24 18:51:40 +02:00
Niels Dossche
110fae0628
Merge branch 'PHP-8.4'
...
* PHP-8.4:
Fix memory leak in phar tar temporary file error handling code
2025-09-07 13:05:13 +02:00
Niels Dossche
3d52e925a1
Merge branch 'PHP-8.3' into PHP-8.4
...
* PHP-8.3:
Fix memory leak in phar tar temporary file error handling code
2025-09-07 13:05:07 +02:00
Niels Dossche
2f162214e8
Fix memory leak in phar tar temporary file error handling code
...
Closes GH-19740.
2025-09-07 13:04:19 +02:00
Niels Dossche
5a2a150829
Merge branch 'PHP-8.4'
...
* PHP-8.4:
Fix phar crash and file corruption with SplFileObject
2025-07-05 21:44:39 +02:00
Niels Dossche
2aeefb13be
Merge branch 'PHP-8.3' into PHP-8.4
...
* PHP-8.3:
Fix phar crash and file corruption with SplFileObject
2025-07-05 21:44:34 +02:00
Niels Dossche
405be1c940
Fix phar crash and file corruption with SplFileObject
...
There are two bugfixes here.
The first was a crash that I discovered while working on GH-19035.
The check for when a file pointer was still occupied was wrong, leading
to a UAF. Strangely, zip got this right.
The second issue was that even after fixing the first one, the file
contents were garbage. This is because the file write offset for the
phar stream was wrong.
Closes GH-19038.
2025-07-05 21:44:12 +02:00
Niels Dossche
9e3508bfa8
Fix persistent local flag on filename zend_strings in phar ( #17353 )
...
This fixes the nightly failure.
2025-01-04 14:56:26 +01:00
Niels Dossche
21f4211d1a
Use zend_string_{equals,startswith} helpers
...
Closes GH-17240.
2025-01-03 17:59:58 +01:00
Niels Dossche
c7b80e640e
Transform phar_entry_info filename to zend_string
...
The contents of the string are copied many times, especially in hash
tables. Avoid all this work by using zend_string in the first place.
2025-01-03 17:59:04 +01:00
Niels Dossche
c6d7d07a1d
Merge branch 'PHP-8.3' into PHP-8.4
...
* PHP-8.3:
Fix GH-16695: phar:// tar parser and zero-length file header blocks
2024-11-09 17:08:49 +01:00
Niels Dossche
58f4b45bca
Merge branch 'PHP-8.2' into PHP-8.3
...
* PHP-8.2:
Fix GH-16695: phar:// tar parser and zero-length file header blocks
2024-11-09 17:08:19 +01:00
Niels Dossche
72c0222926
Fix GH-16695: phar:// tar parser and zero-length file header blocks
...
There are two issues:
1) There's an off-by-one in the check for the minimum file size for a
tar (i.e. `>` instead of `>=`).
2) The loop in the tar parsing parses a header, and then unconditionally
reads the next one. However, that doesn't necessarily exist.
Instead, we remove the loop condition and check for the end of the
file before reading the next header. Note that we can't use
php_stream_eof as the flag may not be set yet when we're already at
the end.
Closes GH-16700.
2024-11-09 17:07:53 +01:00
Gina Peter Bnayard
2513258a2b
ext/phar: Voidify flush function as it always returns EOL
2024-09-14 14:00:46 +01:00
Gina Peter Bnayard
290fb920f2
ext/phar: Mark constant string as static const
2024-09-14 14:00:46 +01:00
Gina Peter Bnayard
b75c79ee1d
ext/phar: Use bool instead of int
2024-09-14 14:00:46 +01:00
Gina Peter Bnayard
03e2cfdad1
ext/phar: Refactor flushing of archive to only take string stub file
2024-09-14 14:00:46 +01:00
Gina Peter Bnayard
f9c69bc392
ext/phar: Reorganise some headers
2024-08-23 17:42:37 +01:00
Gina Peter Bnayard
03be1ac0ad
ext/phar: Refactor part of tar.c
2024-08-23 17:42:37 +01:00
Niels Dossche
f0f05c7923
Introduce some const pointers
2024-05-06 19:50:22 +02:00
Niels Dossche
7b60f53f07
Remove unused field from _phar_archive_data ( #14146 )
...
This field is only ever written to, but never read.
2024-05-06 19:50:12 +02:00
Cristian Rodríguez
782ffd761b
Use a single version of strnlen ( #12015 )
...
* Zend: Make zend_strnlen available for use outside zend_compile
* exif: remove local php_strnlen, use zend_strnlen instead
* main: remove local strnlen, use zend_strnlen instead
* phar: remove local strnlen, use zend_strnlen
2023-08-22 17:40:24 +02:00
Niels Dossche
22040f5a8f
Merge branch 'PHP-8.1' into PHP-8.2
...
* PHP-8.1:
Fix undefined behaviour in GENERATE_SEED()
Fix undefined behaviour when writing 32-bit values in phar/tar.c
2023-03-26 16:15:57 +02:00
Niels Dossche
19ddc62778
Fix undefined behaviour when writing 32-bit values in phar/tar.c
...
As shown on the CI runs on my fork (which runs with UBSAN),
the pointers can sometimes be unaligned when trying to write.
This is UB and on platforms like ARM this *can* result in a bus error.
Replace it with memcpy, which at least on x86 and powerpc
architectures does result in the same assembly code.
Closes GH-10940.
2023-03-26 16:06:29 +02:00
George Peter Banyard
08f654b590
Merge branch 'PHP-8.1' into PHP-8.2
...
* PHP-8.1:
Fix incorrect check in phar tar parsing
2023-01-29 17:17:21 +00:00
Niels Dossche
ec4939b170
Fix incorrect check in phar tar parsing
...
The entry.flags was used to check whether the entry has the directory
flag. The flags however were masked to only contain the permissions. We
need to check the mode, before the permission masking, instead of the
flags to check whether it is a directory.
Closes GH-10464
Signed-off-by: George Peter Banyard <girgias@php.net >
2023-01-29 17:14:12 +00:00