Skip to content

Commit 1a77956

Browse files
committed
Fuzzer zts stuff
1 parent 53fbaf4 commit 1a77956

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

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

0 commit comments

Comments
 (0)