diff options
author | Andrea Fioraldi <andreafioraldi@gmail.com> | 2019-09-03 11:12:49 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-09-03 11:12:49 +0200 |
commit | f3617bd83bcf4de3b10866faca4b83f566ee0e8f (patch) | |
tree | 6308bf840cdf24af50fdef4c216d6c9433cd021b /afl-common.c | |
parent | 3bfd88aabbf3fdf70cb053aa25944f32d2113d8f (diff) | |
parent | d47ef88fcd842bd13923b1b519544fa2c8d6d0eb (diff) | |
download | afl++-f3617bd83bcf4de3b10866faca4b83f566ee0e8f.tar.gz |
Merge pull request #53 from vanhauser-thc/code-cleanup
Code cleanup
Diffstat (limited to 'afl-common.c')
-rw-r--r-- | afl-common.c | 69 |
1 files changed, 0 insertions, 69 deletions
diff --git a/afl-common.c b/afl-common.c deleted file mode 100644 index 1c5e5bfe..00000000 --- a/afl-common.c +++ /dev/null @@ -1,69 +0,0 @@ -/* - gather some functions common to multiple executables - - detect_file_args - */ - -#include <stdlib.h> -#include <stdio.h> -#include <strings.h> - -#include "debug.h" -#include "alloc-inl.h" - -/* Detect @@ in args. */ -#ifndef __glibc__ -#include <unistd.h> -#endif -void detect_file_args(char** argv, u8* prog_in) { - - u32 i = 0; -#ifdef __GLIBC__ - u8* cwd = getcwd(NULL, 0); /* non portable glibc extension */ -#else - u8* cwd; - char *buf; - long size = pathconf(".", _PC_PATH_MAX); - if ((buf = (char *)malloc((size_t)size)) != NULL) { - cwd = getcwd(buf, (size_t)size); /* portable version */ - } else { - PFATAL("getcwd() failed"); - } -#endif - - if (!cwd) PFATAL("getcwd() failed"); - - while (argv[i]) { - - u8* aa_loc = strstr(argv[i], "@@"); - - if (aa_loc) { - - u8 *aa_subst, *n_arg; - - if (!prog_in) FATAL("@@ syntax is not supported by this tool."); - - /* Be sure that we're always using fully-qualified paths. */ - - if (prog_in[0] == '/') aa_subst = prog_in; - else aa_subst = alloc_printf("%s/%s", cwd, prog_in); - - /* Construct a replacement argv value. */ - - *aa_loc = 0; - n_arg = alloc_printf("%s%s%s", argv[i], aa_subst, aa_loc + 2); - argv[i] = n_arg; - *aa_loc = '@'; - - if (prog_in[0] != '/') ck_free(aa_subst); - - } - - i++; - - } - - free(cwd); /* not tracked */ - -} - |