pacemaker 3.0.1-16e74fc4da
Scalable High-Availability cluster resource manager
Loading...
Searching...
No Matches
iso8601_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
14#include <crm/common/util.h>
15#include <crm/common/internal.h>
16
17int
18LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
19{
20 char *ns = NULL;
21 char *result = NULL;
22 time_t epoch = 0;
23 pcmk__time_hr_t *now = NULL;
24 crm_time_period_t *period = NULL;
25
26 // Ensure we have enough data.
27 if (size < 10) {
28 return -1; // Do not add input to testing corpus
29 }
30 ns = pcmk__assert_alloc(1, size + 1);
31 memcpy(ns, data, size);
32
33 period = crm_time_parse_period(ns);
35
36 now = pcmk__time_hr_new(ns);
38
39 now = pcmk__time_hr_now(&epoch);
42 free(result);
43
44 free(ns);
45 return 0;
46}
#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
crm_time_period_t * crm_time_parse_period(const char *period_str)
Parse a time period from an ISO 8601 interval specification.
Definition iso8601.c:1283
void crm_time_free_period(crm_time_period_t *period)
Free a dynamically allocated time period object.
Definition iso8601.c:1373
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
char * pcmk__time_format_hr(const char *format, const pcmk__time_hr_t *hr_dt)
Definition iso8601.c:2029
pcmk__time_hr_t * pcmk__time_hr_new(const char *date_time)
Definition iso8601.c:1996
void pcmk__time_hr_free(pcmk__time_hr_t *hr_dt)
Definition iso8601.c:2013
pcmk__time_hr_t * pcmk__time_hr_now(time_t *epoch)
Definition iso8601.c:1977
pcmk__action_result_t result
Definition pcmk_fence.c:37