You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
805 B
33 lines
805 B
7 months ago
|
#include "chewing_fuzzer_common.h"
|
||
|
|
||
|
#include <libgen.h>
|
||
|
#include <stdio.h>
|
||
|
#include <stdlib.h>
|
||
|
#include <string.h>
|
||
|
|
||
|
static char userphrase_path[] = "/tmp/chewing_userphrase.db.XXXXXX";
|
||
|
|
||
|
int LLVMFuzzerInitialize(int* argc, char*** argv) {
|
||
|
char* exe_path = (*argv)[0];
|
||
|
|
||
|
// dirname() can modify its argument.
|
||
|
char* exe_path_copy = strdup(exe_path);
|
||
|
char* dir = dirname(exe_path_copy);
|
||
|
|
||
|
// Assume data files are at the same location as executable.
|
||
|
setenv("CHEWING_PATH", dir, 0);
|
||
|
free(exe_path_copy);
|
||
|
|
||
|
// Specify user db of this process. So we can run multiple fuzzers at the
|
||
|
// same time.
|
||
|
mktemp(userphrase_path);
|
||
|
setenv("TEST_USERPHRASE_PATH", userphrase_path, 0);
|
||
|
return 0;
|
||
|
}
|
||
|
|
||
|
int get_fuzz_input() {
|
||
|
if (fuzz_ptr - fuzz_input >= fuzz_size)
|
||
|
return EOF;
|
||
|
return *fuzz_ptr++;
|
||
|
}
|