[fuzz] reset state on each invocation (#2130)

This commit is contained in:
Jonathan Hui
2017-08-23 14:45:26 -07:00
committed by GitHub
parent 7804396588
commit 5c52373c99
3 changed files with 26 additions and 31 deletions
+11 -16
View File
@@ -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);