1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

1301 Commits

Author SHA1 Message Date
ndossche
daf1d322da Merge branch 'PHP-8.5'
* PHP-8.5:
  Fix pcre leak test (#21327)
2026-03-02 18:51:57 +01:00
ndossche
fa3c8eed16 Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
  Fix pcre leak test (#21327)
2026-03-02 18:51:52 +01:00
Nora Dossche
4e831236f8 Fix pcre leak test (#21327)
We need an uninterned string to trigger the leak. The loop is also
unnecessary.
2026-03-02 18:51:29 +01:00
David Carlier
114c0d6e93 Merge branch 'PHP-8.5'
* PHP-8.5:
  ext/pcre: fix mdata_used race conditions in PCRE functions
2026-02-27 22:18:56 +00:00
David Carlier
7a8a8633ce Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
  ext/pcre: fix mdata_used race conditions in PCRE functions
2026-02-27 22:15:02 +00:00
David Carlier
f8114f554c ext/pcre: fix mdata_used race conditions in PCRE functions
Mirror the mdata_used protection pattern from php_pcre_replace_func_impl
in php_pcre_match_impl, php_pcre_replace_impl, php_pcre_split_impl,
and php_pcre_grep_impl.

close GH-21291
2026-02-27 22:14:41 +00:00
David Carlier
d1ff85f26f Merge branch 'PHP-8.5'
* PHP-8.5:
  ext/pcre: drop negative-length match tests
2026-02-27 19:18:35 +00:00
David Carlier
27e12b50f4 ext/pcre: drop negative-length match tests
Newer PCRE2 rejects \K in lookarounds at compile time, so the
negative-length match code path can no longer be triggered from
userland PHP. The PCRE2_EXTRA_ALLOW_LOOKAROUND_BSK flag that would
re-enable it is only settable via the C compile context API.
2026-02-27 19:18:25 +00:00
David Carlier
7bc80c0932 Merge branch 'PHP-8.5'
* PHP-8.5:
  ext/pcre: fix new pcre2 test
2026-02-26 19:47:37 +00:00
David Carlier
e64e8b0117 ext/pcre: fix new pcre2 test
close GH-21307
2026-02-26 19:47:19 +00:00
David Carlier
9cc1d323e0 Merge branch 'PHP-8.5'
* PHP-8.5:
  ext/pcre: fix memory leaks on error paths
2026-02-26 18:57:21 +00:00
David Carlier
5406176050 Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
  ext/pcre: fix memory leaks on error paths
2026-02-26 18:57:11 +00:00
David Carlier
78702fa470 ext/pcre: fix memory leaks on error paths
Fix pcre2_code leak when pcre2_pattern_info() fails after a successful
pcre2_compile(), and fix match_sets/match_data/marks leak when
offsets[1] < offsets[0] in php_pcre_match_impl().

close GH-21298
2026-02-26 18:56:24 +00:00
Louis-Arnaud
5bd1bbdc50 ext/pcre: Fix preg_grep() returning partial array instead of false on error (#21260)
When a PCRE execution error occurs (e.g. malformed UTF-8 with /u
modifier), preg_grep() was returning a partial result array containing
only the entries processed before the error. All other preg_* functions
return false on execution errors.

After the match loop, check PCRE_G(error_code) and if an error
occurred, destroy the partial array and return false instead.

Fixes GH-11936
2026-02-26 16:14:53 +00:00
David Carlier
300892ac81 Merge branch 'PHP-8.5'
* PHP-8.5:
  ext/pcre: preg_match() fix memory leak with invalid regexes.
2026-02-24 22:20:15 +00:00
David Carlier
955f82f417 Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
  ext/pcre: preg_match() fix memory leak with invalid regexes.
2026-02-24 22:20:06 +00:00
David Carlier
6c45f7a000 ext/pcre: preg_match() fix memory leak with invalid regexes.
close GH-21290
2026-02-24 22:19:27 +00:00
Arnaud Le Blanc
65b4073922 Include the actual stub name in generated arginfo headers (#20993) 2026-01-21 20:57:00 +01:00
Michael Voříšek
7db647dd99 Verify bundled PCRE2 in CI
Closes GH-20354
2025-11-12 18:23:01 +01:00
Ilija Tovilo
f5f81fee4d Merge branch 'PHP-8.5'
* PHP-8.5:
  ext/pcre/tests: support libpcre2-10.47
2025-11-07 18:55:04 +01:00
Ilija Tovilo
47cedfae26 Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
  ext/pcre/tests: support libpcre2-10.47
2025-11-07 18:54:56 +01:00
Ilija Tovilo
29f530158a Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  ext/pcre/tests: support libpcre2-10.47
2025-11-07 18:54:45 +01:00
Ilija Tovilo
ae01a8adcc Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  ext/pcre/tests: support libpcre2-10.47
2025-11-07 18:53:22 +01:00
Ilija Tovilo
b4e8635f5c Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  ext/pcre/tests: support libpcre2-10.47
2025-11-07 18:53:16 +01:00
Michael Orlitzky
bdf62b55bb ext/pcre/tests: support libpcre2-10.47
In the latest version of libpcre2, the offsets appearing in some
"compilation failed" warnings have increased by one, as a result of

  https://github.com/PCRE2Project/pcre2/pull/756

This is causing spurious test failures, so in this commit we replace
the hard-coded offsets by a regex that matches both values.

Gentoo-bug: https://bugs.gentoo.org/965018

Closes GH-20397
2025-11-07 18:52:48 +01:00
Niels Dossche
20bc05991f Merge branch 'PHP-8.5'
* PHP-8.5:
  NEWS for GH-20341
  Revert "Upgrade bundled pcre2lib to 10.45 (#17825)"
  Revert "Update pcre2lib from 10.45 to 10.46 (#19618)"
2025-11-03 23:02:12 +01:00
Niels Dossche
ed3e48b506 Revert "Upgrade bundled pcre2lib to 10.45 (#17825)"
This reverts commit e92848789a.
2025-11-03 23:01:50 +01:00
Niels Dossche
3ef966ceb7 Revert "Update pcre2lib from 10.45 to 10.46 (#19618)"
This reverts commit 84b78c047e.
2025-11-03 23:01:50 +01:00
Gina Peter Banyard
0df31e5a5b Merge branch 'PHP-8.5'
* PHP-8.5:
  Update NEWS for null deprecation bug fix
  Fix GH-20194: null offset deprecation not emitted for writes (#20238)
2025-10-29 18:37:29 +00:00
Gina Peter Banyard
9a1b8a785d Fix GH-20194: null offset deprecation not emitted for writes (#20238)
Based on a patch from @ndossche
2025-10-29 18:36:10 +00:00
Tim Düsterhus
09add9a0a3 pcre: Use return true / return false for functions returning bool
Changes done with Coccinelle:

    @r1@
    identifier fn;
    typedef bool;
    symbol false;
    symbol true;
    @@

    bool fn ( ... )
    {
    <...
    return
    (
    - 0
    + false
    |
    - 1
    + true
    )
    ;
    ...>
    }

Coccinelle patch sourced from
torvalds/linux@46b5c9b856.
2025-09-24 18:51:40 +02:00
Tim Düsterhus
a1e1fa3ef8 pcre: 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
84b78c047e Update pcre2lib from 10.45 to 10.46 (#19618)
There is a new release of pcre2lib to address a security issue [1].
It only affects version 10.45.
Only the master branch has version 10.45.

[1] https://github.com/PCRE2Project/pcre2/releases/tag/pcre2-10.46
2025-08-28 21:56:54 +02:00
Peter Kokot
f64c6248b5 Autotools: Update ax_check_compile_flag.m4 to serial 11 (#19127)
```sh
wget -O build/ax_check_compile_flag.m4 \
  https://cgit.git.savannah.gnu.org/cgit/autoconf-archive.git/plain/m4/ax_check_compile_flag.m4
```

New version of AX_CHECK_COMPILE_FLAG macro now adds the -Werror flag
automatically, if GNU-compatible compiler is detected.
2025-08-09 02:03:37 +02:00
Peter Kokot
be70f42de7 Add HAVE_MEMMOVE to ext/pcre (#18862)
The pcre2 library still needs HAVE_MEMMOVE defined to use the system
(C99 standard) memmove() function, otherwise emulation is used. On
Windows, this is already enabled.
2025-06-19 21:49:36 +02:00
Michael Voříšek
355700c904 Remove PCRE2_EXTRA_ALLOW_LOOKAROUND_BSK from pcre compile options
This option is semi-deprecated [1] and shouldn't influence much anyway.
The anticipated BC break is low.

[1] https://github.com/PCRE2Project/pcre2/issues/736#issuecomment-2753974366
[2] https://github.com/PCRE2Project/pcre2/issues/736#issuecomment-2754110610

Closes GH-18150.
2025-03-31 20:01:45 +02:00
Remi Collet
9d4fd7f9b9 Merge branch 'PHP-8.4'
* PHP-8.4:
  Relax test expectation for pcre2lib 10.45 Using e92848789a
2025-03-13 07:48:50 +01:00
Remi Collet
5de019d9bd Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Relax test expectation for pcre2lib 10.45 Using e92848789a
2025-03-13 07:46:55 +01:00
Remi Collet
69480be12a Relax test expectation for pcre2lib 10.45 Using e92848789a
Co-authored-by: Niels Dossche <7771979+nielsdos@users.noreply.github.com>
2025-03-13 07:46:18 +01:00
Niels Dossche
03f97fc34b Avoid unnecessary string refcounting in ext/pcre (#17893) 2025-02-23 00:23:39 +01:00
Niels Dossche
e92848789a Upgrade bundled pcre2lib to 10.45 (#17825) 2025-02-16 12:16:46 +01:00
Gina Peter Banyard
d6cc31cf95 ext/pcre: Refactor preg_replace_callback(_array)() to not pass a useless FCI (#17365)
* ext/pcre: Refactor php_pcre_replace_func_impl() to not rely on an FCI

* ext/pcre: Refactor populate_subpat_array() to take subject as a HashTable*

This makes the assumption the zval is always an array explicit

* ext/pcre: Refactor php_pcre_replace_func_impl()

We don't need the FCI any more, and we always have the subject as a zend_string.

* ext/pcre: Refactor php_pcre_replace_func()

We don't need the FCI any more

* ext/pcre: Refactor php_replace_in_subject_func()

We don't need the FCI any more
Make the Hashtable param const
Throw exception on non string entries

* ext/pcre: Refactor preg_replace_func_impl()

We don't need the FCI anymore
Make the Hashtable params const
Rename function to indicate it is a PHP pcre function

* ext/pcre: Add trampoline tests for preg_replace_callback(_array)()

* ext/pcre: Handle trampolines properly for preg_replace_callback(_array)()

* Revert FCI passing removal
2025-01-08 18:05:06 +00:00
Niels Dossche
dc27acddd6 Fix GH-17122: memory leak in regex
Because the subpattern names are persistent, and the fact that the
symbol table destruction is skipped when using fast_shutdown,
this means the refcounts will not be updated for the destruction of
the arrays that hold the subpattern name keys.
To solve this, detect this situation and duplicate the strings.

Closes GH-17132.
2025-01-06 20:11:36 +01:00
Niels Dossche
5839fc5dd9 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix GH-16184: UBSan address overflowed in ext/pcre/php_pcre.c
2024-10-03 21:12:42 +02:00
Niels Dossche
ddc7a6b1fc Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix GH-16184: UBSan address overflowed in ext/pcre/php_pcre.c
2024-10-03 21:11:25 +02:00
Niels Dossche
c4bb07552e Fix GH-16184: UBSan address overflowed in ext/pcre/php_pcre.c
libpcre2 can return the special value -1 for a non-match.
In this case we get pointer overflow, although it doesn't matter in
practice because the pointer will be in bounds and the copy length will
be 0. Still, we should fix the UBSAN warning.

Closes GH-16205.
2024-10-03 21:10:57 +02:00
David Carlier
f5d4781ee0 Merge branch 'PHP-8.3' into PHP-8.4 2024-10-03 12:48:46 +01:00
David Carlier
1aeb70f83c Merge branch 'PHP-8.2' into PHP-8.3 2024-10-03 12:48:34 +01:00
David Carlier
f453d1ae2a Fix GH-16189: underflow on preg_match/preg_match_all start_offset.
close GH-16191
2024-10-03 12:48:13 +01:00
Ilija Tovilo
ffb440550c Use APPLY_STOP in pcre_clean_cache() (GH-15839)
Once num_clean has reached 0, we never remove any more elements anyway.

Closes GH-15839
2024-09-12 22:32:23 +02:00