2021-06-05 23:55:16 +00:00
|
|
|
diff --git a/src/bin/fuzzer.c b/src/bin/fuzzer.c
|
2021-06-08 19:12:39 +00:00
|
|
|
index 9c2eb50..82d6fd6 100644
|
2021-06-05 23:55:16 +00:00
|
|
|
--- a/src/bin/fuzzer.c
|
|
|
|
+++ b/src/bin/fuzzer.c
|
2021-06-08 19:12:39 +00:00
|
|
|
@@ -125,7 +125,21 @@ int LLVMFuzzerInitialize(int *argc, char ***argv)
|
2021-06-05 23:55:16 +00:00
|
|
|
}
|
|
|
|
}
|
2021-06-08 19:12:39 +00:00
|
|
|
|
2021-06-05 23:55:16 +00:00
|
|
|
- if (!dict_dir) dict_dir = DICTDIR;
|
2021-06-08 19:12:39 +00:00
|
|
|
+ int free_dict = 0;
|
|
|
|
+ int free_lib = 0;
|
2021-06-05 23:55:16 +00:00
|
|
|
+ if (!dict_dir) {
|
|
|
|
+ dict_dir = malloc(strlen((*argv)[0]) + 1);
|
|
|
|
+ memcpy(dict_dir, (*argv)[0], strlen((*argv)[0]) + 1);
|
|
|
|
+ snprintf(strrchr(dict_dir, '/'), 6, "/dict");
|
2021-06-08 19:12:39 +00:00
|
|
|
+ free_dict = 1;
|
2021-06-05 23:55:16 +00:00
|
|
|
+ }
|
|
|
|
+ if (!lib_dir) {
|
|
|
|
+ lib_dir = malloc(strlen((*argv)[0]) + 1);
|
|
|
|
+ memcpy(lib_dir, (*argv)[0], strlen((*argv)[0]) + 1);
|
|
|
|
+ snprintf(strrchr(lib_dir, '/'), 5, "/lib");
|
|
|
|
+ setenv("FR_LIBRARY_PATH", lib_dir, 1);
|
2021-06-08 19:12:39 +00:00
|
|
|
+ free_lib = 1;
|
2021-06-05 23:55:16 +00:00
|
|
|
+ }
|
2021-06-08 19:12:39 +00:00
|
|
|
|
2021-06-05 23:55:16 +00:00
|
|
|
/*
|
|
|
|
* When jobs=N is specified the fuzzer spawns worker processes via
|
2021-06-08 19:12:39 +00:00
|
|
|
@@ -182,6 +196,13 @@ int LLVMFuzzerInitialize(int *argc, char ***argv)
|
|
|
|
|
|
|
|
init = true;
|
|
|
|
|
|
|
|
+ if (free_lib) {
|
|
|
|
+ free(lib_dir);
|
|
|
|
+ }
|
|
|
|
+ if (free_dict) {
|
|
|
|
+ free(dict_dir);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|