Coverage Report

Created: 2025-06-13 06:25

/src/systemd/src/udev/net/fuzz-link-parser.c
Line
Count
Source
1
/* SPDX-License-Identifier: LGPL-2.1-or-later */
2
3
#include "fd-util.h"
4
#include "fuzz.h"
5
#include "link-config.h"
6
#include "tmpfile-util.h"
7
8
9.04k
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
9
9.04k
        _cleanup_(link_config_ctx_freep) LinkConfigContext *ctx = NULL;
10
9.04k
        _cleanup_(unlink_tempfilep) char filename[] = "/tmp/fuzz-link-config.XXXXXX";
11
9.04k
        _cleanup_fclose_ FILE *f = NULL;
12
13
9.04k
        if (outside_size_range(size, 0, 65536))
14
5
                return 0;
15
16
9.03k
        fuzz_setup_logging();
17
18
9.03k
        assert_se(fmkostemp_safe(filename, "r+", &f) == 0);
19
9.03k
        if (size != 0)
20
9.03k
                assert_se(fwrite(data, size, 1, f) == 1);
21
22
9.03k
        fflush(f);
23
9.03k
        assert_se(link_config_ctx_new(&ctx) >= 0);
24
9.03k
        (void) link_load_one(ctx, filename);
25
9.03k
        return 0;
26
9.04k
}