OpenBSD 4.4 gnutls-serv IPv6 Only Bug

Peter Hendrickson pdh at wiredyne.com
Fri Apr 17 08:14:02 CEST 2009


Using GnuTLS 2.6.5 under OpenBSD 4.4, there is a bug in gnutls-serv.
It only listens for connection on an IPv6 port and ignores all IPv4
requests.  This can be seen by running something as simple as
"gnutls-serv --http".  The patch below illustrates the problem and
supplies a quick fix.

(BTW, I have just started looking at GnuTLS and I really like it!)

Peter

--- serv.c.orig	Sat Apr 11 18:35:29 2009
+++ serv.c	Fri Apr 17 06:00:11 2009
@@ -652,6 +652,12 @@
 
   snprintf (portname, sizeof (portname), "%d", listen_port);
   memset (&hints, 0, sizeof (hints));
+  /* Under OpenBSD 4.4, getaddrinfo() returns an IPv6 addrinfo
+     structure followed by an IPv4 addrinfo structure.  The code below
+     uses the first successful structure it gets which means it
+     listens for IPv6 connections.  Setting the family hint to AF_INET
+     forces getaddrinfo() to return IPv4 addrinfo structures. */
+  hints.ai_family = AF_INET;
   hints.ai_socktype = SOCK_STREAM;
   hints.ai_flags = AI_PASSIVE;





More information about the Gnutls-devel mailing list