emacs-devel
[Top][All Lists]
Advanced

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

[PATCH] fix conv_lisp_to_sockaddr for AF_INET6 addresses


From: David Edmondson
Subject: [PATCH] fix conv_lisp_to_sockaddr for AF_INET6 addresses
Date: Sat, 06 Feb 2016 16:06:17 +0000

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




reply via email to

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