Coverage Report

Created: 2025-08-29 06:14

/src/util-linux/libmount/src/fuzz.c
Line
Count
Source (jump to first uncovered line)
1
#include "fuzz.h"
2
#include "xalloc.h"
3
#include "mountP.h"
4
5
#include <stdlib.h>
6
#include <stddef.h>
7
8
3.42k
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
9
3.42k
        struct libmnt_table *tb = NULL;
10
3.42k
        FILE *f = NULL;
11
12
3.42k
        if (size == 0)
13
0
                return 0;
14
15
        // 128Kb should be enough to trigger all the issues we're interested in
16
3.42k
        if (size > 131072)
17
10
                return 0;
18
19
3.41k
        tb = mnt_new_table();
20
3.41k
        if (!tb)
21
0
    err_oom();
22
23
3.41k
        f = fmemopen((char*) data, size, "re");
24
3.41k
        if (!f)
25
0
    err(EXIT_FAILURE, "fmemopen() failed");
26
27
3.41k
        mnt_table_enable_comments(tb, TRUE);
28
3.41k
        (void) mnt_table_parse_stream(tb, f, "mountinfo");
29
30
3.41k
        mnt_unref_table(tb);
31
3.41k
        fclose(f);
32
33
3.41k
        return 0;
34
3.41k
}