all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#34134: 27.0.50; process-contact for accepted sockets broken
@ 2019-01-19  6:52 Mathew Handugan
  2019-01-25  8:07 ` Eli Zaretskii
  0 siblings, 1 reply; 3+ messages in thread
From: Mathew Handugan @ 2019-01-19  6:52 UTC (permalink / raw)
  To: 34134

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

Git commit be9e60fc3c43cc49cc5d749924c3e96737ae297c  causes accepted
sockets to store 't as :host instead of the string-formatted peer IP
address.

This manifests as
 (process-contact proc)
returning something like
 (t 55269)

instead of the expected:
 ("192.168.2.13" 55269)

my clumsy attempt at a simple example:

(defun echo-server-filter (proc string) (print (format "%s %s"
(process-contact proc) string)))
(progn
  (setq echo-server-port 10000)
  (make-network-process :name "echo-server" :family 'ipv4 :service
echo-server-port :filter 'echo-server-filter :sentinel 'echo-server-filter
:server 't)
  (let ((client-process (open-network-stream "echo-client"
                             "*echo-client*" "localhost" echo-server-port)))
    (process-send-string client-process "hello world\n")
    (sleep-for 1)
    (delete-process client-process))
  (delete-process "echo-server")
  )

[-- Attachment #2: Type: text/html, Size: 1133 bytes --]

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

* bug#34134: 27.0.50; process-contact for accepted sockets broken
  2019-01-19  6:52 bug#34134: 27.0.50; process-contact for accepted sockets broken Mathew Handugan
@ 2019-01-25  8:07 ` Eli Zaretskii
  2019-01-30 23:13   ` Paul Eggert
  0 siblings, 1 reply; 3+ messages in thread
From: Eli Zaretskii @ 2019-01-25  8:07 UTC (permalink / raw)
  To: Mathew Handugan, Paul Eggert; +Cc: 34134

> From: Mathew Handugan <mathew@handugan.com>
> Date: Fri, 18 Jan 2019 22:52:41 -0800
> 
> Git commit be9e60fc3c43cc49cc5d749924c3e96737ae297c  causes accepted sockets to store 't as :host
> instead of the string-formatted peer IP address.
> 
> This manifests as 
>  (process-contact proc)
> returning something like
>  (t 55269)
> 
> instead of the expected:
>  ("192.168.2.13" 55269)

Thanks.  Paul, could you please take a look at this?





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

* bug#34134: 27.0.50; process-contact for accepted sockets broken
  2019-01-25  8:07 ` Eli Zaretskii
@ 2019-01-30 23:13   ` Paul Eggert
  0 siblings, 0 replies; 3+ messages in thread
From: Paul Eggert @ 2019-01-30 23:13 UTC (permalink / raw)
  To: Eli Zaretskii, Mathew Handugan; +Cc: 34134-done

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

On 1/25/19 12:07 AM, Eli Zaretskii wrote:
>> From: Mathew Handugan <mathew@handugan.com>
>> Date: Fri, 18 Jan 2019 22:52:41 -0800
>>
>> Git commit be9e60fc3c43cc49cc5d749924c3e96737ae297c  causes accepted sockets to store 't as :host
>> instead of the string-formatted peer IP address.
>>
>> This manifests as
>>   (process-contact proc)
>> returning something like
>>   (t 55269)
>>
>> instead of the expected:
>>   ("192.168.2.13" 55269)
> Thanks.  Paul, could you please take a look at this?

Thanks for reporting the bug, especially the test case. I reproduce the 
problem and fixed it by installing the attached patch into the emacs-26 
branch on Savannah.


[-- Attachment #2: 0001-Fix-process-contact-bug-with-TCP-connections.patch --]
[-- Type: text/x-patch, Size: 2195 bytes --]

From 16d92c9748fe0eb75ec20a1117700525538b5bd0 Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Wed, 30 Jan 2019 15:11:17 -0800
Subject: [PATCH] Fix process-contact bug with TCP connections

This fixes a regression from Emacs 25.3 (Bug#34134).
* src/process.c (server_accept_connection):
Set host correctly, fixing a bug introduced in
2017-09-16T21:29:18Z!eggert@cs.ucla.edu
when working around a GCC bug.
---
 src/process.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/src/process.c b/src/process.c
index 7f32150e8e..d8acd139c0 100644
--- a/src/process.c
+++ b/src/process.c
@@ -4724,19 +4724,24 @@ server_accept_connection (Lisp_Object server, int channel)
   service = Qnil;
   Lisp_Object args[11];
   int nargs = 0;
-  AUTO_STRING (procname_format_in, "%s <%d.%d.%d.%d:%d>");
-  AUTO_STRING (procname_format_in6, "%s <[%x:%x:%x:%x:%x:%x:%x:%x]:%d>");
+  #define HOST_FORMAT_IN "%d.%d.%d.%d"
+  #define HOST_FORMAT_IN6 "%x:%x:%x:%x:%x:%x:%x:%x"
+  AUTO_STRING (host_format_in, HOST_FORMAT_IN);
+  AUTO_STRING (host_format_in6, HOST_FORMAT_IN6);
+  AUTO_STRING (procname_format_in, "%s <"HOST_FORMAT_IN":%d>");
+  AUTO_STRING (procname_format_in6, "%s <["HOST_FORMAT_IN6"]:%d>");
   AUTO_STRING (procname_format_default, "%s <%d>");
   switch (saddr.sa.sa_family)
     {
     case AF_INET:
       {
 	args[nargs++] = procname_format_in;
-	nargs++;
+	args[nargs++] = host_format_in;
 	unsigned char *ip = (unsigned char *)&saddr.in.sin_addr.s_addr;
 	service = make_number (ntohs (saddr.in.sin_port));
 	for (int i = 0; i < 4; i++)
 	  args[nargs++] = make_number (ip[i]);
+	host = Fformat (5, args + 1);
 	args[nargs++] = service;
       }
       break;
@@ -4745,11 +4750,12 @@ server_accept_connection (Lisp_Object server, int channel)
     case AF_INET6:
       {
 	args[nargs++] = procname_format_in6;
-	nargs++;
+	args[nargs++] = host_format_in6;
 	DECLARE_POINTER_ALIAS (ip6, uint16_t, &saddr.in6.sin6_addr);
 	service = make_number (ntohs (saddr.in.sin_port));
 	for (int i = 0; i < 8; i++)
 	  args[nargs++] = make_number (ip6[i]);
+	host = Fformat (9, args + 1);
 	args[nargs++] = service;
       }
       break;
-- 
2.20.1


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

end of thread, other threads:[~2019-01-30 23:13 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-01-19  6:52 bug#34134: 27.0.50; process-contact for accepted sockets broken Mathew Handugan
2019-01-25  8:07 ` Eli Zaretskii
2019-01-30 23:13   ` Paul Eggert

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.