summaryrefslogtreecommitdiffhomepage
path: root/fuzzing/nxt_http_h1p_fuzz.c
diff options
context:
space:
mode:
Diffstat (limited to 'fuzzing/nxt_http_h1p_fuzz.c')
-rw-r--r--fuzzing/nxt_http_h1p_fuzz.c23
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: