@@ -56,8 +56,6 @@ static const char HARDCODED_INI[] =
56
56
",crypt"
57
57
/* openlog() has a known memory-management issue. */
58
58
",openlog"
59
- /* Can cause long loops that bypass the executor step limit. */
60
- "\ndisable_classes=InfiniteIterator"
61
59
;
62
60
63
61
static int startup (sapi_module_struct * sapi_module )
@@ -128,6 +126,21 @@ static sapi_module_struct fuzzer_module = {
128
126
STANDARD_SAPI_MODULE_PROPERTIES
129
127
};
130
128
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
+
131
144
int fuzzer_init_php (const char * extra_ini )
132
145
{
133
146
#ifdef __SANITIZE_ADDRESS__
@@ -183,6 +196,8 @@ int fuzzer_request_startup(void)
183
196
SIGG (check ) = 0 ;
184
197
#endif
185
198
199
+ fuzzer_disable_classes ();
200
+
186
201
return SUCCESS ;
187
202
}
188
203
0 commit comments