quickfix for first big bug that use_stdin was not correctly initialized and could not be set

This commit is contained in:
van Hauser
2020-03-09 19:40:59 +01:00
parent 253bbf3a5c
commit 73a1b39446
7 changed files with 17 additions and 8 deletions

View File

@ -31,7 +31,7 @@
#include "types.h" #include "types.h"
#include "stdbool.h" #include "stdbool.h"
void detect_file_args(char** argv, u8* prog_in, u8 use_stdin); void detect_file_args(char** argv, u8* prog_in, u8 *use_stdin);
void check_environment_vars(char** env); void check_environment_vars(char** env);
char** get_qemu_argv(u8* own_loc, u8** target_path_p, int argc, char** argv); char** get_qemu_argv(u8* own_loc, u8** target_path_p, int argc, char** argv);

View File

@ -1009,7 +1009,7 @@ int main(int argc, char** argv, char** envp) {
set_up_environment(); set_up_environment();
find_binary(argv[optind]); find_binary(argv[optind]);
detect_file_args(argv + optind, prog_in, use_stdin); detect_file_args(argv + optind, prog_in, &use_stdin);
if (qemu_mode) { if (qemu_mode) {

View File

@ -38,7 +38,7 @@
extern u8 be_quiet; extern u8 be_quiet;
void detect_file_args(char** argv, u8* prog_in, u8 use_stdin) { void detect_file_args(char** argv, u8* prog_in, u8 *use_stdin) {
u32 i = 0; u32 i = 0;
#ifdef __GLIBC__ #ifdef __GLIBC__
@ -149,7 +149,7 @@ char **create_file_args(int argc, char** argv, u8* prog_in, u8 use_stdin) {
if (!prog_in) FATAL("@@ syntax is not supported by this tool."); if (!prog_in) FATAL("@@ syntax is not supported by this tool.");
use_stdin = 0; *use_stdin = 0;
if (prog_in[0] != 0) { // not afl-showmap special case if (prog_in[0] != 0) { // not afl-showmap special case

View File

@ -135,6 +135,15 @@ void handle_timeout(int sig) {
void afl_fsrv_init(afl_forkserver_t *fsrv) { void afl_fsrv_init(afl_forkserver_t *fsrv) {
uint32_t i, j = 0;
// this is the default and is != 0 so we need to set it if fsrv is still
// uninitialized
for (i = 0; i < sizeof(afl_forkserver_t) && j == 0; i++)
if (((char*)fsrv)[i] != 0)
j = 1;
if (j == 0)
fsrv->use_stdin = 1;
list_append(&fsrv_list, fsrv); list_append(&fsrv_list, fsrv);
} }

View File

@ -942,7 +942,7 @@ int main(int argc, char** argv, char** envp) {
} }
detect_file_args(argv + optind + 1, afl->fsrv.out_file, detect_file_args(argv + optind + 1, afl->fsrv.out_file,
afl->fsrv.use_stdin); &afl->fsrv.use_stdin);
break; break;
} }

View File

@ -899,11 +899,11 @@ int main(int argc, char** argv, char** envp) {
if (in_dir) { if (in_dir) {
if (at_file) PFATAL("Options -A and -i are mutually exclusive"); if (at_file) PFATAL("Options -A and -i are mutually exclusive");
detect_file_args(argv + optind, "", fsrv->use_stdin); detect_file_args(argv + optind, "", &fsrv->use_stdin);
} else { } else {
detect_file_args(argv + optind, at_file, fsrv->use_stdin); detect_file_args(argv + optind, at_file, &fsrv->use_stdin);
} }

View File

@ -1274,7 +1274,7 @@ int main(int argc, char** argv, char** envp) {
set_up_environment(fsrv); set_up_environment(fsrv);
find_binary(fsrv, argv[optind]); find_binary(fsrv, argv[optind]);
detect_file_args(argv + optind, fsrv->out_file, fsrv->use_stdin); detect_file_args(argv + optind, fsrv->out_file, &fsrv->use_stdin);
if (qemu_mode) { if (qemu_mode) {