blob: 7af5b607041726d698402eb7b4524292d1126ae9 [file] [log] [blame]
Robert Swieckif827c982017-06-01 16:02:39 +02001#ifdef __cplusplus
2extern "C" {
3#endif
4
Robert Swiecki79255592017-06-01 16:50:56 +02005#include <stdbool.h>
Robert Swiecki67ed6c12017-06-06 21:49:07 +02006#include <stddef.h>
Robert Swiecki79255592017-06-01 16:50:56 +02007#include <stdint.h>
8
Robert Swiecki74c23a82017-06-01 15:58:45 +02009/*
10 * buf: input fuzzing data
11 * len: size of the 'buf' data
12 *
13 * Return value: should return 0
14 */
Robert Swieckicabf6e72017-06-01 16:12:23 +020015 int LLVMFuzzerTestOneInput(const uint8_t * buf, size_t len);
Robert Swiecki74c23a82017-06-01 15:58:45 +020016
17/*
18 * argc: ptr to main's argc
19 * argv: ptr to main's argv
20 *
21 * Return value: ignored
22 */
Robert Swieckif827c982017-06-01 16:02:39 +020023 int LLVMFuzzerInitialize(int *argc, char ***argv);
Robert Swiecki74c23a82017-06-01 15:58:45 +020024
25/*
Robert Swieckif98a9272017-06-02 13:56:42 +020026 * Data: data to mutate
27 * Size: size of the data to mutate
28 * MaxSize: maximum size of the destination buffer
29 *
30 * Return value: size of the mutated buffer
31 */
32 size_t LLVMFuzzerMutate(uint8_t * Data, size_t Size, size_t MaxSize);
33
34/*
Robert Swiecki74c23a82017-06-01 15:58:45 +020035 *
36 * An alternative for LLVMFuzzerTestOneInput()
37 *
38 * buf_ptr: will be set to input fuzzing data
39 * len_ptr: will be set to the size of the input fuzzing data
40 */
Robert Swieckicabf6e72017-06-01 16:12:23 +020041 void HF_ITER(const uint8_t ** buf_ptr, size_t * len_ptr);
Robert Swieckif827c982017-06-01 16:02:39 +020042
Robert Swieckifcf85112017-06-27 23:57:32 +020043/*
44 * Update comparison map:
45 *
46 * addr: address of original comparison
47 * n: new value (only if better than the old/current value)
48 */
Robert Swiecki659afb72017-06-28 00:03:39 +020049 void instrumentCmpMap(void *addr, unsigned int n);
Robert Swieckifcf85112017-06-27 23:57:32 +020050
Robert Swieckic650d342017-07-11 18:32:14 +020051/*
52 * Instrumented comparison functions
53 */
54 int hfuzz_strcmp(const char *s1, const char *s2, void *addr);
55 int hfuzz_strcasecmp(const char *s1, const char *s2, void *addr);
56 int hfuzz_strncmp(const char *s1, const char *s2, size_t n, void *addr);
57 int hfuzz_strncasecmp(const char *s1, const char *s2, size_t n, void *addr);
58 char *hfuzz_strstr(const char *haystack, const char *needle, void *addr);
59 char *hfuzz_strcasestr(const char *haystack, const char *needle, void *addr);
60 int hfuzz_memcmp(const void *m1, const void *m2, size_t n, void *addr);
61
Robert Swiecki0061b222017-06-01 16:49:35 +020062#if defined(__linux__)
Robert Swiecki649b89d2017-06-01 16:42:49 +020063
Robert Swieckic6802372017-06-16 19:35:20 +020064#include <sched.h>
65
Robert Swiecki649b89d2017-06-01 16:42:49 +020066/*
67 * Enter Linux namespaces
68 *
69 * cloneFlags: see 'man unshare'
70 */
71 bool linuxEnterNs(uintptr_t cloneFlags);
72/*
73 * Bring network interface up
74 *
75 * ifacename: name of the interface, typically "lo"
76 */
77 bool linuxIfaceUp(const char *ifacename);
78/*
79 * Mount tmpfs over a mount point
80 *
81 * dst: mount point for tmfs
82 */
83 bool linuxMountTmpfs(const char *dst);
84
Robert Swiecki0061b222017-06-01 16:49:35 +020085#endif /* defined(__linux__) */
Robert Swiecki649b89d2017-06-01 16:42:49 +020086
Robert Swieckif827c982017-06-01 16:02:39 +020087#ifdef __cplusplus
88} /* extern "C" */
89#endif