Coverage Report

Created: 2026-07-16 06:23

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
1.19k
LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
27
1.19k
    if(size >= MAX_PACKET_LEN)
28
7
        return 0;
29
1.18k
    memcpy(message_buf, data, size);
30
1.18k
    message_buf[size] = 0; /* zero terminate */
31
32
1.18k
    struct message m;
33
1.18k
    memset(&m, 0, sizeof(struct message));
34
35
1.18k
    int parseResult = message_parse(&m, message_buf);
36
1.18k
    if(!parseResult)
37
794
        return 0;
38
39
389
    mdns_daemon_t *d = mdnsd_new(QCLASS_IN, 1000);
40
41
389
    inet_addr_t from = {};
42
389
    inet_anyaddr(AF_INET, 2000, &from);
43
389
    mdnsd_in(d, &m, &from);
44
389
    mdnsd_free(d);
45
46
389
    return 0;
47
1.18k
}