|
|
|
@ -32,7 +32,7 @@ ThreadVars tv;
|
|
|
|
DecodeThreadVars *dtv;
|
|
|
|
DecodeThreadVars *dtv;
|
|
|
|
//FlowWorkerThreadData
|
|
|
|
//FlowWorkerThreadData
|
|
|
|
void *fwd;
|
|
|
|
void *fwd;
|
|
|
|
SCInstance suricata;
|
|
|
|
SCInstance surifuzz;
|
|
|
|
|
|
|
|
|
|
|
|
const char configNoChecksum[] = "\
|
|
|
|
const char configNoChecksum[] = "\
|
|
|
|
%YAML 1.1\n\
|
|
|
|
%YAML 1.1\n\
|
|
|
|
@ -155,14 +155,14 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
|
|
|
|
if (ConfYamlLoadString(configNoChecksum, strlen(configNoChecksum)) != 0) {
|
|
|
|
if (ConfYamlLoadString(configNoChecksum, strlen(configNoChecksum)) != 0) {
|
|
|
|
abort();
|
|
|
|
abort();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
suricata.sig_file = strdup("/tmp/fuzz.rules");
|
|
|
|
surifuzz.sig_file = strdup("/tmp/fuzz.rules");
|
|
|
|
suricata.sig_file_exclusive = 1;
|
|
|
|
surifuzz.sig_file_exclusive = 1;
|
|
|
|
//loads rules after init
|
|
|
|
//loads rules after init
|
|
|
|
suricata.delayed_detect = 1;
|
|
|
|
surifuzz.delayed_detect = 1;
|
|
|
|
|
|
|
|
|
|
|
|
PostConfLoadedSetup(&suricata);
|
|
|
|
PostConfLoadedSetup(&surifuzz);
|
|
|
|
PreRunPostPrivsDropInit(run_mode);
|
|
|
|
PreRunPostPrivsDropInit(run_mode);
|
|
|
|
PostConfLoadedDetectSetup(&suricata);
|
|
|
|
PostConfLoadedDetectSetup(&surifuzz);
|
|
|
|
|
|
|
|
|
|
|
|
memset(&tv, 0, sizeof(tv));
|
|
|
|
memset(&tv, 0, sizeof(tv));
|
|
|
|
dtv = DecodeThreadVarsAlloc(&tv);
|
|
|
|
dtv = DecodeThreadVarsAlloc(&tv);
|
|
|
|
@ -197,16 +197,16 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (pos > 0 && pos < size) {
|
|
|
|
if (pos > 0 && pos < size) {
|
|
|
|
// dump signatures to a file so as to reuse SigLoadSignatures
|
|
|
|
// dump signatures to a file so as to reuse SigLoadSignatures
|
|
|
|
if (TestHelperBufferToFile(suricata.sig_file, data, pos-1) < 0) {
|
|
|
|
if (TestHelperBufferToFile(surifuzz.sig_file, data, pos-1) < 0) {
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
if (TestHelperBufferToFile(suricata.sig_file, data, pos) < 0) {
|
|
|
|
if (TestHelperBufferToFile(surifuzz.sig_file, data, pos) < 0) {
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (DetectEngineReload(&suricata) < 0) {
|
|
|
|
if (DetectEngineReload(&surifuzz) < 0) {
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (pos < size) {
|
|
|
|
if (pos < size) {
|
|
|
|
|