summaryrefslogtreecommitdiff
path: root/test/spectre_read_fuzzer.c
blob: a0ca3e6c217613a5e94a222f256a75c66b07d0ef (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
36
37
38
39
40
41
#ifdef __cplusplus
extern "C" {
#endif

#include <stddef.h>
#include <inttypes.h>

#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>

#include "../libspectre/spectre.h"
#include "../libspectre/spectre-utils.h"
#include "../libspectre/ps.h"

int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size);

int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
{
    SpectreDocument *document;

    document = spectre_document_new();
    if(document == NULL) return 0;

    spectre_document_load_from_data(document, (void*)data, size);

    if(spectre_document_status(document))
    {
        spectre_document_free(document);
        return 0;
    }

    spectre_document_free(document);

    return 0;
}

#ifdef __cplusplus
}
#endif