diff --git a/fuzzers/cib_file_fuzzer.c b/fuzzers/cib_file_fuzzer.c index 36adf1b369..1bd1d2b877 100644 --- a/fuzzers/cib_file_fuzzer.c +++ b/fuzzers/cib_file_fuzzer.c @@ -1,48 +1,48 @@ /* * Copyright 2024 the Pacemaker project contributors * * The version control history for this file may have further details. * * This source code is licensed under the GNU Lesser General Public License * version 2.1 or later (LGPLv2.1+) WITHOUT ANY WARRANTY. */ #include #include #include #include #include int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { char *filename = NULL; int fd = 0; // Have at least some data if (size < 5) { - return 0; + return -1; // Do not add input to testing corpus } filename = crm_strdup_printf("%s/libfuzzer.XXXXXX", pcmk__get_tmpdir()); fd = mkstemp(filename); if (fd == -1) { free(filename); return 0; } if (write(fd, data, size) < 0) { close(fd); unlink(filename); free(filename); return 0; } close(fd); cib_file_read_and_verify(filename, NULL, NULL); unlink(filename); free(filename); return 0; } diff --git a/fuzzers/iso8601_fuzzer.c b/fuzzers/iso8601_fuzzer.c index 3747c1d878..0e151c6dbd 100644 --- a/fuzzers/iso8601_fuzzer.c +++ b/fuzzers/iso8601_fuzzer.c @@ -1,48 +1,46 @@ /* * Copyright 2024 the Pacemaker project contributors * * The version control history for this file may have further details. * * This source code is licensed under the GNU Lesser General Public License * version 2.1 or later (LGPLv2.1+) WITHOUT ANY WARRANTY. */ #include #include #include #include #include int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { char *ns = NULL; char *result = NULL; time_t epoch = 0; pcmk__time_hr_t *now = NULL; crm_time_period_t *period = NULL; // Ensure we have enough data. if (size < 10) { - return 0; + return -1; // Do not add input to testing corpus } ns = pcmk__assert_alloc(1, size + 1); memcpy(ns, data, size); - ns[size] = '\0'; period = crm_time_parse_period(ns); crm_time_free_period(period); now = pcmk__time_hr_new(ns); pcmk__time_hr_free(now); - epoch = 0; now = pcmk__time_hr_now(&epoch); result = pcmk__time_format_hr(ns, now); pcmk__time_hr_free(now); free(result); free(ns); return 0; } diff --git a/fuzzers/strings_fuzzer.c b/fuzzers/strings_fuzzer.c index 7b99964189..f8dfc8e39f 100644 --- a/fuzzers/strings_fuzzer.c +++ b/fuzzers/strings_fuzzer.c @@ -1,40 +1,40 @@ /* * Copyright 2024 the Pacemaker project contributors * * The version control history for this file may have further details. * * This source code is licensed under the GNU Lesser General Public License * version 2.1 or later (LGPLv2.1+) WITHOUT ANY WARRANTY. */ #include #include #include #include #include #include #include #include int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { char *ns = NULL; guint res = 0U; if (size < 10) { - return 0; + return -1; // Do not add input to testing corpus } ns = pcmk__assert_alloc(1, size + 1); memcpy(ns, data, size); ns[size] = '\0'; pcmk__numeric_strcasecmp(ns, ns); pcmk__trim(ns); pcmk_parse_interval_spec(ns, &res); crm_get_msec(ns); free(ns); return 0; } diff --git a/fuzzers/utils_fuzzer.c b/fuzzers/utils_fuzzer.c index 4fafbd79f9..2cb3a5339b 100644 --- a/fuzzers/utils_fuzzer.c +++ b/fuzzers/utils_fuzzer.c @@ -1,34 +1,34 @@ /* * Copyright 2024 the Pacemaker project contributors * * The version control history for this file may have further details. * * This source code is licensed under the GNU Lesser General Public License * version 2.1 or later (LGPLv2.1+) WITHOUT ANY WARRANTY. */ #include #include #include #include #include int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { char *ns = NULL; guint result = 0U; if (size < 10) { - return 0; + return -1; // Do not add input to testing corpus } ns = pcmk__assert_alloc(1, size + 1); memcpy(ns, data, size); ns[size] = '\0'; pcmk_parse_interval_spec(ns, &result); free(ns); return 0; }