| 96 | } |
| 97 | |
| 98 | int 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); |
| 132 | out: |
| 133 | free_sip_msg(&msg); |
| 134 | return 0; |
| 135 | } |
nothing calls this directly
no test coverage detected