1 #ifdef __cplusplus 2 extern "C" { 3 #endif 4 5 #include <stdbool.h> 6 #include <stddef.h> 7 #include <stdint.h> 8 9 /* 10 * buf: input fuzzing data 11 * len: size of the 'buf' data 12 * 13 * Return value: should return 0 14 */ 15 int LLVMFuzzerTestOneInput(const uint8_t* buf, size_t len); 16 17 /* 18 * argc: ptr to main's argc 19 * argv: ptr to main's argv 20 * 21 * Return value: ignored 22 */ 23 int LLVMFuzzerInitialize(int* argc, char*** argv); 24 25 /* 26 * 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 /* 35 * 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 */ 41 void HF_ITER(const uint8_t** buf_ptr, size_t* len_ptr); 42 43 /* 44 * Update comparison map: 45 * 46 * addr: address of original comparison 47 * n: new value (only if better than the old/current value) 48 */ 49 void instrumentUpdateCmpMap(void* addr, unsigned int n); 50 51 /* 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 62 #if defined(__linux__) 63 64 #include <sched.h> 65 66 /* 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 85 #endif /* defined(__linux__) */ 86 87 #ifdef __cplusplus 88 } /* extern "C" */ 89 #endif 90