Skip to content

Commit

Permalink
Add a first fuzzer for the parser.
Browse files Browse the repository at this point in the history
PR-URL: nodejs#506
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com>
  • Loading branch information
DavidKorczynski authored and bnoordhuis committed Apr 14, 2020
1 parent 2343fd6 commit 7af127d
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions fuzzers/fuzz_parser.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include "http_parser.h"

int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
{
static const http_parser_settings settings_null = {
.on_message_begin = 0
, .on_header_field = 0
,.on_header_value = 0
,.on_url = 0
,.on_status = 0
,.on_body = 0
,.on_headers_complete = 0
,.on_message_complete = 0
,.on_chunk_header = 0
,.on_chunk_complete = 0
};

http_parser parser;
http_parser_init(&parser, HTTP_BOTH);
http_parser_execute(&parser, &settings_null, (char*)data, size);

return 0;
}

0 comments on commit 7af127d

Please sign in to comment.