1
0
mirror of https://github.com/php/php-src.git synced 2026-04-23 16:08:35 +02:00
Commit Graph

1657 Commits

Author SHA1 Message Date
Niels Dossche d6c3079910 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  [ci skip] Fix GH-17808 dependencies
2025-02-16 00:17:06 +01:00
Niels Dossche 3e879f3dd5 [ci skip] Fix GH-17808 dependencies 2025-02-16 00:16:57 +01:00
Niels Dossche 5d8ea65f43 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix GH-17808: PharFileInfo refcount bug
2025-02-15 13:16:33 +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 d3101fb420 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  [skip ci] Another flaky phar macOS test
2025-02-04 14:52:31 +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 4d545f91bc Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  [skip ci] Another flaky macOS phar test
2025-01-28 12:59:25 +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 c63460c92c Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  [skip ci] Another flaky macOS phar test
2025-01-28 12:45:35 +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 7cc8719ee5 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix GH-17518: offset overflow phar extractTo()
2025-01-19 13:05:55 +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 57eb399700 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix GH-17137: Segmentation fault ext/phar/phar.c
2024-12-15 13:55:44 +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 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
Ilija Tovilo fe310181e4 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  [skip ci] Mark another phar test as flaky on macOS
2024-10-18 15:24:55 +02: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 d8e516631f Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix GH-16406: Assertion failure in ext/phar/phar.c:2808
2024-10-17 21:24:08 +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 07377de110 Merge branch 'PHP-8.3'
* PHP-8.3:
  Cast big endian byte shuffling to uint
2024-09-24 02:24:02 -03: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
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 4f9fdf841e ext/phar: Move variable to inner scope 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
Ilija Tovilo 5e7a1cc818 Merge branch 'PHP-8.3'
* PHP-8.3:
  Mark some phar tests as flaky on macOS
2024-09-13 18:14:23 +02: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
Gina Peter Banyard f756b96e06 Make CSV deprecation less annoying to deal with (#15569) 2024-09-13 15:07:26 +01:00
Niels Dossche cd232ed328 Fix short-lived phar regression
Regressed in 1facbc385a
The macro caused the value to be read over and over, but the change to
a variable makes the condition not work like before. Just inline the
read.
2024-09-12 23:16:49 +02:00
Gina Peter Bnayard 1facbc385a ext/phar: Use normal variable instead of macro 2024-09-12 20:41:51 +01:00
Gina Peter Bnayard ae9d8099c2 ext/phar: Add comment about include 2024-09-12 20:41:51 +01:00
Gina Peter Bnayard d486d65962 ext/phar: Reduce scope of some variables 2024-09-12 20:41:51 +01:00
Gina Peter Bnayard 6adffebeb8 ext/phar: Use zend_result as return value
Also simplify some calls to functions returning zend_result
2024-09-12 20:41:51 +01:00
DanielEScherzer 53cb89670c Generated arginfo header files: remove empty zend_function_entry arrays (#15705)
When a class (or enum) has no methods, rather than using an array that only
contains `ZEND_FE_END`, use `NULL` for the functions. The implementation of
class registration for internal classes, `do_register_internal_class()` in
zend_API.c, already skips classes where the functions are `NULL`. By removing
these unneeded arrays, we can reduce the size of the header files, while also
removing an unneeded call to zend_register_functions() for each internal class
with no extra methods.
2024-09-03 23:19:53 +02:00
Peter Kokot fefa7d8c07 Autotools: Sync CS in ext/phar (#15586) 2024-08-25 17:26:21 +02:00