[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
scm_to_sockaddr mishandles IPv6 addresses
From: |
Scott McPeak |
Subject: |
scm_to_sockaddr mishandles IPv6 addresses |
Date: |
Tue, 29 Sep 2009 20:16:50 -0700 |
User-agent: |
Thunderbird 2.0.0.18 (X11/20081113) |
Hi,
In Guile-1.8.7, the function 'scm_to_sockaddr' mishandles IPv6
addresses. Specifically, it passes the 'address' parameter (which is
a vector) to the 'scm_to_ipv6' function, which expects an integer.
I have a patch, at the end, that fixes the problem.
The patch also improves the error message produced by 'scm_to_ipv6'
when passed the wrong type of argument. I realize it's somewhat
unconventional to use the C function name as the 'subr' in
'scm_wrong_type_arg_msg', but it to me it seems preferable to NULL; if
the message had included that name when it originally manifested in my
program, diagnosis would have taken less time.
Here is a demonstration of the problem. I have a service listening on
port 8080 of the IPv6 loopback interface, "::1". This code is running
on linux/x86_64.
Test program:
$ cat testipv6.scm
(define INADDR_LOOPBACK_IPV6 1) ; "::1"
(define sock (socket PF_INET6 SOCK_STREAM 0))
(define addr (make-socket-address AF_INET6 INADDR_LOOPBACK_IPV6 8080))
(display "about to connect\n")
(connect sock addr)
(display "connected!\n")
(close-port sock)
Original behavior with Guile 1.8.7:
$ guile testipv6.scm
about to connect
ERROR: Wrong type: #(10 1 8080 0 0)
After improving the scm_to_ipv6 error message:
$ guile testipv6.scm
about to connect
ERROR: In procedure scm_to_ipv6:
ERROR: Wrong type (expecting integer): #(10 1 8080 0 0)
After fixing the bug in scm_to_sockaddr:
$ guile testipv6.scm
about to connect
connected!
-Scott
diff --git a/libguile/socket.c b/libguile/socket.c
index f34b6d4..b51e4f1 100644
--- a/libguile/socket.c
+++ b/libguile/socket.c
@@ -347,7 +347,7 @@ scm_to_ipv6 (scm_t_uint8 dst[16], SCM src)
scm_remember_upto_here_1 (src);
}
else
- scm_wrong_type_arg (NULL, 0, src);
+ scm_wrong_type_arg_msg ("scm_to_ipv6", 0, src, "integer");
}
#ifdef HAVE_INET_PTON
@@ -1167,7 +1167,7 @@ scm_to_sockaddr (SCM address, size_t *address_size)
{
struct sockaddr_in6 c_inet6;
- scm_to_ipv6 (c_inet6.sin6_addr.s6_addr, address);
+ scm_to_ipv6 (c_inet6.sin6_addr.s6_addr, SCM_SIMPLE_VECTOR_REF
(address, 1));
c_inet6.sin6_port =
htons (scm_to_ushort (SCM_SIMPLE_VECTOR_REF (address, 2)));
c_inet6.sin6_flowinfo =
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- scm_to_sockaddr mishandles IPv6 addresses,
Scott McPeak <=