This commit is contained in:
Maciej Domanski
2022-12-27 16:54:36 +01:00
parent 3d031f93a6
commit b189640a92
5 changed files with 45 additions and 27 deletions

View File

@ -26,15 +26,16 @@ import shutil
with open(".clang-format") as f: with open(".clang-format") as f:
fmt = f.read() fmt = f.read()
CURRENT_LLVM = os.getenv('LLVM_VERSION', 14) #CURRENT_LLVM = os.getenv('LLVM_VERSION', 14)
CLANG_FORMAT_BIN = os.getenv("CLANG_FORMAT_BIN", "") #CLANG_FORMAT_BIN = os.getenv("CLANG_FORMAT_BIN", "")
if shutil.which(CLANG_FORMAT_BIN) is None: #if shutil.which(CLANG_FORMAT_BIN) is None:
CLANG_FORMAT_BIN = f"clang-format-{CURRENT_LLVM}" # CLANG_FORMAT_BIN = f"clang-format-{CURRENT_LLVM}"
if shutil.which(CLANG_FORMAT_BIN) is None: #if shutil.which(CLANG_FORMAT_BIN) is None:
print(f"[!] clang-format-{CURRENT_LLVM} is needed. Aborted.") # print(f"[!] clang-format-{CURRENT_LLVM} is needed. Aborted.")
exit(1) # exit(1)
CLANG_FORMAT_BIN = "clang-format"
COLUMN_LIMIT = 80 COLUMN_LIMIT = 80
for line in fmt.split("\n"): for line in fmt.split("\n"):

View File

@ -1,4 +1,4 @@
# argvfuzz #argvfuzz
AFL++ supports fuzzing file inputs or stdin. When source is available, AFL++ supports fuzzing file inputs or stdin. When source is available,
`argv-fuzz-inl.h` can be used to change `main()` to build argv from stdin. `argv-fuzz-inl.h` can be used to change `main()` to build argv from stdin.

View File

@ -59,7 +59,9 @@
#define AFL_INIT_ARGV_PERSISTENT(persistent_buff) \ #define AFL_INIT_ARGV_PERSISTENT(persistent_buff) \
do { \ do { \
\
argv = afl_init_argv_persistent(&argc, persistent_buff); \ argv = afl_init_argv_persistent(&argc, persistent_buff); \
\
} while (0) } while (0)
#define AFL_INIT_SET0_PERSISTENT(_p, persistent_buff) \ #define AFL_INIT_SET0_PERSISTENT(_p, persistent_buff) \
@ -105,7 +107,8 @@ static char **afl_init_argv(int *argc) {
} }
static char **afl_init_argv_persistent(int *argc, unsigned char *persistent_buff) { static char **afl_init_argv_persistent(int *argc,
unsigned char *persistent_buff) {
static char *ret[MAX_CMDLINE_PAR]; static char *ret[MAX_CMDLINE_PAR];

View File

@ -3,6 +3,7 @@
#include "argv-fuzz-inl.h" #include "argv-fuzz-inl.h"
int main(int argc, char **argv) { int main(int argc, char **argv) {
// Initialize the argv array for use with the AFL (American Fuzzy Lop) tool // Initialize the argv array for use with the AFL (American Fuzzy Lop) tool
AFL_INIT_ARGV(); AFL_INIT_ARGV();
@ -12,12 +13,16 @@ int main(int argc, char **argv) {
an error message is printed. If the values do match, the program an error message is printed. If the values do match, the program
calls the abort() function. */ calls the abort() function. */
if (argc > 1 && strcmp(argv[1], "XYZ") == 0) { if (argc > 1 && strcmp(argv[1], "XYZ") == 0) {
if (strcmp(argv[2], "TEST2") == 0) {
abort(); if (strcmp(argv[2], "TEST2") == 0) { abort(); }
}
} else { } else {
printf("Bad number of arguments!\n"); printf("Bad number of arguments!\n");
} }
return 0; return 0;
} }

View File

@ -16,6 +16,7 @@ __AFL_FUZZ_INIT();
one of the arguments. one of the arguments.
*/ */
int main(int argc, char **argv) { int main(int argc, char **argv) {
#ifdef __AFL_HAVE_MANUAL_CONTROL #ifdef __AFL_HAVE_MANUAL_CONTROL
__AFL_INIT(); __AFL_INIT();
#endif #endif
@ -25,6 +26,7 @@ int main(int argc, char **argv) {
the loop and allowing the program to terminate. It protects against the loop and allowing the program to terminate. It protects against
accidental memory leaks and similar issues. */ accidental memory leaks and similar issues. */
while (__AFL_LOOP(100000)) { while (__AFL_LOOP(100000)) {
int len = __AFL_FUZZ_TESTCASE_LEN; int len = __AFL_FUZZ_TESTCASE_LEN;
// Check that the length of the test case is at least 8 bytes // Check that the length of the test case is at least 8 bytes
@ -37,13 +39,20 @@ int main(int argc, char **argv) {
If so, call the "abort" function to terminate the program. If so, call the "abort" function to terminate the program.
Otherwise, print an error message. */ Otherwise, print an error message. */
if (argc > 1 && strcmp(argv[1], "XYZ") == 0) { if (argc > 1 && strcmp(argv[1], "XYZ") == 0) {
if (strcmp(argv[2], "TEST2") == 0) { abort(); } if (strcmp(argv[2], "TEST2") == 0) { abort(); }
} else { } else {
printf("Bad number of arguments!\n"); printf("Bad number of arguments!\n");
} }
} }
/* Exiting the loop allows the program to terminate normally. AFL will restart /* Exiting the loop allows the program to terminate normally. AFL will restart
the process with a clean slate for allocated memory, file descriptors, etc. the process with a clean slate for allocated memory, file descriptors, etc.
*/ */
return 0; return 0;
} }