summaryrefslogtreecommitdiffstats
path: root/fluent-bit/tests/internal/fuzzers/strp_fuzzer.c
blob: 3de21c7a978d589c5a96c89f7e93cbd31f641bb2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include <stdint.h>
#include <string.h>
#include <stdlib.h>
#include <fluent-bit/flb_time.h>
#include <fluent-bit/flb_parser.h>
#include <msgpack.h>
#include <fluent-bit/flb_info.h>
#include <fluent-bit/flb_mem.h>
#include <fluent-bit/flb_pack.h>
#include <fluent-bit/flb_utils.h>
#include <fluent-bit/flb_version.h>
#include <fluent-bit/flb_strptime.h>

#include "flb_fuzz_header.h"

int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
{
    if (size < 40) {
        return 0;
    }

    /* Set fuzzer-malloc chance of failure */
    flb_malloc_mod = 25000;
    flb_malloc_p = 0;

    char *fmt = get_null_terminated(size - 30, &data, &size);
    char *buf = get_null_terminated(size, &data, &size);

    struct tm tt;
    flb_strptime(buf, fmt, &tt);

    flb_free(buf);
    flb_free(fmt);
    return 0;
}