MCPcopy Create free account
hub / github.com/OpenSIPS/opensips / LLVMFuzzerTestOneInput

Function LLVMFuzzerTestOneInput

test/fuzz/fuzz_core_funcs.c:98–135  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

96}
97
98int LLVMFuzzerTestOneInput(const char *data, size_t size) {
99 str buf;
100 const int ncmds = count_noparam_cmds();
101 struct socket_info si = {};
102
103 if (size <= ncmds + 1) {
104 return 0;
105 }
106
107 struct sip_msg msg = {};
108 msg.buf = (char *)data;
109 msg.len = size - ncmds;
110
111 if (parse_msg(msg.buf, msg.len, &msg) != 0)
112 goto out;
113 if (msg.via1 == NULL || msg.via1->error != PARSE_OK)
114 goto out;
115 msg.rcv.src_ip.af = AF_INET;
116 msg.rcv.src_port = (unsigned short)66666;
117 for (int i = 0; i < ncmds; i++) {
118 const cmd_export_t *cmd = pick_some_command(data[size - ncmds + i]);
119 if (cmd == NULL)
120 continue;
121 cmd->function(&msg, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
122 }
123 for (int i = 0; i < nspecs; i++) {
124 pv_value_t v = {};
125
126 pv_specs[i].getf(&msg, &pv_specs[i].pvp, &v);
127 }
128 buf.s = build_req_buf_from_sip_req(&msg, (unsigned int*)&buf.len,
129 &si, PROTO_UDP, NULL, 0 /*flags*/);
130 if (buf.s)
131 pkg_free(buf.s);
132out:
133 free_sip_msg(&msg);
134 return 0;
135}

Callers

nothing calls this directly

Calls 4

count_noparam_cmdsFunction · 0.85
pick_some_commandFunction · 0.85
free_sip_msgFunction · 0.85

Tested by

no test coverage detected