pacemaker 3.0.1-16e74fc4da
Scalable High-Availability cluster resource manager
Loading...
Searching...
No Matches
strings_fuzzer.c
Go to the documentation of this file.
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
20int
21LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
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
34 pcmk__trim(ns);
36 crm_get_msec(ns);
37
38 free(ns);
39 return 0;
40}
#define pcmk__assert_alloc(nmemb, size)
Definition internal.h:246
Utility functions.
char data[0]
Definition cpg.c:10
uint32_t size
Definition cpg.c:4
API related to options.
API for strings.
int pcmk_parse_interval_spec(const char *input, guint *result_ms)
Parse milliseconds from a Pacemaker interval specification.
Definition strings.c:452
long long crm_get_msec(const char *input)
Parse a time+units string and return milliseconds equivalent.
Definition strings.c:351
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
int pcmk__numeric_strcasecmp(const char *s1, const char *s2)
Definition strings.c:1081
char * pcmk__trim(char *str)
Definition strings.c:530