Skip to content

Commit 5bf5753

Browse files
committed
Fuzzer zts stuff
1 parent 3a18b81 commit 5bf5753

File tree

5 files changed

+23
-5
lines changed

5 files changed

+23
-5
lines changed

main/php_version.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/* automatically generated by configure */
22
/* edit configure.ac to change version number */
33
#define PHP_MAJOR_VERSION 8
4-
#define PHP_MINOR_VERSION 4
4+
#define PHP_MINOR_VERSION 3
55
#define PHP_RELEASE_VERSION 0
66
#define PHP_EXTRA_VERSION "-dev"
7-
#define PHP_VERSION "8.4.0-dev"
8-
#define PHP_VERSION_ID 80400
7+
#define PHP_VERSION "8.3.0-dev"
8+
#define PHP_VERSION_ID 80300

sapi/fuzzer/fuzzer-json.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "fuzzer.h"
2121

2222
#include "Zend/zend.h"
23+
#include "main/php.h"
2324
#include "main/php_config.h"
2425
#include "main/php_main.h"
2526

sapi/fuzzer/fuzzer-sapi.c

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,6 @@ static const char HARDCODED_INI[] =
5656
",crypt"
5757
/* openlog() has a known memory-management issue. */
5858
",openlog"
59-
/* Can cause long loops that bypass the executor step limit. */
60-
"\ndisable_classes=InfiniteIterator"
6159
;
6260

6361
static int startup(sapi_module_struct *sapi_module)
@@ -128,6 +126,21 @@ static sapi_module_struct fuzzer_module = {
128126
STANDARD_SAPI_MODULE_PROPERTIES
129127
};
130128

129+
static ZEND_COLD zend_object *disable_class_create_handler(zend_class_entry *class_type) /* {{{ */
130+
{
131+
zend_throw_error(NULL, "Cannot construct class %s, as it is disabled", ZSTR_VAL(class_type->name));
132+
return NULL;
133+
}
134+
135+
static void fuzzer_disable_classes(void)
136+
{
137+
/* Overwrite built-in constructor for InfiniteIterator as it
138+
* can cause long loops that bypass the executor step limit. */
139+
/* Lowercase as this is how the CE as stored */
140+
zend_class_entry *InfiniteIterator_class = zend_hash_str_find(CG(class_table), "infiniteiterator", strlen("infiniteiterator"));
141+
InfiniteIterator_class->create_object = disable_class_create_handler;
142+
}
143+
131144
int fuzzer_init_php(const char *extra_ini)
132145
{
133146
#ifdef __SANITIZE_ADDRESS__
@@ -183,6 +196,8 @@ int fuzzer_request_startup(void)
183196
SIGG(check) = 0;
184197
#endif
185198

199+
fuzzer_disable_classes();
200+
186201
return SUCCESS;
187202
}
188203

sapi/fuzzer/fuzzer-unserialize.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include "fuzzer.h"
1919

2020
#include "Zend/zend.h"
21+
#include "main/php.h"
2122
#include "main/php_config.h"
2223
#include "main/php_main.h"
2324

sapi/fuzzer/fuzzer-unserializehash.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include "fuzzer.h"
1717

1818
#include "Zend/zend.h"
19+
#include "main/php.h"
1920
#include "main/php_config.h"
2021
#include "main/php_main.h"
2122

0 commit comments

Comments
 (0)