billiob pushed a commit to branch master.

http://git.enlightenment.org/apps/terminology.git/commit/?id=755a4c3f2f3feccaf9f43e97dd0ab78b647b0662

commit 755a4c3f2f3feccaf9f43e97dd0ab78b647b0662
Author: Boris Faure <bill...@gmail.com>
Date:   Sun Nov 1 18:39:39 2015 +0100

    enable fuzzing with --enable-fuzzing
    
    Only enable it if you know what you're doing
---
 configure.ac      | 19 +++++++++++++++++++
 src/bin/termpty.c | 52 +++++++++++++++++++++++++---------------------------
 2 files changed, 44 insertions(+), 27 deletions(-)

diff --git a/configure.ac b/configure.ac
index 1f8f651..8a99fcf 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 c9d713f..83dfc58 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;
-
-             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);
-          }
+#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);
+#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"),

-- 


Reply via email to