[stunnel-users] A couple of patches against 4.06

Peter Pentchev roam at ringlet.net
Wed Dec 29 15:45:47 CET 2004


First of all, thanks for writing and maintaining this great piece
of software :)

When I ported 4.06 to FreeBSD on Monday, there were three changes that
needed to be made.  One is the passing of -1, not -1000, to poll(2),
which has already been discussed on this list (and which, by the way, is
mandated by POSIX and the Single Unix Specification, as you can see at
http://www.opengroup.org/onlinepubs/007908799/xsh/poll.html )
The other two can be seen in the patch below.

The first one is related to the fact that EAI_NODATA is not present on
all systems - it was actually obsoleted by the KAME implementation of
IPv6 about an year ago.  On some systems it is defined and has its own
value - then stunnel builds just fine.  On other systems it is not
defined at all, while on yet other systems it is aliased to EAI_NONAME,
so 'case EAI_NONAME' and 'case EAI_NODATA' would produce an error
message from the compiler.  Thus, the #ifdef and #if in the first chunk
of the patch.  This could not be done portably with a single statement,
something like '#if defined(EAI_NODATA) && EAI_NODATA != EAI_NONAME',
since there are some compilers that would barf on the second part if
EAI_NODATA was not actually defined.

The second chunk of the patch fixes getnameinfo() error reporting - just
like with getaddrinfo(), getnameinfo() errors should be displayed using
s_gai_strerror() instead of sockerror().

Keep up the good work!


--- src/network.c.orig	Thu Oct 14 18:03:49 2004
+++ src/network.c	Wed Dec 29 14:16:06 2004
@@ -416,8 +416,12 @@
             return "Temporary failure in name resolution (EAI_AGAIN)";
         case EAI_FAIL:
             return "Non-recoverable failure in name resolution (EAI_FAIL)";
+#ifdef EAI_NODATA
         case EAI_NODATA:
             return "No address associated with nodename (EAI_NODATA)";
         case EAI_FAMILY:
             return "ai_family not supported (EAI_FAMILY)";
         case EAI_SOCKTYPE:
@@ -562,10 +566,13 @@
 /* getnameinfo() version */
 char *s_ntop(char *text, SOCKADDR_UNION *addr) {
     char host[20], port[6];
+    int err;
-    if(getnameinfo(&addr->sa, addr_len(*addr),
-            host, 20, port, 6, NI_NUMERICHOST|NI_NUMERICSERV)) {
-        sockerror("getnameinfo");
+    err = getnameinfo(&addr->sa, addr_len(*addr),
+            host, 20, port, 6, NI_NUMERICHOST|NI_NUMERICSERV);
+    if (err) {
+        s_log(LOG_ERR, "Error resolving the specified address: %s",
+            s_gai_strerror(err));
         strcpy(text, "unresolvable IP");
         return text;

Peter Pentchev	roam at ringlet.net    roam at cnsys.bg    roam at FreeBSD.org
PGP key:	http://people.FreeBSD.org/~roam/roam.key.asc
Key fingerprint	FDBA FD79 C26F 3C51 C95E  DF9E ED18 B68D 1619 4553
.siht ekil ti gnidaer eb d'uoy ,werbeH ni erew ecnetnes siht fI
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
URL: <http://www.stunnel.org/pipermail/stunnel-users/attachments/20041229/c926e45f/attachment.sig>

More information about the stunnel-users mailing list