emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Emacs-diffs] master a066fb1: Fix use-after-close in connect_network


From: Ken Brown
Subject: Re: [Emacs-diffs] master a066fb1: Fix use-after-close in connect_network_socket
Date: Mon, 1 Aug 2016 07:43:01 -0400
User-agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0

On 7/21/2016 5:29 AM, Paul Eggert wrote:
branch: master
commit a066fb1ceee373c982214c28206108c5fba01bf7
Author: Paul Eggert <address@hidden>
Commit: Paul Eggert <address@hidden>

    Fix use-after-close in connect_network_socket

    * src/process.c (connect_network_socket): Don’t use
    external_sock_fd after closing it.  Problem found by Coverity Scan.
---
 src/process.c |    4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/process.c b/src/process.c
index bdbdefa..bc2ac45 100644
--- a/src/process.c
+++ b/src/process.c
@@ -3185,6 +3185,8 @@ connect_network_socket (Lisp_Object proc, Lisp_Object 
addrinfos,
              xerrno = errno;
              emacs_close (s);
              s = -1;
+             if (socket_to_use < 0)
+               break;
              continue;
            }
        }
@@ -3312,6 +3314,8 @@ connect_network_socket (Lisp_Object proc, Lisp_Object 
addrinfos,
       specpdl_ptr = specpdl + count1;
       emacs_close (s);
       s = -1;
+      if (socket_to_use < 0)
+       break;

 #ifdef WINDOWSNT
       if (xerrno == EINTR)

This commit causes two network-streams-tests failures on Cygwin:

   FAILED  echo-server-with-dns
   FAILED  echo-server-with-localhost

Did you perhaps get the condition (socket_to_use < 0) backwards? If socket_to_use < 0, then it is not external_sock_fd that has been closed.

Ken



reply via email to

[Prev in Thread] Current Thread [Next in Thread]