139 Commits
Author SHA1 Message Date
Yuma Kakei 2295a3504a Fuzz exif thumbnail handling (#24722)
exif_read_data() only reads the thumbnail if $read_thumbnail is true,
and exif_thumbnail() only scans the thumbnail for its dimensions if they
are requested, so the exif fuzzer never reached this code.
2026-10-28 08:13:49 +01:00
Yuma Kakei 6f6964b5b3 Fix JIT fuzzers never enabling the JIT (#24717)
Since the default of opcache.jit changed from "tracing" to "disable"
(c16ad918ba, RFC jit_config_defaults), JIT_G(enabled) is false after
startup and zend_jit_config() rejects every runtime change of
opcache.jit. The function-jit and tracing-jit fuzzers turn the JIT on
at runtime without checking the result, so since PHP 8.4 they have only
been running the VM. The OSS-Fuzz coverage report of 2026-10-24 shows
0.04% line coverage (40/103166) for ext/opcache/jit/.

Start with opcache.jit=off, which keeps the JIT available, and abort if
switching the JIT mode fails, so that this cannot regress silently.
2026-10-26 19:21:39 +01:00
Yuma Kakei 6e215f882e Fix tempnam() not being disabled in the fuzzer SAPI (#24719)
The disable_functions list contains "tempname", which does not exist,
so tempnam() stays available and fuzz inputs can create files in /tmp.
2026-10-26 18:55:05 +01:00
Ilija Tovilo 9705fda1bb Merge branch 'PHP-8.6' into master
* PHP-8.6:
  Add NEWS entry
  Avoid state corruption via bailout
2026-10-21 16:34:56 +02:00
Ilija Tovilo d6373dfe15 Merge branch 'PHP-8.5' into PHP-8.6
* PHP-8.5:
  Add NEWS entry
  Avoid state corruption via bailout
2026-10-21 16:33:23 +02:00
Ilija Tovilo c7273b9ba8 Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
  Add NEWS entry
  Avoid state corruption via bailout
2026-10-21 16:30:04 +02:00
Ilija Tovilo 8a94bb3822 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Add NEWS entry
  Avoid state corruption via bailout
2026-10-21 16:27:03 +02:00
Ilija Tovilo c1a5f468d0 Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Add NEWS entry
  Avoid state corruption via bailout
2026-10-21 16:12:35 +02:00
3584a98bda Avoid state corruption via bailout
- Replace bailout on OOM with UnwindExit
- Properly reset various globals that may be accessed during startup

Fix GHSA-w8hw-w9fx-j79w (CVE-2026-109618)
Fix GHSA-6wmf-4rv5-p3rp (CVE-2026-109619)

Co-authored-by: Ilija Tovilo <ilija.tovilo@me.com>
Co-authored-by: Jakub Zelenka <bukka@php.net>
Co-authored-by: Nora Dossche <7771979+ndossche@users.noreply.github.com>
Co-authored-by: Nicolas Grekas <nicolas.grekas@gmail.com>
2026-10-21 16:06:22 +02:00
Arnaud Le Blanc 090c7c10e5 Merge branch 'PHP-8.6'
* PHP-8.6:
  Fix -Wint-to-pointer-cast warnings in the CALL VM on 32-bit (#24360)
2026-10-19 11:43:52 +02:00
Arnaud Le Blanc 5089b1c4e8 Merge branch 'PHP-8.5' into PHP-8.6
* PHP-8.5:
  Fix -Wint-to-pointer-cast warnings in the CALL VM on 32-bit (#24360)
2026-10-19 11:43:42 +02:00
Marc Bennewitz 4bb88e0367 Fix -Wint-to-pointer-cast warnings in the CALL VM on 32-bit (#24360)
ZEND_VM_ENTER_BIT tags the opline returned by CALL VM handlers. It is
1ULL so that ~ZEND_VM_ENTER_BIT keeps the upper half of 64-bit pointers,
but on 32-bit platforms it widens the tagged pointer expressions to
64 bits, and casting those back to a pointer warns. This breaks
--enable-werror builds where no global VM registers are used, e.g. arm32,
or i386 with --disable-gcc-global-regs.

Use (uintptr_t)1 instead, which is exactly pointer-sized everywhere, also
in the copies of the definition in the JIT and the fuzzer SAPI.
2026-10-19 11:43:04 +02:00
Calvin Buckley 20f4c4d605 sapi: Remove sapi_terminate_process (#23524)
This is unused; this is a vestige of 6c158374ba
and 45e327a672, which set up some timeout code
which was removed in 650c1c0a7d. Remove this
useless function from SAPIs.
2026-09-28 15:06:30 -03:00
Daniel Scherzer 60ddc8fbf1 JSON fuzzer: use options for handling invalid UTF-8 and big strings (#23877)
Previously, the fuzzer only used the default options (`0`) and the
`PHP_JSON_OBJECT_AS_ARRAY` option (`1`). After running the fuzzer on its
existing corpus with `-reduce_inputs=0`, `-runs=100000`, and `-seed=1`, it
failed to reach the code paths for handling big integers and strings, or for
dealing with invalid UTF8, within the allotted 100,000 runs. Those 100,000 runs
resulted in coverage of roughly 2,020 code blocks or edges, and roughly 5,400
"features".

Expand the fuzzer to also run with options that include the
`PHP_JSON_BIGINT_AS_STRING`, `PHP_JSON_INVALID_UTF8_IGNORE`, and
`PHP_JSON_INVALID_UTF8_SUBSTITUTE` flags. The two flags for handling UTF-8 are
not applied used together, since invalid UTF-8 can only be handled one way, but
other than that all combinations of these flags and `PHP_JSON_OBJECT_AS_ARRAY`
are now tested. Repeating the same fuzzing as earlier with the expanded options
results in roughly 2,150 code blocks or edges, and roughly 5,700 "features",
being covered.
2026-09-25 15:33:15 -07:00
Weilin Du d779512be4 Merge branch 'PHP-8.5'
* PHP-8.5:
  sapi/fuzzer: depend on PHP_BINARY_OBJS instead of PHP_SAPI_OBJS (#23394)
2026-08-23 04:51:49 +08:00
Weilin Du ae52a3ed16 Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
  sapi/fuzzer: depend on PHP_BINARY_OBJS instead of PHP_SAPI_OBJS (#23394)
2026-08-23 04:51:09 +08:00
Mrmaxmeier 5284278d97 sapi/fuzzer: depend on PHP_BINARY_OBJS instead of PHP_SAPI_OBJS (#23394)
FUZZER_BUILD links $(PHP_BINARY_OBJS), including
main/internal_functions_cli.lo, but the php-fuzz-* rules list
$(PHP_SAPI_OBJS), including main/internal_functions.lo, as prerequisites.
Building a fuzzer target in isolation from a clean tree therefore fails
because internal_functions_cli.lo has not been built.

Use $(PHP_BINARY_OBJS) for these prerequisites to match the objects linked by
FUZZER_BUILD. This aligns the fuzzer build rules with the CLI, CGI, phpdbg,
and litespeed fragments.

Assisted-By: Claude Opus 5

Closes #23394
2026-08-23 04:50:06 +08:00
Ben Ramsey 27f7bb7eea license-update: sapi/fuzzer source headers
RFC: https://wiki.php.net/rfc/php_license_update
2026-04-11 21:20:54 -05:00
Calvin BuckleyandPeter Kokot 13b83a46cf Bump libtool to serial 63 from 2.5.4 (#21067)
The libtool 1.5.26 is bundled with PHP since the very early days of the
Autotools build system to ease the building process and avoid additional
dependency on the system Libtool. This updates the bundled libtool to
2.5.4 version.

Fixes and implementations:

- Fixed race conditions when building PHP in parallel ("cannot create
  .libs" warnings).
- Implements request https://bugs.php.net/70374 (Update libtool.m4)
- Fixes libtool eating -flto flags.
- Fixes GH-17310 (configure producing errors on macOS)
- Fixes GH-15946 (./configure error when building with NixOS)

Changes:
- Add a script to update autotools files.
- libtool is spread across multiple files; phpize is updated to handle
  this.
- Remove outdated hacks, i.e. for `ar`.
- Remove documentation references to external libtool, as we vendor it.
- `--with-pic` is now `--enable-pic`. Error out on the old flag.
- On macOS linker now uses -undefined dynamic_lookup flag for shared
  extensions and shared embed SAPI (libphp) instead of older
  '-undefined suppress -flat_namespace' combination.

Co-authored-by: Peter Kokot <peterkokot@gmail.com>
2026-03-11 12:37:56 -03:00
Ilija Tovilo eb1d45bd42 Restore opcache_invalidate() fuzzer behavior
The zend_exception_save() and zend_exception_restore() functions were removed in
GH-20256. However, the fuzzer expects to be able to call opcache_invalidate()
even if there was an exception thrown. I'm not sure why exactly, but let's
restore the previous behavior.

Closes OSS-Fuzz #476466130
2026-01-20 15:53:08 +01:00
Ilija Tovilo 084e409694 Remove zend_exception_save() and zend_exception_restore()
These are leftovers from the pre-PHP-7.0 era. This also implicitly solves
GH-20564 by not clearing exceptions before entering the autoloader.

Closes GH-20256
Fixes GH-20564
2026-01-16 20:18:51 +01:00
Ilija Tovilo 7a06f6b4eb [fuzzer][skip ci] Wrap php_request_shutdown() in zend_try (GH-19846)
php_request_shutdown() may also bail. E.g. GH-19844.
2025-09-16 13:06:52 +02:00
Niels Dossche bd4e2c78ac Fix fuzzer runner (#19676) 2025-09-11 22:36:26 +02:00
Niels Dossche a88a5ecbef Fix disabling of InfiniteIterator in fuzzer (#19690)
The canonical way to do this is via `get_constructor` as `create_object`
may not return NULL.
2025-09-04 06:01:58 +02:00
Gina Peter Banyard 326c254c1e sapi/fuzzer: Fix disabling of InfiniteIterator (#19668) 2025-09-02 16:59:30 +01:00
Gina Peter Banyard f4e2e91d4b core: Remove disable_classes INI setting
RFC: https://wiki.php.net/rfc/deprecations_php_8_5#remove_disable_classes_ini_setting

This took longer to merge than expected but the initial motivation from 2 years ago still applied:

As described in the email to the PHP internals list [1] this feature is fundamentally broken and pointless.

Only internal classes can be disable which brings the following observation. On a minimal build of PHP, with only the mandatory extensions enabled, there are 148 classes/interfaces/traits defined. [2]

Other than the SPL ones (and even then), disabling any of these classes will cause issues within the engine.
Moreover, the SPL ones are not a security concern.

Therefore, any other class that can be disabled must come from an extension that can be disabled altogether. And "disabling" a class from an extension without disabling said extension will render it useless anyway.

If a hosting provided is concerned about an extension, then it should not enable it in the first place. Not break it ad hoc.

Considering the above, I cannot see how this functionality was ever useful.

This is in stark contrast to the disable_functions INI setting, which can be used to selectively remove functionality of an extension without breaking it overall.

What makes this setting particularly broken is that it does not unregister the class, it only overwrites the create CE handler to emit a warning and purge the properties and function hashtables. This leads to various use after free, segfaults, and broken expectations for the engine and extensions which define said classes. On top of that, it is possible to actually instantiate such a class (and even classes which actually disallow this like ext/imap) in userland, and pass it to function that are typed against said class without raising a TypeError. However, when trying to do anything with said object stuff is going to explode in countless ways.

[1] https://news-web.php.net/php.internals/120896
[2] https://gist.github.com/Girgias/63d55ba1e50b580412b004046daed02b
2025-08-25 21:16:55 +01:00
Arnaud Le Blanc d1fceeec30 Check stack limit in fuzzer executor
The stack limit is checked when entering execute_ex(), but the fuzzer has
its own execute function and does not call execute_ex().

Add a stack limit check in the fuzzer's execute function.

Closes GH-19391
2025-08-07 08:32:02 +02:00
Niels Dossche bc2d02e3a9 Fix fuzzer after opcache became mandatory (#19292) 2025-07-30 09:01:10 +02:00
Arnaud Le BlancandTim Düsterhus 7b4c14dc10 Make OPcache non-optional
This removes the --enable-opcache/--disable-opcache configure switch. OPcache
is now always builtin. The default value of opcache.enable and
opcache.enable_cli is unchanged.

RFC: https://wiki.php.net/rfc/make_opcache_required

Closes GH-18961.

Co-authored-by: Tim Düsterhus <tim@tideways-gmbh.com>
2025-07-27 09:40:22 +02:00
Niels Dossche dd3a098a9b Disable error handler in fuzzer (#19183)
These are all the same root cause and it's known.
2025-07-19 13:08:21 +02:00
Gina Peter Banyard c33805791d sapi/fuzzer: Fetch function and call it directly instead of using a zval to hold the name (#19030) 2025-07-06 01:29:48 +01:00
Niels Dossche 4152ca5c8a Fix fuzzer support after CALL VM changes (#18491) 2025-05-04 13:25:42 +02:00
Niels Dossche a67f351b67 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix GH-18082: Memory leaks in fuzzer SAPI error paths
2025-03-16 16:38:55 +01:00
Katherine456719 38e553e418 Fix GH-18082: Memory leaks in fuzzer SAPI error paths
Closes GH-18081.
2025-03-16 16:37:59 +01:00
Peter Kokot 1e4ed4adaa Autotools: Sync CS in sapi/fuzzer (#15417)
- AS_VAR_IF macro used
- redundant quotes removed
- PHP_FUZZER_TARGET macro body synced with the rest of the macros in
  php-src
- PHP_FUZZER_TARGET arguments quoted
2024-08-15 11:38:34 +02:00
Peter Kokot 540b9f5bc7 Autotools: Wrap long texts with m4_text_wrap (#15368)
The m4_text_wrap macro wraps the text into a single space separated
string which is wrapped to not exceed the line lenght of 79 characters
by default.
2024-08-13 10:33:17 +02:00
Peter Kokot 575efc0617 Autotools: Quote PHP_ADD_SOURCES* macros arguments (#15146)
- A redundant shell quoted flags argument replaced with Autoconf quotes
  (the PHP_ADD_SOURCES macro already adds the necessary shell quotes
  characters where needed)
- CS synced
2024-07-29 10:08:48 +02:00
Peter Kokot 003e238436 Autotools: Quote and fix PHP_SELECT_SAPI arguments (#15118)
This macro once had also the 5th argument (the build target), which was
removed via 2a6da0f24c. This quotes all
PHP_SELECT_SAPI arguments and removes the redundant ones. The basic
macro usage help text is moved to the macros section from the obsolete
docs file.
2024-07-27 22:46:36 +02:00
Peter Kokot 97afc86437 Autotools: Quote M4 arguments (#15045)
- AC_MSG_CHECKING
- AC_MSG_RESULT
- AC_MSG_WARN
- AC_MSG_ERROR
- AC_MSG_NOTICE
2024-07-21 01:52:17 +02:00
Jorg Adam Sowa 85b7181d7d Added property hooks words in fuzzer parser dict (#14958) 2024-07-14 22:52:25 +02:00
Peter Kokot dc7b67ebc3 Autotools: Sync PHP_ADD_MAKEFILE_FRAGMENT (#14766)
- Macro help text updated for extensions and general usage
- Arguments quoted
- dnl removes redundant newlines in the generated configure script
2024-07-03 13:15:13 +02:00
Peter Kokot dc1cc503db Autotools: Sync PHP_SUBST in sapi (#14753)
- Arguments quoted
- Redundant comments removed (some basic help info is in the
  build/php.m4)
- APXS variable as such isn't used in the generated Makefile, the path
  to the apxs tool is inserted during the configure step directly
2024-07-01 21:04:09 +02:00
Arnaud Le Blanc 11accb5cdf Preferably include from build dir (#13516)
* Include from build dir first

This fixes out of tree builds by ensuring that configure artifacts are included
from the build dir.

Before, out of tree builds would preferably include files from the src dir, as
the include path was defined as follows (ignoring includes from ext/ and sapi/) :

    -I$(top_builddir)/main
    -I$(top_srcdir)
    -I$(top_builddir)/TSRM
    -I$(top_builddir)/Zend
    -I$(top_srcdir)/main
    -I$(top_srcdir)/Zend
    -I$(top_srcdir)/TSRM
    -I$(top_builddir)/

As a result, an out of tree build would include configure artifacts such as
`main/php_config.h` from the src dir.

After this change, the include path is defined as follows:

    -I$(top_builddir)/main
    -I$(top_builddir)
    -I$(top_srcdir)/main
    -I$(top_srcdir)
    -I$(top_builddir)/TSRM
    -I$(top_builddir)/Zend
    -I$(top_srcdir)/Zend
    -I$(top_srcdir)/TSRM

* Fix extension include path for out of tree builds

* Include config.h with the brackets form

`#include "config.h"` searches in the directory containing the including-file
before any other include path. This can include the wrong config.h when building
out of tree and a config.h exists in the source tree.

Using `#include <config.h>` uses exclusively the include path, and gives
priority to the build dir.
2024-06-26 00:26:43 +02:00
Peter Kokot da86eec3db Sync #if/ifdef/defined (#14371)
These are either undefined or defined to value 1 in Autotools and
Windows:
- HAVE_COMMONCRYPTO_COMMONRANDOM_H
- HAVE_EXIF
- HAVE_FOPENCOOKIE
- HAVE_IF_NAMETOINDEX
- HAVE_LIBICONV
- HAVE_SOCKETS
- HAVE_STRUCT_STAT_ST_RDEV
- HAVE_STRUCT_TM_TM_GMTOFF
- HAVE_STRUCT_TM_TM_ZONE

Follow up of GH-5526 (-Wundef)
2024-06-07 23:45:17 +02:00
Cristian Rodríguez 8e62e2b829 Mark multple functions as static (#13864)
* Mark many functions as static

Multiple functions are missing the static qualifier.

* remove unused struct sigactions

struct sigaction act, old_term, old_quit, old_int;
all unused.

* optimizer: minXOR and maxXOR are unused
2024-05-22 13:11:46 +02:00
Peter Kokot 08e2c6fb7b Fix fuzzer result message in configure log (#14278)
The 2nd argument of PHP_ARG_ENABLE can be a check message to avoid
manual AC_MSG_* calls.
2024-05-20 20:46:09 +02:00
Peter Kokot ca3444b1d8 Emit error when building fuzzer with ZTS (#14273)
Thread safety (--enable-zts) is not supported when building fuzzer
(--enable-fuzzer).

Fixes GH-14243
2024-05-20 15:31:33 +02:00
Niels Dossche 14cd67a42a Merge branch 'PHP-8.3'
* PHP-8.3:
  Fix GH-13978: Fuzzer readme still mentions obsolete --enable-json flag (#13983)
2024-04-16 22:17:59 +02:00
Niels Dossche 90388233ed Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix GH-13978: Fuzzer readme still mentions obsolete --enable-json flag (#13983)
2024-04-16 22:17:42 +02:00
Niels Dossche 093d334684 Fix GH-13978: Fuzzer readme still mentions obsolete --enable-json flag (#13983)
[ci skip]
2024-04-16 22:16:51 +02:00