etc.git


etc

~ scripts and random things
git clone https://github.com/djnnvx/etc.git
log | files | refs | archive

fuzz_iad.c (894B)

      1 /*
      2  * Harness: IAD two-pass parsing via raw_desc_to_iad_array().
      3  */
      4 
      5 #include "fuzz-include/libusb_fuzz.h"
      6 #include "libusb-src/libusb/descriptor.c"
      7 
      8 static int fuzz_one(const uint8_t *data, size_t size)
      9 {
     10     if (size < 1)
     11         return 0;
     12 
     13     struct libusb_interface_association_descriptor_array *iad_array = NULL;
     14     int r = raw_desc_to_iad_array(NULL, data,
     15         (int)(size > (size_t)INT_MAX ? INT_MAX : size), &iad_array);
     16     if (r == LIBUSB_SUCCESS && iad_array)
     17         libusb_free_interface_association_descriptors(iad_array);
     18     return 0;
     19 }
     20 
     21 #ifdef __AFL_FUZZ_TESTCASE_LEN
     22 __AFL_FUZZ_INIT();
     23 int main(void)
     24 {
     25     __AFL_INIT();
     26     uint8_t *buf = __AFL_FUZZ_TESTCASE_BUF;
     27     while (__AFL_LOOP(10000))
     28         fuzz_one(buf, __AFL_FUZZ_TESTCASE_LEN);
     29     return 0;
     30 }
     31 #else
     32 int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
     33 {
     34     return fuzz_one(data, size);
     35 }
     36 #endif