File: fuzz-sbat.c

package info (click to toggle)
shim 15.8-1~deb11u1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 15,096 kB
  • sloc: ansic: 168,639; asm: 1,802; sh: 1,284; makefile: 1,151
file content (46 lines) | stat: -rw-r--r-- 780 bytes parent folder | download | duplicates (3)
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