From 9d22c8a02ca9043e62c250a32d5affdaeab11dcd Mon Sep 17 00:00:00 2001 From: Rumata888 Date: Tue, 17 Nov 2020 12:00:06 +0300 Subject: Fixed fd leak on early exit and closed pipes before early exits and PFATAL --- custom_mutators/symcc/symcc.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'custom_mutators/symcc') diff --git a/custom_mutators/symcc/symcc.c b/custom_mutators/symcc/symcc.c index 54a7fbb0..acec29da 100644 --- a/custom_mutators/symcc/symcc.c +++ b/custom_mutators/symcc/symcc.c @@ -142,8 +142,14 @@ void afl_custom_queue_new_entry(my_mutator_t * data, ssize_t r = read(fd, data->mutator_buf, MAX_FILE); DBG("fn=%s, fd=%d, size=%ld\n", fn, fd, r); ck_free(fn); - if (r <= 0) return; close(fd); + if (r <= 0) { + + close(pipefd[1]); + return; + + } + if (r > fcntl(pipefd[1], F_GETPIPE_SZ)) fcntl(pipefd[1], F_SETPIPE_SZ, MAX_FILE); ck_write(pipefd[1], data->mutator_buf, r, filename_new_queue); @@ -151,7 +157,7 @@ void afl_custom_queue_new_entry(my_mutator_t * data, } else { ck_free(fn); - + close(pipefd[1]); PFATAL( "Something happened to the enqueued file before sending its " "contents to symcc binary"); -- cgit 1.4.1