Skip to content

Commit bee1070

Browse files
authored
gh-73691: Increase size limits in _xxtestfuzz (#99070)
Now that our int<->str conversions are size limited and we have the _pylong module handling larger integers, we don't need to limit everything just to avoid wasting time in the quadratic time DoS-like case while fuzzing. We can tweak these further after seeing how this goes.
1 parent 0ee59a9 commit bee1070

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

Modules/_xxtestfuzz/fuzzer.c

+6-3
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ static int fuzz_struct_unpack(const char* data, size_t size) {
142142
}
143143

144144

145-
#define MAX_JSON_TEST_SIZE 0x10000
145+
#define MAX_JSON_TEST_SIZE 0x100000
146146

147147
PyObject* json_loads_method = NULL;
148148
/* Called by LLVMFuzzerTestOneInput for initialization */
@@ -335,7 +335,7 @@ static int fuzz_sre_match(const char* data, size_t size) {
335335
return 0;
336336
}
337337

338-
#define MAX_CSV_TEST_SIZE 0x10000
338+
#define MAX_CSV_TEST_SIZE 0x100000
339339
PyObject* csv_module = NULL;
340340
PyObject* csv_error = NULL;
341341
/* Called by LLVMFuzzerTestOneInput for initialization */
@@ -393,7 +393,7 @@ static int fuzz_csv_reader(const char* data, size_t size) {
393393
return 0;
394394
}
395395

396-
#define MAX_AST_LITERAL_EVAL_TEST_SIZE 0x10000
396+
#define MAX_AST_LITERAL_EVAL_TEST_SIZE 0x100000
397397
PyObject* ast_literal_eval_method = NULL;
398398
/* Called by LLVMFuzzerTestOneInput for initialization */
399399
static int init_ast_literal_eval(void) {
@@ -459,6 +459,9 @@ int LLVMFuzzerInitialize(int *argc, char ***argv) {
459459
PyConfig config;
460460
PyConfig_InitPythonConfig(&config);
461461
config.install_signal_handlers = 0;
462+
/* Raise the limit above the default allows exercising larger things
463+
* now that we fall back to the _pylong module for large values. */
464+
config.int_max_str_digits = 8086;
462465
PyStatus status;
463466
status = PyConfig_SetBytesString(&config, &config.program_name, *argv[0]);
464467
if (PyStatus_Exception(status)) {

0 commit comments

Comments
 (0)