suricata
fuzz_confyamlloadstring.c
Go to the documentation of this file.
1 /**
2  * @file
3  * @author Philippe Antoine <contact@catenacyber.fr>
4  * fuzz target for ConfYamlLoadString
5  */
6 
7 
8 #include "suricata-common.h"
9 #include "suricata.h"
10 #include "conf-yaml-loader.h"
11 
12 int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size);
13 
14 static int initialized = 0;
15 
16 int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
17 {
18  if (initialized == 0) {
19  //Redirects logs to /dev/null
20  setenv("SC_LOG_OP_IFACE", "file", 0);
21  setenv("SC_LOG_FILE", "/dev/null", 0);
22  //global init
23  InitGlobal();
25  initialized = 1;
26  }
27 
28  ConfYamlLoadString((const char *) data, size);
29 
30  return 0;
31 }
RUNMODE_UNITTEST
@ RUNMODE_UNITTEST
Definition: runmodes.h:40
LLVMFuzzerTestOneInput
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
Definition: fuzz_confyamlloadstring.c:16
SCRunmodeSet
void SCRunmodeSet(int run_mode)
Set the current run mode.
Definition: suricata.c:265
ConfYamlLoadString
int ConfYamlLoadString(const char *string, size_t len)
Load configuration from a YAML string.
Definition: conf-yaml-loader.c:523
conf-yaml-loader.h
setenv
void setenv(const char *name, const char *value, int overwrite)
suricata-common.h
suricata.h
InitGlobal
int InitGlobal(void)
Global initialization common to all runmodes.
Definition: suricata.c:2856