1
0
mirror of https://github.com/php/php-src.git synced 2026-04-25 08:58:28 +02:00
Commit Graph

1656 Commits

Author SHA1 Message Date
Niels Dossche 0a69e14278 Avoid copying request strings in phar_parse_pharfile() 2025-01-04 14:08:33 +00: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 b09ed9a0f2 Use format string to cut off filename instead of duplicating memory
Split off from GH-17240.
2024-12-26 12:30:49 +01:00
Niels Dossche fe87ba41b8 Merge branch 'PHP-8.4'
* PHP-8.4:
  Fix GH-17137: Segmentation fault ext/phar/phar.c
2024-12-15 13:55:50 +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
Gina Peter Banyard 234219dc33 ext/phar: Refactor phar_call_openssl_signverify() 2024-11-11 15:00:08 +00:00
Gina Peter Banyard 2684a5ef91 ext/phar: Fix test that is only run when ext/openssl is not built 2024-11-11 15:00:08 +00:00
Niels Dossche 37d53d5a04 Merge branch 'PHP-8.4'
* PHP-8.4:
  Fix GH-16695: phar:// tar parser and zero-length file header blocks
2024-11-09 17:08:55 +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 4704f00fc2 Merge branch 'PHP-8.4'
* PHP-8.4:
  [skip ci] Mark another phar test as flaky on macOS
2024-10-18 15:25:02 +02: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 7aeafe4bae Merge branch 'PHP-8.4'
* PHP-8.4:
  Fix GH-16406: Assertion failure in ext/phar/phar.c:2808
2024-10-17 21:24:13 +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
Gina Peter Banyard d7bdf902e5 ext/phar: Remove phar_resolve_alias() (#15860)
As this is unused and a SourceGraph search returns 0 result
2024-10-02 15:44:05 +01:00
Gina Peter Banyard 1f14d58c72 ext/phar: Remove unnecessary memory duplication for phar_make_dirstream()
And also pass in the known string length
2024-09-26 21:36:03 +01:00
Gina Peter Banyard b581e8e6d0 ext/phar: Use HASH_FOREACH macro in phar_make_dirstream()
Also simplify and refactor the inside of the loop
2024-09-26 21:36:03 +01:00
Gina Peter Banyard c74f1bebc6 ext/phar: Prevent duplicate strlen() computation in phar_wrapper_open_dir() 2024-09-26 21:36:03 +01:00
Gina Peter Banyard a600713cd6 ext/phar: Use HASH_FOREACH macro in phar_wrapper_open_dir()
Also simplify the inner if condition
2024-09-26 21:36:03 +01:00
Gina Peter Banyard 615960be9c ext/phar: Refer to zend_string* length directly
This makes it more obvious that the host_len is that of resource->host
2024-09-26 21:36:03 +01:00
Gina Peter Banyard 839952c65a ext/phar: Use HASH_FOREACH macro in phar_wrapper_rmdir()
Also simplify the inner if condition
2024-09-26 21:36:03 +01: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
Máté Kocsis 8d12f666ae Fix registration of internal readonly child classes (#15459)
Currently, internal classes are registered with the following code:

INIT_CLASS_ENTRY(ce, "InternalClass", class_InternalClass_methods);
class_entry = zend_register_internal_class_ex(&ce, NULL);
class_entry->ce_flags |= ...;

This has worked well so far, except if InternalClass is readonly. It is because some inheritance checks are run by zend_register_internal_class_ex before ZEND_ACC_READONLY_CLASS is added to ce_flags.

The issue is fixed by adding a zend_register_internal_class_with_flags() zend API function that stubs can use from now on. This function makes sure to add the flags before running any checks. Since the new API is not available in lower PHP versions, gen_stub.php has to keep support for the existing API for PHP 8.3 and below.
2024-08-24 12:36:54 +02:00