Coverage Report

Created: 2023-06-07 06:04

/src/kamailio/misc/fuzz/fuzz_parse_msg.c
Line
Count
Source
1
#include "../config.h"
2
#include "../parser/sdp/sdp.h"
3
#include "../parser/parse_uri.c"
4
#include "../parser/parse_hname2.h"
5
#include "../parser/contact/parse_contact.h"
6
#include "../parser/parse_from.h"
7
#include "../parser/parse_to.h"
8
#include "../parser/parse_rr.h"
9
#include "../parser/parse_refer_to.h"
10
#include "../parser/parse_ppi_pai.h"
11
#include "../parser/parse_privacy.h"
12
#include "../parser/parse_diversion.h"
13
#include "../parser/parse_identityinfo.h"
14
#include "../parser/parse_disposition.h"
15
16
2
int LLVMFuzzerInitialize(int *argc, char ***argv) {
17
2
    ksr_hname_init_index();
18
2
    return 0;
19
2
}
20
21
int
22
18.9k
LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
23
18.9k
    sip_msg_t orig_inv = { };
24
18.9k
    orig_inv.buf = (char*)data;
25
18.9k
    orig_inv.len = size;
26
27
18.9k
    if(size >= 4*BUF_SIZE) {
28
        /* test with larger message than core accepts, but not indefinitely large */
29
5
        return 0;
30
5
    }
31
32
18.9k
    if (parse_msg(orig_inv.buf, orig_inv.len, &orig_inv) < 0) {
33
4.50k
        goto cleanup;
34
4.50k
    }
35
36
14.4k
    parse_headers(&orig_inv, HDR_EOH_F, 0);
37
38
14.4k
    parse_sdp(&orig_inv);
39
40
14.4k
    parse_from_header(&orig_inv);
41
42
14.4k
    parse_from_uri(&orig_inv);
43
44
14.4k
    parse_to_header(&orig_inv);
45
46
14.4k
    parse_to_uri(&orig_inv);
47
48
14.4k
    parse_contact_headers(&orig_inv);
49
50
14.4k
    parse_refer_to_header(&orig_inv);
51
52
14.4k
    parse_pai_header(&orig_inv);
53
54
14.4k
    parse_diversion_header(&orig_inv);
55
56
14.4k
    parse_privacy(&orig_inv);
57
58
14.4k
    parse_content_disposition(&orig_inv);
59
60
14.4k
    parse_identityinfo_header(&orig_inv);
61
62
14.4k
    parse_record_route_headers(&orig_inv);
63
64
14.4k
    parse_route_headers(&orig_inv);
65
66
14.4k
    str uri;
67
14.4k
    get_src_uri(&orig_inv, 0, &uri);
68
69
14.4k
    str ssock;
70
14.4k
    get_src_address_socket(&orig_inv, &ssock);
71
72
18.9k
cleanup:
73
18.9k
    free_sip_msg(&orig_inv);
74
75
18.9k
    return 0;
76
14.4k
}