summaryrefslogtreecommitdiffstats
path: root/fuzz/bpf-object-fuzzer.c
blob: 89286e2d44eeb048d36c0bf5c78c3a62f2400f0e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include "libbpf.h"

static int libbpf_print_fn(enum libbpf_print_level level, const char *format, va_list args)
{
	return 0;
}

int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
	struct bpf_object *obj = NULL;
	DECLARE_LIBBPF_OPTS(bpf_object_open_opts, opts);
	int err;

	libbpf_set_print(libbpf_print_fn);

	opts.object_name = "fuzz-object";
	obj = bpf_object__open_mem(data, size, &opts);
	err = libbpf_get_error(obj);
	if (err)
		return 0;

	bpf_object__close(obj);
	return 0;
}