billiob pushed a commit to branch master.

http://git.enlightenment.org/apps/terminology.git/commit/?id=7508c8658b71d7151892ff7a9347c77348a64afc

commit 7508c8658b71d7151892ff7a9347c77348a64afc
Author: Boris Faure <bill...@gmail.com>
Date:   Mon Dec 5 22:45:44 2016 +0100

    termpty: ensure we're not reading from invalid fd
---
 src/bin/termpty.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/src/bin/termpty.c b/src/bin/termpty.c
index 57398fb..476c1d0 100644
--- a/src/bin/termpty.c
+++ b/src/bin/termpty.c
@@ -169,6 +169,8 @@ _cb_fd_read(void *data, Ecore_Fd_Handler *fd_handler)
         ERR("error while reading from tty slave fd");
         return ECORE_CALLBACK_CANCEL;
      }
+   if (ty->fd == -1)
+     return ECORE_CALLBACK_CANCEL;
 
    // read up to 64 * 4096 bytes
    for (reads = 0; reads < 64; reads++)
@@ -190,6 +192,10 @@ _cb_fd_read(void *data, Ecore_Fd_Handler *fd_handler)
                {
                   ERR("error while reading from tty slave fd: %s", 
strerror(errno));
                }
+             close(ty->fd);
+             ty->fd = -1;
+             if (ty->hand_fd) ecore_main_fd_handler_del(ty->hand_fd);
+             ty->hand_fd = NULL;
              return ECORE_CALLBACK_CANCEL;
           }
         if (len <= 0) break;
@@ -584,7 +590,11 @@ termpty_free(Termpty *ty)
    if (ty->block.blocks) eina_hash_free(ty->block.blocks);
    if (ty->block.chid_map) eina_hash_free(ty->block.chid_map);
    if (ty->block.active) eina_list_free(ty->block.active);
-   if (ty->fd >= 0) close(ty->fd);
+   if (ty->fd >= 0)
+     {
+        close(ty->fd);
+        ty->fd = -1;
+     }
    if (ty->slavefd >= 0) close(ty->slavefd);
    if (ty->pid >= 0)
      {

-- 


Reply via email to