diff options
author | Arjun <pkillarjun@protonmail.com> | 2024-08-02 18:21:12 +0530 |
---|---|---|
committer | Andrew Clayton <a.clayton@nginx.com> | 2024-08-02 17:39:15 +0100 |
commit | e56c4edefa3726ffe86f66fde3cba9e9365bfd61 (patch) | |
tree | 1ec3e67439acf79f6eaef180a5fa6a8845390f11 /fuzzing/nxt_http_h1p_fuzz.c | |
parent | a91b961d620dc17c98b998a9142050defe46b56e (diff) | |
download | unit-e56c4edefa3726ffe86f66fde3cba9e9365bfd61.tar.gz unit-e56c4edefa3726ffe86f66fde3cba9e9365bfd61.tar.bz2 |
fuzzing: code cleanup
Signed-off-by: Arjun <pkillarjun@protonmail.com>
Signed-off-by: Andrew Clayton <a.clayton@nginx.com>
Diffstat (limited to 'fuzzing/nxt_http_h1p_fuzz.c')
-rw-r--r-- | fuzzing/nxt_http_h1p_fuzz.c | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/fuzzing/nxt_http_h1p_fuzz.c b/fuzzing/nxt_http_h1p_fuzz.c index a170463a..6b54431c 100644 --- a/fuzzing/nxt_http_h1p_fuzz.c +++ b/fuzzing/nxt_http_h1p_fuzz.c @@ -42,8 +42,9 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { nxt_mp_t *mp; + nxt_int_t rc; nxt_buf_mem_t buf; - nxt_http_request_t *r_h1p; + nxt_http_request_t *req; nxt_http_request_parse_t rp; if (size < KMININPUTLENGTH || size > KMAXINPUTLENGTH) { @@ -55,8 +56,8 @@ LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) return 0; } - nxt_memzero(&rp, sizeof(nxt_http_request_parse_t)); - if (nxt_http_parse_request_init(&rp, mp) != NXT_OK) { + req = nxt_mp_zget(mp, sizeof(nxt_http_request_t)); + if (req == NULL) { goto failed; } @@ -65,19 +66,21 @@ LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) buf.pos = buf.start; buf.free = buf.end; - if (nxt_http_parse_request(&rp, &buf) != NXT_DONE) { - goto failed; - } + req->mem_pool = mp; - r_h1p = nxt_mp_zget(mp, sizeof(nxt_http_request_t)); + nxt_memzero(&rp, sizeof(nxt_http_request_parse_t)); - if (r_h1p == NULL) { + rc = nxt_http_parse_request_init(&rp, mp); + if (rc != NXT_OK) { goto failed; } - r_h1p->mem_pool = mp; + rc = nxt_http_parse_request(&rp, &buf); + if (rc != NXT_DONE) { + goto failed; + } - nxt_http_fields_process(rp.fields, &nxt_h1p_fields_hash, r_h1p); + nxt_http_fields_process(rp.fields, &nxt_h1p_fields_hash, req); failed: |