From a0c76783e9771997000e5c54b1163247679d0e3b Mon Sep 17 00:00:00 2001 From: neuromancer Date: Sun, 5 Jan 2020 14:53:13 -0300 Subject: [PATCH 1/2] Added DeepState_MallocAll implementation --- src/lib/DeepState.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/lib/DeepState.c b/src/lib/DeepState.c index 4001c488..76f47e00 100644 --- a/src/lib/DeepState.c +++ b/src/lib/DeepState.c @@ -85,6 +85,7 @@ static struct DeepState_TestInfo *DeepState_DrFuzzTest = NULL; /* Initialize global input buffer and index. */ volatile uint8_t DeepState_Input[DeepState_InputSize] = {}; uint32_t DeepState_InputIndex = 0; +uint32_t DeepState_ConcreteInputIndex = 0; /* Swarm related state. */ uint32_t DeepState_SwarmConfigsIndex = 0; @@ -380,6 +381,13 @@ void *DeepState_Malloc(size_t num_bytes) { return data; } +/* Allocate all the available concrete input, update the `num_bytes` pointer and return a pointer to symbolic bytes. */ +void *DeepState_MallocAll(size_t *num_bytes) { + *num_bytes = DeepState_ConcreteInputIndex; + DeepState_ConcreteInputIndex = 0; + return DeepState_Malloc(*num_bytes); +} + /* Portable and architecture-independent memory scrub without dead store elimination. */ void *DeepState_MemScrub(void *pointer, size_t data_size) { volatile unsigned char *p = pointer; @@ -1183,6 +1191,7 @@ extern int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { DeepState_SwarmConfigsIndex = 0; memcpy((void *) DeepState_Input, (void *) Data, Size); + DeepState_ConcreteInputIndex = Size; DeepState_Begin(test); From 59fcc16fec5411f687c6771da4c7a24f00b9fbdb Mon Sep 17 00:00:00 2001 From: neuromancer Date: Sun, 5 Jan 2020 14:55:45 -0300 Subject: [PATCH 2/2] Added DeepState_MallocAll declaration --- src/include/deepstate/DeepState.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/include/deepstate/DeepState.h b/src/include/deepstate/DeepState.h index 67fa862e..0ab80f28 100644 --- a/src/include/deepstate/DeepState.h +++ b/src/include/deepstate/DeepState.h @@ -245,6 +245,9 @@ extern const char *DeepState_ConcretizeCStr(const char *begin); /* Allocate and return a pointer to `num_bytes` symbolic bytes. */ extern void *DeepState_Malloc(size_t num_bytes); +/* Allocate all the concrete inputs and return a pointer to `num_bytes` symbolic bytes. */ +extern void *DeepState_MallocAll(size_t *num_bytes); + /* Returns the path to a testcase without parsing to any aforementioned types */ extern const char *DeepState_InputPath(char *testcase_path);