Created
February 11, 2025 12:55
-
-
Save hartwork/93e23a5d6cbc1a47c6cfb2287712f5f2 to your computer and use it in GitHub Desktop.
Demo effectiveness of coverage-guided fuzz testing with libFuzzer (https://llvm.org/docs/LibFuzzer.html#id30)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copyright (c) 2025 Sebastian Pipping <[email protected]> | |
// Licensed under the MIT license | |
#include <cstdint> | |
#include <signal.h> | |
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { | |
if (Size >= 1 && Data[0] == 'H') { | |
if (Size >= 2 && Data[1] == 'e') { | |
if (Size >= 3 && Data[2] == 'l') { | |
if (Size >= 4 && Data[3] == 'l') { | |
if (Size >= 5 && Data[4] == 'o') { | |
if (Size >= 6 && Data[5] == ' ') { | |
if (Size >= 7 && Data[6] == 'c') { | |
if (Size >= 8 && Data[7] == 'o') { | |
if (Size >= 9 && Data[8] == 'v') { | |
if (Size >= 10 && Data[9] == 'e') { | |
if (Size >= 11 && Data[10] == 'r') { | |
if (Size >= 12 && Data[11] == 'a') { | |
if (Size >= 13 && Data[12] == 'g') { | |
if (Size >= 14 && Data[13] == 'e') { | |
if (Size >= 15 && Data[14] == '!') { | |
if (Size >= 16 && Data[15] == '\n') { | |
if (Size == 16) { | |
raise(SIGSEGV); | |
} | |
} | |
} | |
} | |
} | |
} | |
} | |
} | |
} | |
} | |
} | |
} | |
} | |
} | |
} | |
} | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment