GnuTLS 2.6.6/2.7.8 assumes AF_INET6 is available

Simon Josefsson simon at josefsson.org
Tue May 5 12:01:00 CEST 2009


"Tom G. Christensen" <tgc at jupiterrise.com> writes:

> I just attempted a build of GnuTLS 2.6.6 on Solaris 2.6 but it fails
> in src/serv.c because AF_INET6 is undefined.
>
> gcc -std=gnu99 -DHAVE_CONFIG_H -I. -I..  -I../includes -I../includes -I../lgl -I../lgl -I../gl -I../gl -I./cfg -I/usr/tgcware/include -I/usr/tgcware/include -g -O2 -Wno-pointer-sign -MT serv.o -MD -MP -MF .deps/serv.Tpo -c -o serv.o serv.c
> serv.c:783: warning: 'struct sockaddr_storage' declared inside parameter list
> serv.c:783: warning: its scope is only this definition or declaration, which is probably not what you want
> serv.c: In function 'get_port':
> serv.c:785: error: dereferencing pointer to incomplete type
> serv.c:787: error: 'AF_INET6' undeclared (first use in this function)
> serv.c:787: error: (Each undeclared identifier is reported only once
> serv.c:787: error: for each function it appears in.)
> serv.c:788: error: dereferencing pointer to incomplete type
> serv.c: In function 'main':
> serv.c:813: error: storage size of 'client_address' isn't known
> make[3]: *** [serv.o] Error 1
>
> Grepping for AF_INET6 reveals the same issue in src/certtool-cfg.c
>
> I looked at 2.7.8 and there seems to have been no change in the
> situation there.
>
> The buildlog from 2.6.6 is available here:
> http://jupiterrise.com/tmp

Thanks for the report.  For 2.6.6, can you try the patch below?  If it
works, we can port it to GnuTLS 2.7.x as well.

/Simon

diff --git a/src/certtool-cfg.c b/src/certtool-cfg.c
index 796dc7e..6acf01c 100644
--- a/src/certtool-cfg.c
+++ b/src/certtool-cfg.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2004, 2005, 2006, 2007, 2008 Free Software Foundation
+ * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation
  *
  * This file is part of GNUTLS.
  *
@@ -732,6 +732,7 @@ static int string_to_ip( unsigned char *ip, const char * str)
   int len = strlen( str);
   int ret;
 
+#if HAVE_IPV6
   if ( strchr(str, ':') != NULL || len > 16) { /* IPv6 */
     ret = inet_pton(AF_INET6, str, ip);
     if (ret <= 0) {
@@ -741,7 +742,9 @@ static int string_to_ip( unsigned char *ip, const char * str)
 
     /* To be done */
     return 16;
-  } else { /* IPv4 */
+  } else
+#endif
+  { /* IPv4 */
     ret = inet_pton(AF_INET, str, ip);
     if (ret <= 0) {
         fprintf(stderr, "Error in IPv4 address %s\n", str);
diff --git a/src/serv.c b/src/serv.c
index c138bff..a8e0910 100644
--- a/src/serv.c
+++ b/src/serv.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2004, 2006, 2007, 2008 Free Software Foundation
+ * Copyright (C) 2004, 2006, 2007, 2008, 2009 Free Software Foundation
  * Copyright (C) 2001,2002 Paul Sheer
  * Portions Copyright (C) 2002,2003 Nikos Mavrogiannopoulos
  *
@@ -784,8 +784,10 @@ get_port (const struct sockaddr_storage *addr)
 {
   switch (addr->ss_family)
     {
+#if HAVE_IPV6
     case AF_INET6:
       return ntohs (((const struct sockaddr_in6 *) addr)->sin6_port);
+#endif
     case AF_INET:
       return ntohs (((const struct sockaddr_in *) addr)->sin_port);
     }





More information about the Gnutls-devel mailing list