From d26127888db1fd0ac734947ef309d2998b0ea12f Mon Sep 17 00:00:00 2001 From: Arjun Date: Fri, 2 Aug 2024 15:21:25 +0530 Subject: [PATCH] fuzzing: updated JSON target Added 'nxt_conf_json_length' check for extra coverage. --- fuzzing/nxt_json_fuzz.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/fuzzing/nxt_json_fuzz.c b/fuzzing/nxt_json_fuzz.c index cfeb395da..5e0f52758 100644 --- a/fuzzing/nxt_json_fuzz.c +++ b/fuzzing/nxt_json_fuzz.c @@ -31,12 +31,13 @@ LLVMFuzzerInitialize(int *argc, char ***argv) int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { - nxt_mp_t *mp; - nxt_str_t input; - nxt_thread_t *thr; - nxt_runtime_t *rt; - nxt_conf_value_t *conf; - nxt_conf_validation_t vldt; + nxt_mp_t *mp; + nxt_str_t input; + nxt_thread_t *thr; + nxt_runtime_t *rt; + nxt_conf_value_t *conf; + nxt_conf_validation_t vldt; + nxt_conf_json_pretty_t pretty; if (size < KMININPUTLENGTH || size > KMAXINPUTLENGTH) { return 0; @@ -65,6 +66,11 @@ LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) goto failed; } + nxt_memzero(&pretty, sizeof(nxt_conf_json_pretty_t)); + + nxt_conf_json_length(conf, NULL); + nxt_conf_json_length(conf, &pretty); + nxt_memzero(&vldt, sizeof(nxt_conf_validation_t)); vldt.pool = nxt_mp_create(1024, 128, 256, 32);