Skip to content

Commit ed1e148

Browse files
committed
[FIX] Disable write_to_testcase - AFLNet does not need it
And remove everything related to out_fd - this generates crashes
1 parent 0e814dd commit ed1e148

File tree

1 file changed

+27
-44
lines changed

1 file changed

+27
-44
lines changed

afl-fuzz.c

+27-44
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,8 @@ EXP_ST u8 skip_deterministic, /* Skip deterministic stages? */
140140
deferred_mode, /* Deferred forkserver mode? */
141141
fast_cal; /* Try to calibrate faster? */
142142

143-
static s32 out_fd, /* Persistent fd for out_file */
144-
dev_urandom_fd = -1, /* Persistent fd for /dev/urandom */
143+
//static s32 out_fd, /* Persistent fd for out_file */
144+
static s32 dev_urandom_fd = -1, /* Persistent fd for /dev/urandom */
145145
dev_null_fd = -1, /* Persistent fd for /dev/null */
146146
fsrv_ctl_fd, /* Fork server control pipe (write) */
147147
fsrv_st_fd; /* Fork server status pipe (read) */
@@ -3116,12 +3116,13 @@ EXP_ST void init_forkserver(char** argv) {
31163116

31173117
dup2(dev_null_fd, 0);
31183118

3119-
} else {
3119+
}
3120+
//else {
31203121

3121-
dup2(out_fd, 0);
3122-
close(out_fd);
3122+
// dup2(out_fd, 0);
3123+
// close(out_fd);
31233124

3124-
}
3125+
//}
31253126

31263127
/* Set up control and status pipes, close the unneeded original fds. */
31273128

@@ -3402,12 +3403,13 @@ static u8 run_target(char** argv, u32 timeout) {
34023403

34033404
dup2(dev_null_fd, 0);
34043405

3405-
} else {
3406+
}
3407+
//else {
34063408

3407-
dup2(out_fd, 0);
3408-
close(out_fd);
3409+
// dup2(out_fd, 0);
3410+
// close(out_fd);
34093411

3410-
}
3412+
//}
34113413

34123414
/* On Linux, would be faster to use O_CLOEXEC. Maybe TODO. */
34133415

@@ -3559,26 +3561,7 @@ static u8 run_target(char** argv, u32 timeout) {
35593561

35603562
static void write_to_testcase(void* mem, u32 len) {
35613563

3562-
s32 fd = out_fd;
3563-
3564-
if (out_file) {
3565-
3566-
unlink(out_file); /* Ignore errors. */
3567-
3568-
fd = open(out_file, O_WRONLY | O_CREAT | O_EXCL, 0600);
3569-
3570-
if (fd < 0) PFATAL("Unable to create '%s'", out_file);
3571-
3572-
} else lseek(fd, 0, SEEK_SET);
3573-
3574-
ck_write(fd, mem, len, out_file);
3575-
3576-
if (!out_file) {
3577-
3578-
if (ftruncate(fd, len)) PFATAL("ftruncate() failed");
3579-
lseek(fd, 0, SEEK_SET);
3580-
3581-
} else close(fd);
3564+
//AFLNet sends data via network so it does not need this function
35823565

35833566
}
35843567

@@ -8925,19 +8908,19 @@ EXP_ST void setup_dirs_fds(void) {
89258908

89268909
/* Setup the output file for fuzzed data, if not using -f. */
89278910

8928-
EXP_ST void setup_stdio_file(void) {
8929-
8930-
u8* fn = alloc_printf("%s/.cur_input", out_dir);
8931-
8932-
unlink(fn); /* Ignore errors */
8933-
8934-
out_fd = open(fn, O_RDWR | O_CREAT | O_EXCL, 0600);
8935-
8936-
if (out_fd < 0) PFATAL("Unable to create '%s'", fn);
8937-
8938-
ck_free(fn);
8939-
8940-
}
8911+
//EXP_ST void setup_stdio_file(void) {
8912+
//
8913+
// u8* fn = alloc_printf("%s/.cur_input", out_dir);
8914+
//
8915+
// unlink(fn); /* Ignore errors */
8916+
//
8917+
// out_fd = open(fn, O_RDWR | O_CREAT | O_EXCL, 0600);
8918+
//
8919+
// if (out_fd < 0) PFATAL("Unable to create '%s'", fn);
8920+
//
8921+
// ck_free(fn);
8922+
//
8923+
//}
89418924

89428925

89438926
/* Make sure that core dumps don't go to a program. */
@@ -9874,7 +9857,7 @@ int main(int argc, char** argv) {
98749857

98759858
detect_file_args(argv + optind + 1);
98769859

9877-
if (!out_file) setup_stdio_file();
9860+
//if (!out_file) setup_stdio_file();
98789861

98799862
check_binary(argv[optind]);
98809863

0 commit comments

Comments
 (0)