mirror of
https://github.com/AFLplusplus/AFLplusplus.git
synced 2025-06-11 17:51:32 +00:00
Merge pull request #817 from realmadsci/atat-plusplus
Make @@ handling more flexible
This commit is contained in:
commit
7dc4847869
2
afl-cmin
2
afl-cmin
@ -243,7 +243,7 @@ BEGIN {
|
||||
if (!stdin_file) {
|
||||
found_atat = 0
|
||||
for (prog_args_ind in prog_args) {
|
||||
if ("@@" == prog_args[prog_args_ind]) {
|
||||
if (match(prog_args[prog_args_ind], "@@") != 0) {
|
||||
found_atat = 1
|
||||
break
|
||||
}
|
||||
|
@ -70,31 +70,26 @@ void detect_file_args(char **argv, u8 *prog_in, bool *use_stdin) {
|
||||
|
||||
*use_stdin = false;
|
||||
|
||||
if (prog_in[0] != 0) { // not afl-showmap special case
|
||||
/* Be sure that we're always using fully-qualified paths. */
|
||||
|
||||
u8 *n_arg;
|
||||
*aa_loc = 0;
|
||||
|
||||
/* Be sure that we're always using fully-qualified paths. */
|
||||
/* Construct a replacement argv value. */
|
||||
u8 *n_arg;
|
||||
|
||||
*aa_loc = 0;
|
||||
if (prog_in[0] == '/') {
|
||||
|
||||
/* Construct a replacement argv value. */
|
||||
n_arg = alloc_printf("%s%s%s", argv[i], prog_in, aa_loc + 2);
|
||||
|
||||
if (prog_in[0] == '/') {
|
||||
} else {
|
||||
|
||||
n_arg = alloc_printf("%s%s%s", argv[i], prog_in, aa_loc + 2);
|
||||
|
||||
} else {
|
||||
|
||||
n_arg = alloc_printf("%s%s/%s%s", argv[i], cwd, prog_in, aa_loc + 2);
|
||||
|
||||
}
|
||||
|
||||
ck_free(argv[i]);
|
||||
argv[i] = n_arg;
|
||||
n_arg = alloc_printf("%s%s/%s%s", argv[i], cwd, prog_in, aa_loc + 2);
|
||||
|
||||
}
|
||||
|
||||
ck_free(argv[i]);
|
||||
argv[i] = n_arg;
|
||||
|
||||
}
|
||||
|
||||
i++;
|
||||
|
@ -72,8 +72,7 @@ static u8 *in_data, /* Input data */
|
||||
static u64 total; /* tuple content information */
|
||||
static u32 tcnt, highest; /* tuple content information */
|
||||
|
||||
static u32 in_len, /* Input data length */
|
||||
arg_offset; /* Total number of execs */
|
||||
static u32 in_len; /* Input data length */
|
||||
|
||||
static u32 map_size = MAP_SIZE;
|
||||
|
||||
@ -956,12 +955,30 @@ int main(int argc, char **argv_orig, char **envp) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
if (in_dir) {
|
||||
|
||||
detect_file_args(argv + optind, "", &fsrv->use_stdin);
|
||||
/* If we don't have a file name chosen yet, use a safe default. */
|
||||
u8 *use_dir = ".";
|
||||
|
||||
if (access(use_dir, R_OK | W_OK | X_OK)) {
|
||||
|
||||
use_dir = get_afl_env("TMPDIR");
|
||||
if (!use_dir) { use_dir = "/tmp"; }
|
||||
|
||||
}
|
||||
|
||||
stdin_file = at_file ? strdup(at_file)
|
||||
: (char *)alloc_printf("%s/.afl-showmap-temp-%u",
|
||||
use_dir, (u32)getpid());
|
||||
unlink(stdin_file);
|
||||
|
||||
// If @@ are in the target args, replace them and also set use_stdin=false.
|
||||
detect_file_args(argv + optind, stdin_file, &fsrv->use_stdin);
|
||||
|
||||
} else {
|
||||
|
||||
// If @@ are in the target args, replace them and also set use_stdin=false.
|
||||
detect_file_args(argv + optind, at_file, &fsrv->use_stdin);
|
||||
|
||||
}
|
||||
@ -986,14 +1003,6 @@ int main(int argc, char **argv_orig, char **envp) {
|
||||
|
||||
}
|
||||
|
||||
i = 0;
|
||||
while (use_argv[i] != NULL && !arg_offset) {
|
||||
|
||||
if (strcmp(use_argv[i], "@@") == 0) { arg_offset = i; }
|
||||
i++;
|
||||
|
||||
}
|
||||
|
||||
shm_fuzz = ck_alloc(sizeof(sharedmem_t));
|
||||
|
||||
/* initialize cmplog_mode */
|
||||
@ -1104,31 +1113,12 @@ int main(int argc, char **argv_orig, char **envp) {
|
||||
|
||||
}
|
||||
|
||||
u8 *use_dir = ".";
|
||||
|
||||
if (access(use_dir, R_OK | W_OK | X_OK)) {
|
||||
|
||||
use_dir = get_afl_env("TMPDIR");
|
||||
if (!use_dir) { use_dir = "/tmp"; }
|
||||
|
||||
}
|
||||
|
||||
stdin_file = at_file ? strdup(at_file)
|
||||
: (char *)alloc_printf("%s/.afl-showmap-temp-%u",
|
||||
use_dir, (u32)getpid());
|
||||
unlink(stdin_file);
|
||||
atexit(at_exit_handler);
|
||||
fsrv->out_file = stdin_file;
|
||||
fsrv->out_fd =
|
||||
open(stdin_file, O_RDWR | O_CREAT | O_EXCL, DEFAULT_PERMISSION);
|
||||
if (fsrv->out_fd < 0) { PFATAL("Unable to create '%s'", out_file); }
|
||||
|
||||
if (arg_offset && use_argv[arg_offset] != stdin_file) {
|
||||
|
||||
use_argv[arg_offset] = strdup(stdin_file);
|
||||
|
||||
}
|
||||
|
||||
if (get_afl_env("AFL_DEBUG")) {
|
||||
|
||||
int j = optind;
|
||||
|
@ -90,8 +90,9 @@ for crash in $DIR/crashes/id:*; do
|
||||
|
||||
for a in $@; do
|
||||
|
||||
if [ "$a" = "@@" ] ; then
|
||||
use_args="$use_args $crash"
|
||||
if echo "$a" | grep -qF '@@'; then
|
||||
escaped_fname=`echo $crash | sed 's:/:\\\\/:g'`
|
||||
use_args="$use_args `echo $a | sed "s/@@/$escaped_fname/g"`"
|
||||
unset use_stdio
|
||||
else
|
||||
use_args="$use_args $a"
|
||||
|
Loading…
x
Reference in New Issue
Block a user