summaryrefslogtreecommitdiff
path: root/tools/fuzz/libelf/libelf-fuzzer.c
blob: 84fb84720fa92d514d8f4f337e6c4445563b6ac6 (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 <inttypes.h>
#include <stddef.h>
#include <stdlib.h>
#include <string.h>

#include <xen/libelf/libelf.h>

int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
{
    struct elf_binary elf_buf, *elf;
    struct elf_dom_parms parms;

    elf = &elf_buf;

    memset(elf, 0, sizeof(*elf));
    if ( elf_init(elf, (const char *)data, size) < 0 )
        return -1;

    elf_parse_binary(elf);
    elf_xen_parse(elf, &parms, false);
    elf_xen_parse(elf, &parms, true);

    return 0;
}


/*
 * Local variables:
 * mode: C
 * c-file-style: "BSD"
 * c-basic-offset: 4
 * tab-width: 4
 * indent-tabs-mode: nil
 * End:
 */