1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 16:22:37 +01:00
Commit Graph

118 Commits

Author SHA1 Message Date
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 Blanc
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
Dmitry Stogov
f83cdce0df Merge branch 'PHP-8.3'
* PHP-8.3:
  Wrap cleanup function call with zend_try.
2024-01-22 10:33:18 +03:00
Dmitry Stogov
9f79a98a4c Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Wrap cleanup function call with zend_try.
2024-01-22 10:33:09 +03:00
Dmitry Stogov
b45e7a613f Wrap cleanup function call with zend_try.
Fizes oss-fuzz #65911
2024-01-22 10:32:04 +03:00
Jorg Adam Sowa
dd141f9e3e add missing keywords to parser fuzzer dict from PHP 7.4 to 8.3 (#13160)
* Added missing keywords to parser fuzzer dict from PHP 7.4 to 8.3

* Added null return type
2024-01-17 01:51:42 +01:00
Peter Kokot
64751a0df0 Merge branch 'PHP-8.3'
* PHP-8.3:
  Set libtool tag per command instead of global one
2024-01-10 09:17:48 +01:00
Peter Kokot
04954f6b2c Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Set libtool tag per command instead of global one
2024-01-10 09:13:39 +01:00
Jan Palus
d57a7767a2 Set libtool tag per command instead of global one
Global --tag=CC defined in configure.ac is not correct in all cases. For example
linking objects that were compiled from C++ sources needs to be done with C++
compiler, however for link mode libtool will prefer compiler indicated with
--tag.

Fixes GH-12349
2024-01-10 09:09:45 +01:00
Cristian Rodríguez
927adfb1a6 Use a single version of mempcpy(3) (#12257)
While __php_mempcpy is only used by ext/standard/crypt_sha*, the
mempcpy "pattern" is used everywhere.

This commit removes __php_mempcpy, adds zend_mempcpy and transforms
open-coded parts into function calls.
2023-12-20 15:16:32 +00:00
Alex Dowad
175b438abe Fix spurious failures of php-fuzz-mbstring 2023-11-28 21:04:17 +02:00
Dmitry Stogov
b46ed399c6 Fix php.ini (add missing "\n") 2023-11-20 11:59:47 +03:00
Daniil Gentili
df286a1b98 Improve JIT config in fuzzer SAPI (#12519)
* Improve JIT config in fuzzer SAPI

* Fix

* Fix

* Update
2023-11-14 21:26:24 +03:00
Niels Dossche
1fe7dc31ef Fix -Wstrict-prototypes warnings in fuzzer SAPI (#11277) 2023-05-20 11:43:30 +02:00
Alex Dowad
5f2587eb25 php-fuzz-mbstring also tests text encoding validation functions
In 6fc8d014df, pakutoma added specialized validation functions for
ISO-2022-JP, JIS, UTF-7, and UTF7-IMAP text. In the future, it is
possible we might add such functions for more legacy text encodings.
Allowing them to be tested by php-fuzz-mbstring may help to catch
bugs, both now and in the future.
2023-03-27 08:17:49 +02:00
Ilija Tovilo
9d5f2f1343 Use new ZSTR_INIT_LITERAL macro (#10879) 2023-03-20 16:19:05 +01:00
Dmitry Stogov
5c5707d44d Make fuzzer respect ZEND_MMAP_AHEAD
Fixes oss-fuzz #55654
2023-02-07 13:13:05 +03:00
Alex Dowad
d5d9900661 When fuzzing mbstring encoding conversion code, compare output with different intermediate buffer sizes
Currently, php-fuzz-mbstring only confirms that no crashes (including
ASAN violations) occur when converting text from one encoding to
another.

Try performing each conversion operation with two different sizes for
the intermediate buffer which is used to pass data from the decoder to
the encoder. If the encoding conversion code is correct, the size of
that intermediate buffer shouldn't matter; we should always get exactly
the same results.

This is a much stricter test, which is more likely to catch bugs.
2023-02-05 20:04:05 +02:00
Max Kellermann
d53ad4b566 main/SAPI: make "ini_entries" a const string 2023-01-04 12:49:48 +00:00
Nikita Popov
5f0cbcff3a Don't set rpath for fuzzers
We used to use the rpath for loading libonig, but this is both no
longer needed and breaks under SystemSan.
2022-09-17 15:44:58 +02:00
Nikita Popov
828c93bedc Fix unserialize dictionary generation
We now have namespaced classes in here, and need to escape the
backslashes.
2022-07-30 17:14:22 +02:00
Alex Dowad
492021168d php_mb_convert_encoding{,_ex} returns zend_string
That's what all existing callers want anyways. This avoids 2
unnecessary copies of the converted string.
2022-05-28 21:53:39 +02:00
Alex Dowad
0154a5ac9f Use fast text conversion filters to implement php_mb_convert_encoding_ex 2022-05-28 21:53:38 +02:00