unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* [PATCH] fix conv_lisp_to_sockaddr for AF_INET6 addresses
@ 2016-02-06 16:06 David Edmondson
  2016-02-07  1:45 ` Lars Ingebrigtsen
  2016-02-07 17:52 ` John Wiegley
  0 siblings, 2 replies; 20+ messages in thread
From: David Edmondson @ 2016-02-06 16:06 UTC (permalink / raw)
  To: emacs-devel

When trying to test Lars' async-dns changes I encountered memory
corruption whenever the addresses returned for a host included IPv6
addresses. This turns out to be a bug in the mainline code which is just
more likely to be tickled by the async-dns changes because they convert
addresses to lisp objects whenever `make-network-process' is called (the
current code doesn't do that).

Here is a proposed fix:

From c9995971d47e78475fb5ec9d9b34d2187941227f Mon Sep 17 00:00:00 2001
Date: Sat, 6 Feb 2016 16:02:23 +0000
Subject: [PATCH] * src/process.c (conv_lisp_to_sockaddr): Correctly convert
 AF_INET6 addresses

AF_INET6 addresses are converted to a list of 16 bit quantities by
conv_sockaddr_to_lisp(). conv_lisp_to_sockaddr() should follow the
same scheme rather than expecting a (longer) list of 8 bit quantities.
---
 src/process.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/process.c b/src/process.c
index e1ebdff..1eac5e1 100644
--- a/src/process.c
+++ b/src/process.c
@@ -2372,7 +2372,7 @@ conv_lisp_to_sockaddr (int family, Lisp_Object address, struct sockaddr *sa, int
 	{
 	  struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *) sa;
 	  uint16_t *ip6 = (uint16_t *)&sin6->sin6_addr;
-	  len = sizeof (sin6->sin6_addr) + 1;
+	  len = sizeof (sin6->sin6_addr) / 2 + 1;
 	  hostport = XINT (p->contents[--len]);
 	  sin6->sin6_port = htons (hostport);
 	  for (i = 0; i < len; i++)
-- 
2.6.3




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

end of thread, other threads:[~2016-02-13 13:19 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-02-06 16:06 [PATCH] fix conv_lisp_to_sockaddr for AF_INET6 addresses David Edmondson
2016-02-07  1:45 ` Lars Ingebrigtsen
2016-02-07  1:50   ` Lars Ingebrigtsen
2016-02-07 17:52 ` John Wiegley
2016-02-08  1:29   ` Lars Ingebrigtsen
2016-02-08  3:34     ` Eli Zaretskii
2016-02-08  3:59       ` Lars Ingebrigtsen
2016-02-08  4:01       ` Lars Ingebrigtsen
2016-02-08  4:07         ` Lars Ingebrigtsen
2016-02-08  7:03           ` Michael Albinus
2016-02-08  7:26             ` Lars Ingebrigtsen
2016-02-08 17:04           ` Eli Zaretskii
2016-02-08 23:17             ` Lars Ingebrigtsen
2016-02-09 19:13               ` Eli Zaretskii
2016-02-09 23:07                 ` Lars Ingebrigtsen
2016-02-10 20:08                   ` Eli Zaretskii
2016-02-10 20:31                     ` Eli Zaretskii
2016-02-11  3:54                       ` Lars Ingebrigtsen
2016-02-13 13:19                         ` Eli Zaretskii
2016-02-08  3:43     ` Lars Ingebrigtsen

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).