Coverage Report

Created: 2026-08-14 07:31

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/open62541_15/tests/fuzz/fuzz_mdns_message.cc
Line
Count
Source
1
/* This Source Code Form is subject to the terms of the Mozilla Public
2
 * License, v. 2.0. If a copy of the MPL was not distributed with this
3
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
4
 *
5
 *    Copyright 2019 (c) fortiss (Author: Stefan Profanter)
6
 */
7
8
#include <cstdint>
9
#include <cstdio>
10
#include <cstring>
11
#include <cstdlib>
12
#include <open62541/config.h>
13
14
extern "C" {
15
#include "mdnsd.h"
16
#include "inet.h"
17
}
18
19
unsigned char message_buf[MAX_PACKET_LEN];
20
21
/*
22
** Main entry point.  The fuzzer invokes this function with each
23
** fuzzed input.
24
*/
25
extern "C" int
26
2.35k
LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
27
2.35k
    if(size >= MAX_PACKET_LEN)
28
10
        return 0;
29
2.34k
    memcpy(message_buf, data, size);
30
2.34k
    message_buf[size] = 0; /* zero terminate */
31
32
2.34k
    struct message m;
33
2.34k
    memset(&m, 0, sizeof(struct message));
34
35
2.34k
    int parseResult = message_parse(&m, message_buf);
36
2.34k
    if(!parseResult)
37
710
        return 0;
38
39
1.63k
    mdns_daemon_t *d = mdnsd_new(QCLASS_IN, 1000);
40
41
1.63k
    inet_addr_t from = {};
42
1.63k
    inet_anyaddr(AF_INET, 2000, &from);
43
1.63k
    mdnsd_in(d, &m, &from);
44
1.63k
    mdnsd_free(d);
45
46
1.63k
    return 0;
47
2.34k
}