Coverage Report

Created: 2024-10-12 00:30

/src/pacemaker/lib/common/fuzzers/strings_fuzzer.c
Line
Count
Source
1
/*
2
 * Copyright 2024 the Pacemaker project contributors
3
 *
4
 * The version control history for this file may have further details.
5
 *
6
 * This source code is licensed under the GNU Lesser General Public License
7
 * version 2.1 or later (LGPLv2.1+) WITHOUT ANY WARRANTY.
8
 */
9
10
#include <stdint.h>
11
#include <stdlib.h>
12
#include <stdio.h>
13
#include <strings.h>
14
#include <glib.h>
15
16
#include <crm/common/options.h>
17
#include <crm/common/util.h>
18
#include <crm/common/internal.h>
19
20
int
21
LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
22
3.11k
{
23
3.11k
    char *ns = NULL;
24
3.11k
    guint res = 0U;
25
26
3.11k
    if (size < 10) {
27
16
        return -1; // Do not add input to testing corpus
28
16
    }
29
3.09k
    ns = pcmk__assert_alloc(1, size + 1);
30
3.09k
    memcpy(ns, data, size);
31
3.09k
    ns[size] = '\0';
32
33
3.09k
    pcmk__numeric_strcasecmp(ns, ns);
34
3.09k
    pcmk__trim(ns);
35
3.09k
    pcmk_parse_interval_spec(ns, &res);
36
3.09k
    crm_get_msec(ns);
37
38
3.09k
    free(ns);
39
3.09k
    return 0;
40
3.11k
}