Coverage Report

Created: 2026-08-08 06:57

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/systemd/src/journal/fuzz-journald-stream.c
Line
Count
Source
1
/* SPDX-License-Identifier: LGPL-2.1-or-later */
2
3
#include <linux/sockios.h>
4
#include <sys/ioctl.h>
5
#include <unistd.h>
6
7
#include "sd-event.h"
8
9
#include "fd-util.h"
10
#include "fuzz.h"
11
#include "fuzz-journald-util.h"
12
#include "journald-stream.h"
13
14
1.11k
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
15
1.11k
        _cleanup_close_pair_ int stream_fds[2] = EBADF_PAIR;
16
1.11k
        _cleanup_(manager_freep) Manager *m = NULL;
17
1.11k
        StdoutStream *stream;
18
1.11k
        int v, fd0;
19
20
1.11k
        if (outside_size_range(size, 1, 65536))
21
10
                return 0;
22
23
1.10k
        fuzz_setup_logging();
24
25
1.10k
        assert_se(socketpair(AF_UNIX, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0, stream_fds) >= 0);
26
1.10k
        dummy_manager_new(&m, NULL, 0);
27
28
1.10k
        assert_se(stdout_stream_install(m, stream_fds[0], &stream) >= 0);
29
1.10k
        fd0 = TAKE_FD(stream_fds[0]); /* avoid double close */
30
31
1.10k
        assert_se(write(stream_fds[1], data, size) == (ssize_t) size);
32
4.35k
        while (ioctl(fd0, SIOCINQ, &v) == 0 && v)
33
3.24k
                sd_event_run(m->event, UINT64_MAX);
34
35
1.10k
        if (m->n_stdout_streams > 0)
36
870
                stdout_stream_terminate(stream);
37
38
1.10k
        return 0;
39
1.11k
}