summaryrefslogtreecommitdiff
path: root/fuzz-sbat.c
blob: 74d313bb8789552417b36d45aca8a1a17f5cdd7c (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
42
43
44
45
46
// SPDX-License-Identifier: BSD-2-Clause-Patent
/*
 * fuzz-sbat-section.c - fuzz our .sbat parsing code
 * Copyright Peter Jones <pjones@redhat.com>
 */

#ifndef SHIM_UNIT_TEST
#define SHIM_UNIT_TEST
#endif
#include "shim.h"

#include <stdio.h>

list_t sbat_var;

BOOLEAN
secure_mode() {
	return 1;
}

int
LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
{
	uint8_t *data_copy;
	EFI_STATUS status = 0;
	size_t n = 0;
	struct sbat_section_entry **entries = NULL;

	if (size < 1)
		return 0;

	data_copy = malloc(size+1);
	if (!data_copy)
		return -1;

	memcpy(data_copy, data, size);
	data_copy[size] = 0;
	status = parse_sbat_section(data_copy, size, &n, &entries);
	cleanup_sbat_section_entries(n, entries);

	free(data_copy);

	return 0;
}

// vim:fenc=utf-8:tw=75:noet