-
Notifications
You must be signed in to change notification settings - Fork 99
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow tests to read all the variable-size concrete data #310
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,8 +3,7 @@ | |
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* You may obtain a copy of the Licen | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you fix this? |
||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
|
@@ -86,6 +85,9 @@ static struct DeepState_TestInfo *DeepState_DrFuzzTest = NULL; | |
/* Initialize global input buffer and index / initialized index. */ | ||
volatile uint8_t DeepState_Input[DeepState_InputSize] = {}; | ||
uint32_t DeepState_InputIndex = 0; | ||
|
||
uint32_t DeepState_ConcreteInputIndex = 0; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add a comment explaining what this is for. |
||
|
||
uint32_t DeepState_InputInitialized = 0; | ||
|
||
/* Used if we need to generate on-the-fly data while we fuzz */ | ||
|
@@ -394,6 +396,14 @@ 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); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this use |
||
} | ||
|
||
/* Allocate and return a pointer to `num_bytes` symbolic bytes. */ | ||
void *DeepState_GCMalloc(size_t num_bytes) { | ||
void *data = malloc(num_bytes); | ||
|
@@ -1165,6 +1175,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_InputInitialized = Size; | ||
|
||
DeepState_Begin(test); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe rename to
MallocAllConcreteInputBytes
?