1
0
mirror of https://github.com/php/php-src.git synced 2026-03-28 10:12:18 +01:00
Commit Graph

1570 Commits

Author SHA1 Message Date
Niels Dossche
3e879f3dd5 [ci skip] Fix GH-17808 dependencies 2025-02-16 00:16:57 +01:00
Niels Dossche
e735d2bc3b Fix GH-17808: PharFileInfo refcount bug
PharFileInfo just takes a pointer from the manifest without refcounting
anything. If the entry is then removed from the manifest while the
PharFileInfo object still exists, we get a UAF.
We fix this by using the fp_refcount field. This is technically a
behaviour change as the unlinking is now blocked, and potentially file
modifications can be blocked as well. The alternative would be to have a
field that indicates whether deletion is blocked, but similar corruption
bugs may occur as well with file overwrites, so we increment fp_refcount
instead.
This also fixes an issue where a destructor called multiple times
resulted in a UAF as well, by moving the NULL'ing of the entry field out
of the if.

Closes GH-17811.
2025-02-15 13:15:51 +01:00
Ilija Tovilo
88e1917cb7 Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  [skip ci] Another flaky phar macOS test
2025-02-04 14:52:23 +01:00
Ilija Tovilo
99d2055670 Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  [skip ci] Another flaky phar macOS test
2025-02-04 14:52:15 +01:00
Ilija Tovilo
d8aedb589c [skip ci] Another flaky phar macOS test 2025-02-04 14:52:03 +01:00
Ilija Tovilo
dc06a52362 Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  [skip ci] Another flaky macOS phar test
2025-01-28 12:58:55 +01:00
Ilija Tovilo
c14601cc90 Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  [skip ci] Another flaky macOS phar test
2025-01-28 12:58:42 +01:00
Ilija Tovilo
d9744869e6 [skip ci] Another flaky macOS phar test 2025-01-28 12:58:30 +01:00
Ilija Tovilo
b598dbf822 Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  [skip ci] Another flaky macOS phar test
2025-01-28 12:45:17 +01:00
Ilija Tovilo
01309961bb Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  [skip ci] Another flaky macOS phar test
2025-01-28 12:45:10 +01:00
Ilija Tovilo
65b990a1e0 [skip ci] Another flaky macOS phar test 2025-01-28 12:44:24 +01:00
Niels Dossche
eab209d81d Fix GH-17518: offset overflow phar extractTo()
`search` can be the empty string, so we need to check the length before
checking the last char.

Closes GH-17519.
2025-01-19 13:05:19 +01:00
Niels Dossche
142f85e2e1 Fix GH-17137: Segmentation fault ext/phar/phar.c
Commit edae2431 attempted to fix a leak and double free, but didn't
properly understand what was going on, causing a reference count mistake
and subsequent segfault in this case.

The first mistake of that commit is that the reference count should've
been increased because we're reusing a phar object. The error handling
path should've gotten changed instead to undo this refcount increase
instead of not refcounting at all (root cause of this bug).

The second mistake is that the alias isn't supposed to be transferred or
whatever, that just doesn't make sense. The reason the test
bug69958.phpt originally leaked is because in the non-reuse case we
borrowed the alias and otherwise we own the alias. If we own the alias
the alias information shouldn't get deleted anyway as that would desync
the alias map.

Fixing these will reveal a third issue in which the alias memory is not
always properly in sync with the persistence-ness of the phar, fix this
as well.

Closes GH-17150.
2024-12-15 13:50:09 +01:00
Ilija Tovilo
8a9d45b86f Backport flaky flag for phar tests
4e12189604
b6ca871396
062837aa13
2024-12-10 10:35:00 +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
Ilija Tovilo
ce44a7f95c Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  [skip ci] Mark another phar test as flaky on macOS
2024-10-18 15:24:44 +02:00
Ilija Tovilo
062837aa13 [skip ci] Mark another phar test as flaky on macOS 2024-10-18 15:24:15 +02:00
Niels Dossche
25817ad298 Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix GH-16406: Assertion failure in ext/phar/phar.c:2808
2024-10-17 21:23:47 +02:00
Niels Dossche
6a8d0a054d Fix GH-16406: Assertion failure in ext/phar/phar.c:2808
When copying entries during conversion in phar_convert_to_other(), the
header offset is not reset. This didn't matter in the past as it wasn't
used anyway in the particular use-case, but since 1bb2a4f9 this is
actually used and sanity-checked.

Closes GH-16470.
2024-10-17 21:23:17 +02:00
Calvin Buckley
22d25d2896 Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Cast big endian byte shuffling to uint
2024-09-24 02:23:51 -03:00
Calvin Buckley
6cef9d365e Merge branch 'phar-big-endian-8.2' into PHP-8.2
* phar-big-endian-8.2:
  Cast big endian byte shuffling to uint
2024-09-24 02:23:30 -03:00
Calvin Buckley
792a0e6dec Cast big endian byte shuffling to uint
This works, but UBSan running on a big endian platform (in this, ppc64)
will complain that the ((uchar*)buffer)[n] is int, and shifting that
could be weird. Since the value of PHAR_GET_32 et al are almost always
unsigned, it makes sense to cast these as unsigned.

Fixes phar tests on a big endian system with UBSan enabled.
2024-09-22 15:29:50 -03:00
Ilija Tovilo
5b2d80bc79 Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Mark some phar tests as flaky on macOS
2024-09-13 18:14:14 +02:00
Ilija Tovilo
4e12189604 Mark some phar tests as flaky on macOS
Fixes GH-15748
Closes GH-15876
2024-09-13 18:13:10 +02:00
Niels Dossche
f21947a7ae Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix GH-15028: Memory leak in ext/phar/stream.c
  Fix GH-15023: Memory leak in Zend/zend_ini.c
  Fix GH-15020: Memory leak in Zend/Optimizer/escape_analysis.c
