root/lib/common/fuzzers/strings_fuzzer.c

/* [previous][next][first][last][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. LLVMFuzzerTestOneInput

   1 /*
   2  * Copyright 2024 the Pacemaker project contributors
   3  *
   4  * The version control history for this file may have further details.
   5  *
   6  * This source code is licensed under the GNU Lesser General Public License
   7  * version 2.1 or later (LGPLv2.1+) WITHOUT ANY WARRANTY.
   8  */
   9 
  10 #include <stdint.h>
  11 #include <stdlib.h>
  12 #include <stdio.h>
  13 #include <strings.h>
  14 #include <glib.h>
  15 
  16 #include <crm/common/options.h>
  17 #include <crm/common/util.h>
  18 #include <crm/common/internal.h>
  19 
  20 int
  21 LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
     /* [previous][next][first][last][top][bottom][index][help] */
  22 {
  23     char *ns = NULL;
  24     guint res = 0U;
  25 
  26     if (size < 10) {
  27         return -1; // Do not add input to testing corpus
  28     }
  29     ns = pcmk__assert_alloc(1, size + 1);
  30     memcpy(ns, data, size);
  31     ns[size] = '\0';
  32 
  33     pcmk__numeric_strcasecmp(ns, ns);
  34     pcmk__trim(ns);
  35     pcmk_parse_interval_spec(ns, &res);
  36     crm_get_msec(ns);
  37 
  38     free(ns);
  39     return 0;
  40 }

/* [previous][next][first][last][top][bottom][index][help] */