Files
xen/tools/fuzz/libelf/libelf-fuzzer.c
Roger Pau Monné dec25a2cd1 libelf: don't attempt to parse __xen_guest for PVH
The legacy __xen_guest section doesn't support the PHYS32_ENTRY
elfnote, so it's pointless to attempt to parse the elfnotes from that
section when called from an hvm container.

Pass an hvm boolean parameter to the elf note parsing routine, so that
the respective parsing can be suppressed in case libelf is dealing with
an hvm container.

Suggested-by: Jan Beulich <jbeulich@suse.com>
Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
2021-05-28 09:13:32 +02:00

36 lines
632 B
C

#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:
*/