aboutsummaryrefslogtreecommitdiffstats
path: root/src/process.c
diff options
context:
space:
mode:
authorPaul Eggert2019-01-30 15:11:17 -0800
committerPaul Eggert2019-01-30 15:12:31 -0800
commit9c8412a0b8e1f96b87ea506c3ec67778a4ce7bb4 (patch)
treec693cd8aa6e623ac0a016d33126996afb6e9cd94 /src/process.c
parentb94d76752776cca4d1652cfe715a60f4a36f14a3 (diff)
downloademacs-9c8412a0b8e1f96b87ea506c3ec67778a4ce7bb4.tar.gz
emacs-9c8412a0b8e1f96b87ea506c3ec67778a4ce7bb4.zip
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.
Diffstat (limited to 'src/process.c')
-rw-r--r--src/process.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/process.c b/src/process.c
index 7f32150e8ec..d8acd139c00 100644
--- a/src/process.c
+++ b/src/process.c
@@ -4724,19 +4724,24 @@ server_accept_connection (Lisp_Object server, int channel)
4724 service = Qnil; 4724 service = Qnil;
4725 Lisp_Object args[11]; 4725 Lisp_Object args[11];
4726 int nargs = 0; 4726 int nargs = 0;
4727 AUTO_STRING (procname_format_in, "%s <%d.%d.%d.%d:%d>"); 4727 #define HOST_FORMAT_IN "%d.%d.%d.%d"
4728 AUTO_STRING (procname_format_in6, "%s <[%x:%x:%x:%x:%x:%x:%x:%x]:%d>"); 4728 #define HOST_FORMAT_IN6 "%x:%x:%x:%x:%x:%x:%x:%x"
4729 AUTO_STRING (host_format_in, HOST_FORMAT_IN);
4730 AUTO_STRING (host_format_in6, HOST_FORMAT_IN6);
4731 AUTO_STRING (procname_format_in, "%s <"HOST_FORMAT_IN":%d>");
4732 AUTO_STRING (procname_format_in6, "%s <["HOST_FORMAT_IN6"]:%d>");
4729 AUTO_STRING (procname_format_default, "%s <%d>"); 4733 AUTO_STRING (procname_format_default, "%s <%d>");
4730 switch (saddr.sa.sa_family) 4734 switch (saddr.sa.sa_family)
4731 { 4735 {
4732 case AF_INET: 4736 case AF_INET:
4733 { 4737 {
4734 args[nargs++] = procname_format_in; 4738 args[nargs++] = procname_format_in;
4735 nargs++; 4739 args[nargs++] = host_format_in;
4736 unsigned char *ip = (unsigned char *)&saddr.in.sin_addr.s_addr; 4740 unsigned char *ip = (unsigned char *)&saddr.in.sin_addr.s_addr;
4737 service = make_number (ntohs (saddr.in.sin_port)); 4741 service = make_number (ntohs (saddr.in.sin_port));
4738 for (int i = 0; i < 4; i++) 4742 for (int i = 0; i < 4; i++)
4739 args[nargs++] = make_number (ip[i]); 4743 args[nargs++] = make_number (ip[i]);
4744 host = Fformat (5, args + 1);
4740 args[nargs++] = service; 4745 args[nargs++] = service;
4741 } 4746 }
4742 break; 4747 break;
@@ -4745,11 +4750,12 @@ server_accept_connection (Lisp_Object server, int channel)
4745 case AF_INET6: 4750 case AF_INET6:
4746 { 4751 {
4747 args[nargs++] = procname_format_in6; 4752 args[nargs++] = procname_format_in6;
4748 nargs++; 4753 args[nargs++] = host_format_in6;
4749 DECLARE_POINTER_ALIAS (ip6, uint16_t, &saddr.in6.sin6_addr); 4754 DECLARE_POINTER_ALIAS (ip6, uint16_t, &saddr.in6.sin6_addr);
4750 service = make_number (ntohs (saddr.in.sin_port)); 4755 service = make_number (ntohs (saddr.in.sin_port));
4751 for (int i = 0; i < 8; i++) 4756 for (int i = 0; i < 8; i++)
4752 args[nargs++] = make_number (ip6[i]); 4757 args[nargs++] = make_number (ip6[i]);
4758 host = Fformat (9, args + 1);
4753 args[nargs++] = service; 4759 args[nargs++] = service;
4754 } 4760 }
4755 break; 4761 break;