oss-fuzz/projects/freeradius/patch.diff

42 lines
1.2 KiB
Diff
Raw Normal View History

diff --git a/src/bin/fuzzer.c b/src/bin/fuzzer.c
index 9c2eb50..82d6fd6 100644
--- a/src/bin/fuzzer.c
+++ b/src/bin/fuzzer.c
@@ -125,7 +125,21 @@ int LLVMFuzzerInitialize(int *argc, char ***argv)
}
}
- if (!dict_dir) dict_dir = DICTDIR;
+ int free_dict = 0;
+ int free_lib = 0;
+ 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");
+ free_dict = 1;
+ }
+ 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);
+ free_lib = 1;
+ }
/*
* When jobs=N is specified the fuzzer spawns worker processes via
@@ -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;
}