(root)/
util-linux-2.39/
libmount/
src/
fuzz.c
       1  #include "fuzz.h"
       2  #include "xalloc.h"
       3  #include "mountP.h"
       4  
       5  #include <stdlib.h>
       6  #include <stddef.h>
       7  #include <stdint.h>
       8  
       9  int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
      10          struct libmnt_table *tb = NULL;
      11          FILE *f = NULL;
      12  
      13          if (size == 0)
      14                  return 0;
      15  
      16          // 128Kb should be enough to trigger all the issues we're interested in
      17          if (size > 131072)
      18                  return 0;
      19  
      20          tb = mnt_new_table();
      21          if (!tb)
      22  		err_oom();
      23  
      24          f = fmemopen((char*) data, size, "re");
      25          if (!f)
      26  		err(EXIT_FAILURE, "fmemopen() failed");
      27  
      28          mnt_table_enable_comments(tb, TRUE);
      29          (void) mnt_table_parse_stream(tb, f, "mountinfo");
      30  
      31          mnt_unref_table(tb);
      32          fclose(f);
      33  
      34          return 0;
      35  }