diff options
author | 2019-08-12 18:35:53 +0200 | |
---|---|---|
committer | 2019-08-12 09:35:53 -0700 | |
commit | 0802984dd81a5638adc7607f92682cb629ec12bd (patch) | |
tree | 5003e4638bfa5c0774bdfedc5f58c11e4316e75a /projects/spidermonkey-ufi/target.c | |
parent | 5edcd421d9c170ea30ac9ef82df8f574b6a16dae (diff) |
[spidermonkey-ufi] Add spidermonkey-ufi project (#2676)
Diffstat (limited to 'projects/spidermonkey-ufi/target.c')
-rw-r--r-- | projects/spidermonkey-ufi/target.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/projects/spidermonkey-ufi/target.c b/projects/spidermonkey-ufi/target.c new file mode 100644 index 00000000..3538d29c --- /dev/null +++ b/projects/spidermonkey-ufi/target.c @@ -0,0 +1,39 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> + +#define STRINGLIT(S) #S +#define STRINGIFY(S) STRINGLIT(S) + +// Required for oss-fuzz to consider the binary a target. +static const char* magic __attribute__((used)) = "LLVMFuzzerTestOneInput"; + +int main(int argc, char* argv[]) { + setenv("HOME", "/tmp", 0); + setenv("LIBFUZZER", "1", 1); + setenv("FUZZER", STRINGIFY(FUZZ_TARGET), 1); + + char* options = getenv("ASAN_OPTIONS"); + if (options) { + char* ptr; + char* new_options = strdup(options); + + // https://bugzilla.mozilla.org/1477846 + ptr = strstr(new_options, "detect_stack_use_after_return=1"); + if (ptr) ptr[30] = '0'; + + // https://bugzilla.mozilla.org/1477844 + ptr = strstr(new_options, "detect_leaks=1"); + if (ptr) ptr[13] = '0'; + + setenv("ASAN_OPTIONS", new_options, 1); + free(new_options); + } + + int ret = execv("./fuzz-tests", argv); + if (ret) + perror("execv"); + return ret; +} + |