mirror of
https://github.com/espressif/openthread.git
synced 2026-09-24 18:07:36 +00:00
[fuzz] reset state on each invocation (#2130)
This commit is contained in:
@@ -37,6 +37,11 @@
|
||||
|
||||
static uint32_t sRandomState = 1;
|
||||
|
||||
void FuzzerPlatformInit(void)
|
||||
{
|
||||
sRandomState = 1;
|
||||
}
|
||||
|
||||
uint32_t otPlatAlarmMilliGetNow(void)
|
||||
{
|
||||
return 0;
|
||||
|
||||
+11
-16
@@ -38,32 +38,27 @@
|
||||
|
||||
#include "common/code_utils.hpp"
|
||||
|
||||
static otInstance *sInstance;
|
||||
extern "C" void FuzzerPlatformInit(void);
|
||||
|
||||
extern "C" int LLVMFuzzerInitialize(int *argc, char ***argv)
|
||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
|
||||
{
|
||||
const otPanId panId = 0xdead;
|
||||
|
||||
otInstance *sInstance;
|
||||
otMessage *message = NULL;
|
||||
otError error = OT_ERROR_NONE;
|
||||
bool isSecure;
|
||||
|
||||
VerifyOrExit(size > 0);
|
||||
|
||||
FuzzerPlatformInit();
|
||||
|
||||
sInstance = otInstanceInitSingle();
|
||||
otLinkSetPanId(sInstance, panId);
|
||||
otIp6SetEnabled(sInstance, true);
|
||||
otThreadSetEnabled(sInstance, true);
|
||||
otThreadBecomeLeader(sInstance);
|
||||
|
||||
(void)argc;
|
||||
(void)argv;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
|
||||
{
|
||||
otMessage *message = NULL;
|
||||
otError error = OT_ERROR_NONE;
|
||||
bool isSecure;
|
||||
|
||||
VerifyOrExit(size > 0);
|
||||
|
||||
isSecure = (data[0] & 0x1) != 0;
|
||||
|
||||
message = otIp6NewMessage(sInstance, isSecure);
|
||||
|
||||
@@ -39,31 +39,26 @@
|
||||
|
||||
#include "common/code_utils.hpp"
|
||||
|
||||
static otInstance *sInstance;
|
||||
extern "C" void FuzzerPlatformInit(void);
|
||||
|
||||
extern "C" int LLVMFuzzerInitialize(int *argc, char ***argv)
|
||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
|
||||
{
|
||||
const otPanId panId = 0xdead;
|
||||
|
||||
otInstance *sInstance;
|
||||
otRadioFrame frame;
|
||||
uint8_t *buf;
|
||||
|
||||
VerifyOrExit(size <= OT_RADIO_FRAME_MAX_SIZE);
|
||||
|
||||
FuzzerPlatformInit();
|
||||
|
||||
sInstance = otInstanceInitSingle();
|
||||
otLinkSetPanId(sInstance, panId);
|
||||
otIp6SetEnabled(sInstance, true);
|
||||
otThreadSetEnabled(sInstance, true);
|
||||
otThreadBecomeLeader(sInstance);
|
||||
|
||||
(void)argc;
|
||||
(void)argv;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
|
||||
{
|
||||
otRadioFrame frame;
|
||||
uint8_t *buf;
|
||||
|
||||
VerifyOrExit(size <= OT_RADIO_FRAME_MAX_SIZE);
|
||||
|
||||
buf = static_cast<uint8_t *>(malloc(size));
|
||||
|
||||
memset(&frame, 0, sizeof(frame));
|
||||
|
||||
Reference in New Issue
Block a user