Home | History | Annotate | Download | only in libhfuzz
      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 void HonggfuzzFetchData(const uint8_t** buf_ptr, size_t* len_ptr);
     43 
     44 #if defined(__linux__)
     45 
     46 #include <sched.h>
     47 
     48 /*
     49  * Enter Linux namespaces
     50  *
     51  * cloneFlags: see 'man unshare'
     52  */
     53 bool linuxEnterNs(uintptr_t cloneFlags);
     54 /*
     55  * Bring network interface up
     56  *
     57  * ifacename: name of the interface, typically "lo"
     58  */
     59 bool linuxIfaceUp(const char* ifacename);
     60 /*
     61  * Mount tmpfs over a mount point
     62  *
     63  * dst: mount point for tmfs
     64  */
     65 bool linuxMountTmpfs(const char* dst);
     66 
     67 #endif /* defined(__linux__) */
     68 
     69 #ifdef __cplusplus
     70 } /* extern "C" */
     71 #endif
     72