From 755a4c3f2f3feccaf9f43e97dd0ab78b647b0662 Mon Sep 17 00:00:00 2001 From: Boris Faure Date: Sun, 1 Nov 2015 18:39:39 +0100 Subject: [PATCH] enable fuzzing with --enable-fuzzing Only enable it if you know what you're doing --- configure.ac | 19 ++++++++++++++++++ src/bin/termpty.c | 50 +++++++++++++++++++++++------------------------ 2 files changed, 43 insertions(+), 26 deletions(-) diff --git a/configure.ac b/configure.ac index 1f8f6510..8a99fcfc 100644 --- a/configure.ac +++ b/configure.ac @@ -67,6 +67,24 @@ requirements="\ EFL_ENABLE_EO_API_SUPPORT EFL_ENABLE_BETA_API_SUPPORT +# check for fuzzing +want_fuzzing="fuzzing" +AC_ARG_ENABLE([fuzzing], + [AS_HELP_STRING([--enable-fuzzing],[Enable fuzzing on terminology. Binaries + are not suited for production. @<:@default=disabled@:>@])], + [ + if test "x${enableval}" = "xyes" ; then + want_fuzzing="yes" + AC_DEFINE([ENABLE_FUZZING], [1], [Fuzzing enabled]) + AC_SUBST([want_fuzzing]) + else + want_fuzzing="no" + fi + ], + [want_fuzzing="no"]) + +AM_CONDITIONAL([ENABLE_FUZZING], [test "${want_fuzzing}" = "yes"]) + PKG_CHECK_MODULES([TERMINOLOGY], [${requirements}]) PKG_CHECK_MODULES([ELDBUS], @@ -169,4 +187,5 @@ echo echo "Features:" echo " dbus................: $have_eldbus" echo " gettext.............: $have_po" +echo " fuzzing.............: $want_fuzzing" echo diff --git a/src/bin/termpty.c b/src/bin/termpty.c index c9d713f9..83dfc58c 100644 --- a/src/bin/termpty.c +++ b/src/bin/termpty.c @@ -278,20 +278,19 @@ _cb_fd_read(void *data, Ecore_Fd_Handler *fd_handler) if (ty->cb.change.func) ty->cb.change.func(ty->cb.change.data); if (len <= 0) { - if (42) - { - ty->exit_code = 0; - ty->pid = -1; +#ifdef ENABLE_FUZZING + ty->exit_code = 0; + ty->pid = -1; - if (ty->hand_exe_exit) ecore_event_handler_del(ty->hand_exe_exit); - ty->hand_exe_exit = NULL; - if (ty->hand_fd) ecore_main_fd_handler_del(ty->hand_fd); - ty->hand_fd = NULL; - ty->fd = -1; - ty->slavefd = -1; - if (ty->cb.exited.func) - ty->cb.exited.func(ty->cb.exited.data); - } + if (ty->hand_exe_exit) ecore_event_handler_del(ty->hand_exe_exit); + ty->hand_exe_exit = NULL; + if (ty->hand_fd) ecore_main_fd_handler_del(ty->hand_fd); + ty->hand_fd = NULL; + ty->fd = -1; + ty->slavefd = -1; + if (ty->cb.exited.func) + ty->cb.exited.func(ty->cb.exited.data); +#endif return ECORE_CALLBACK_CANCEL; } @@ -350,18 +349,16 @@ termpty_new(const char *cmd, Eina_Bool login_shell, const char *cd, ty->circular_offset = 0; - /* TODO: boris */ - if (42) - { - ty->fd = STDIN_FILENO; - ty->hand_fd = ecore_main_fd_handler_add(ty->fd, - ECORE_FD_READ | ECORE_FD_ERROR, - _cb_fd_read, ty, - NULL, NULL); - _pty_size(ty); - termpty_save_register(ty); - return ty; - } +#ifdef ENABLE_FUZZING + ty->fd = STDIN_FILENO; + ty->hand_fd = ecore_main_fd_handler_add(ty->fd, + ECORE_FD_READ | ECORE_FD_ERROR, + _cb_fd_read, ty, + NULL, NULL); + _pty_size(ty); + termpty_save_register(ty); + return ty; +#endif needs_shell = ((!cmd) || (strpbrk(cmd, " |&;<>()$`\\\"'*?#") != NULL)); @@ -911,8 +908,9 @@ termpty_write(Termpty *ty, const char *input, int len) { int fd = ty->fd; - /* TODO: boris */ +#ifdef ENABLE_FUZZING fd = STDOUT_FILENO; +#endif if (fd < 0) return; if (write(fd, input, len) < 0) ERR(_("Could not write to file descriptor %d: %s"),