Module: kamailio
Branch: master
Commit: 199f13a7dfac8cd817850c6a6afe5ba510835418
URL:
https://github.com/kamailio/kamailio/commit/199f13a7dfac8cd817850c6a6afe5ba…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: GitHub <noreply(a)github.com>
Date: 2021-09-02T19:53:03+02:00
Merge pull request #2842 from DavidKorczynski/master
misc: fuzz: add msg parse fuzzer
---
Added: misc/fuzz/fuzz_parse_msg.c
---
Diff:
https://github.com/kamailio/kamailio/commit/199f13a7dfac8cd817850c6a6afe5ba…
Patch:
https://github.com/kamailio/kamailio/commit/199f13a7dfac8cd817850c6a6afe5ba…
---
diff --git a/misc/fuzz/fuzz_parse_msg.c b/misc/fuzz/fuzz_parse_msg.c
new file mode 100644
index 0000000000..ef656abd3a
--- /dev/null
+++ b/misc/fuzz/fuzz_parse_msg.c
@@ -0,0 +1,44 @@
+#include "../parser/sdp/sdp.h"
+#include "../parser/parse_uri.c"
+#include "../parser/parse_hname2.h"
+#include "../parser/contact/parse_contact.h"
+#include "../parser/parse_refer_to.h"
+#include "../parser/parse_ppi_pai.h"
+#include "../parser/parse_privacy.h"
+#include "../parser/parse_diversion.h"
+
+int LLVMFuzzerInitialize(int *argc, char ***argv) {
+ ksr_hname_init_index();
+ return 0;
+}
+
+int
+LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
+ sip_msg_t orig_inv = { };
+ orig_inv.buf = (char*)data;
+ orig_inv.len = size;
+ if (parse_msg(orig_inv.buf, orig_inv.len, &orig_inv) < 0) {
+ goto cleanup;
+ }
+
+ parse_sdp(&orig_inv);
+
+ parse_headers(&orig_inv, HDR_TO_F, 0);
+
+ parse_contact_header(&orig_inv);
+
+ parse_refer_to_header(&orig_inv);
+
+ parse_to_header(&orig_inv);
+
+ parse_pai_header(&orig_inv);
+
+ parse_diversion_header(&orig_inv);
+
+ parse_privacy(&orig_inv);
+
+cleanup:
+ free_sip_msg(&orig_inv);
+
+ return 0;
+}