2024-07-19 14:59:44 +02:00
Niels Dossche
5996227f88 Fix GH-15028: Memory leak in ext/phar/stream.c
Closes GH-15029.
2024-07-19 14:58:28 +02:00
David Carlier
04418ede7a Merge branch 'PHP-8.2' into PHP-8.3 2024-06-21 05:08:21 +01:00
David Carlier
686afc10bf Fix GH-14603: invalid null zip file entry.
close GH-14610
2024-06-21 05:07:46 +01:00
Niels Dossche
07fe3b2920 Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix potential NULL pointer dereference before calling EVP_SignInit
2024-04-08 19:31:13 +02:00
icy17
6f8bda0582 Fix potential NULL pointer dereference before calling EVP_SignInit
Closes GH-13870.
2024-04-08 19:30:26 +02:00
Niels Dossche
b34e838874 Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Skip test on Windows because of different error output
2024-03-31 16:56:21 +02:00
Niels Dossche
5ed5d37f25 Skip test on Windows because of different error output 2024-03-31 16:56:14 +02:00
Niels Dossche
b1a6832287 Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix GH-13833: Applying zero offset to null pointer in zend_hash.c
2024-03-31 14:25:39 +02:00
Niels Dossche
47bb6c1b79 Fix GH-13833: Applying zero offset to null pointer in zend_hash.c
MAPPHAR_FAIL will call the destructor of the manifest, mounted_dirs, and
virtual_dirs tables. When a new phar object is allocated using (p)ecalloc,
the bytes are zeroed, but the flag for an uninitialized table is
non-zero. So we have to manually set the flag in case that we have a
code path that can destroy the tables without first initializing them at
least once.

Closes GH-13847.
2024-03-31 14:25:08 +02:00
Niels Dossche
6a23c7fa91 Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix GH-13836: Renaming a file in a Phar to an already existing filename causes a NULL pointer dereference
2024-03-30 18:04:29 +01:00
Niels Dossche
ed8ed714a8 Fix GH-13836: Renaming a file in a Phar to an already existing filename causes a NULL pointer dereference
If the destination already exists, then the `add` function on the
manifest will return NULL, resulting in a NULL entry and therefore a
NULL deref. As `copy()` (not `Phar::copy`) chooses to succeed and
overwrite the destination if it already exists, we should do the same.
Therefore the fix is as simple as changing `add` to `update`.

Closes GH-13840.
2024-03-30 18:03:55 +01:00
Peter Kokot
8d5fc8d23f Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Use EXTENSIONS instead of SKIPIF sections in *.phpt
2024-01-31 11:20:44 +01:00
Peter Kokot
218a93b898 Use EXTENSIONS instead of SKIPIF sections in *.phpt
This also fixes skipped tests due to different naming "zend-test"
instead of "zend_test" and "PDO" instead of "pdo":

- ext/dom/tests/libxml_global_state_entity_loader_bypass.phpt
- ext/simplexml/tests/libxml_global_state_entity_loader_bypass.phpt
- ext/xmlreader/tests/libxml_global_state_entity_loader_bypass.phpt
- ext/zend_test/tests/observer_sqlite_create_function.phpt

EXTENSIONS section is used for the Windows build to load the non-static
extensions.

Closes GH-13276
2024-01-31 11:18:21 +01:00
Niels Dossche
78986a6734 Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix GH-10344: imagettfbbox(): Could not find/open font UNC path
  Fix GH-13037: PharData incorrectly extracts zip file
2024-01-25 20:07:33 +01:00
Niels Dossche
ba80372a58 Fix GH-13037: PharData incorrectly extracts zip file
The code currently assumes that the extra field length of the central
directory entry and the local entry are the same, but that's not the
case. For example, the "Extended Timestamp extra field" differs in size
for local vs central directory entries. This causes the file contents
offset to be incorrect because it is based on the central directory
length instead of the local entry length. Fix it by reading the local
entry and getting the size from there as well as checking consistency
for the file name length.

Closes GH-13045.
2024-01-25 20:05:45 +01:00
Niels Dossche
e062fe02ef Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix phar/tests/bug77432.phpt
2024-01-12 17:24:07 +01:00
Niels Dossche
5a988d5764 Fix phar/tests/bug77432.phpt
- For Windows we just have to set the right error_reporting value
- Test cannot be used repeatedly on Opcache because the unlink will have
  no effect because of caching.

Closes GH-13129.
2024-01-12 17:23:50 +01:00
Peter Kokot
bafb17adcf Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Update year to 2024
2024-01-04 19:29:37 +01:00
Peter Kokot
2575e6b88c Update year to 2024 2024-01-04 19:26:32 +01:00
Niels Dossche
7525e690f6 Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix #71465: PHAR doesn't know about litespeed
2024-01-03 21:34:59 +01:00
Niels Dossche
85dbbe19e2 Fix #71465: PHAR doesn't know about litespeed
We should perhaps look into a generic system to ask the SAPI whether
a feature should be supported or not. Or, we should look into making
a denylist instead of an allowlist.
Anyway, let's not try doing anything fancy on stable branches.

Closes GH-13070.
2024-01-03 21:31:09 +01:00
Niels Dossche
b131681d4c Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Skip on Windows
2024-01-01 15:58:52 +01:00
Niels Dossche
0d2c83ef9c Skip on Windows 2024-01-01 15:58:47 +01:00
Niels Dossche
8d095af1c0 Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix test not emitting warning because of Windows paths
2024-01-01 15:27:43 +01:00