pacemaker 3.0.1-16e74fc4da
Scalable High-Availability cluster resource manager
Loading...
Searching...
No Matches
cib_file_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 <crm_internal.h>
11
12#include <stdint.h>
13#include <stdio.h>
14#include <stdlib.h>
15
16#include <crm/cib.h>
17
18int
19LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
20{
21 char *filename = NULL;
22 int fd = 0;
23 cib_t *cib = NULL;
24
25 // Have at least some data
26 if (size < 5) {
27 return -1; // Do not add input to testing corpus
28 }
29
30 filename = pcmk__assert_alloc(size + 1, sizeof(char));
31 memcpy(filename, data, size);
32 filename[size] = '\0';
33
34 cib = cib_file_new(filename);
35
36 cib_delete(cib);
37 free(filename);
38 return 0;
39}
Cluster Configuration.
void cib_delete(cib_t *cib)
Free all memory used by CIB connection.
Definition cib_client.c:721
cib_t * cib_file_new(const char *filename)
Definition cib_file.c:637
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
#define pcmk__assert_alloc(nmemb, size)
Definition internal.h:246
char data[0]
Definition cpg.c:10
uint32_t size
Definition cpg.c:4