unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Re: [Emacs-diffs] master a066fb1: Fix use-after-close in connect_network_socket
       [not found] ` <20160721092948.D1106220159@vcs.savannah.gnu.org>
@ 2016-08-01 11:43   ` Ken Brown
  2016-08-02  7:32     ` Paul Eggert
  0 siblings, 1 reply; 2+ messages in thread
From: Ken Brown @ 2016-08-01 11:43 UTC (permalink / raw)
  To: emacs-devel, Paul Eggert

On 7/21/2016 5:29 AM, Paul Eggert wrote:
> branch: master
> commit a066fb1ceee373c982214c28206108c5fba01bf7
> Author: Paul Eggert <eggert@cs.ucla.edu>
> Commit: Paul Eggert <eggert@cs.ucla.edu>
>
>     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



^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [Emacs-diffs] master a066fb1: Fix use-after-close in connect_network_socket
  2016-08-01 11:43   ` [Emacs-diffs] master a066fb1: Fix use-after-close in connect_network_socket Ken Brown
@ 2016-08-02  7:32     ` Paul Eggert
  0 siblings, 0 replies; 2+ messages in thread
From: Paul Eggert @ 2016-08-02  7:32 UTC (permalink / raw)
  To: Ken Brown, emacs-devel

[-- Attachment #1: Type: text/plain, Size: 247 bytes --]

Ken Brown wrote:
> 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.

Yes, thanks, I think you're right. I installed the attached on master to fix that.

[-- Attachment #2: 0001-Fix-use-after-close-in-connect_network_socket.patch --]
[-- Type: text/x-diff, Size: 1095 bytes --]

From 10ae6903134d0c501ede683e698a4f0a36cd6297 Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Tue, 2 Aug 2016 03:31:04 -0400
Subject: [PATCH] Fix use-after-close in connect_network_socket

* src/process.c (connect_network_socket):
Reverse sense of previous fix.  Problem reported by Ken Brown in:
http://lists.gnu.org/archive/html/emacs-devel/2016-08/msg00004.html
---
 src/process.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/process.c b/src/process.c
index bc2ac45..5e48e43 100644
--- a/src/process.c
+++ b/src/process.c
@@ -3185,7 +3185,7 @@ connect_network_socket (Lisp_Object proc, Lisp_Object addrinfos,
 	      xerrno = errno;
 	      emacs_close (s);
 	      s = -1;
-	      if (socket_to_use < 0)
+	      if (0 <= socket_to_use)
 		break;
 	      continue;
 	    }
@@ -3314,7 +3314,7 @@ connect_network_socket (Lisp_Object proc, Lisp_Object addrinfos,
       specpdl_ptr = specpdl + count1;
       emacs_close (s);
       s = -1;
-      if (socket_to_use < 0)
+      if (0 <= socket_to_use)
 	break;
 
 #ifdef WINDOWSNT
-- 
2.5.5


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-08-02  7:32 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20160721092948.2203.76649@vcs.savannah.gnu.org>
     [not found] ` <20160721092948.D1106220159@vcs.savannah.gnu.org>
2016-08-01 11:43   ` [Emacs-diffs] master a066fb1: Fix use-after-close in connect_network_socket Ken Brown
2016-08-02  7:32     ` Paul Eggert

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).