-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
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
afl persistent mode #2012
Comments
@GrosQuildu Thanks for reporting. I created a branch https://github.com/nlohmann/json/tree/feature/afl_persistent with your proposed change. I had to make some changes to make it compile via
Then, I get the following warning on Any ideas? Sorry for the questions - since the project is fuzz tested by OSSFuzz, I have not executed AFL regularly. |
#include <vector> // for vector
#include <cstdint> // for uint8_t
#include <iostream> // for cin
#include <cstring> // for memcpy
#include <unistd.h> // for read
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size);
static const std::size_t MaxInputSize = 1048576; // 1MiB
static uint8_t InputBuf[MaxInputSize];
int main()
{
#ifdef __AFL_HAVE_MANUAL_CONTROL
/* AFL deferred fork */
__AFL_INIT();
/* AFL persistent loop */
while (__AFL_LOOP(1000))
{
#endif
/* read data*/
ssize_t bytesReadedS = read(0, InputBuf, MaxInputSize);
if (bytesReadedS > 0)
{
size_t bytesReaded = static_cast<size_t>(bytesReadedS);
/* allocate memory, exactly bytesReaded to catch overflows */
uint8_t* tmpBuf = static_cast<uint8_t*>(malloc(bytesReaded));
memcpy(tmpBuf, InputBuf, bytesReaded);
/* run harness*/
LLVMFuzzerTestOneInput(tmpBuf, bytesReaded);
/* clear */
free(tmpBuf);
}
#ifdef __AFL_HAVE_MANUAL_CONTROL
}
#endif
return 0;
} |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
AFL's persistent mode (
__AFL_LOOP(1000)
) has very poor stability (around 5%).Environment:
AFL is AFL++ from master.
It may be due to the invalid usage of
cin.get
, but not sure about that. Replacing file withtest/src/fuzzer-driver_afl.cpp
:yields 100% stability (performance is about the same).
The text was updated successfully, but these errors were encountered: