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

(usagi-users 01420) heads-up: getaddrinfo return values



Hello,

A heads-up.

I came across this when porting KAME patches to Linux.  Getaddrinfo return 
values in Glibc are negative, in BSD libc positive.

In consequence, e.g. netperf required the attached patch so it wouldn't 
segfault on Linux if name lookup returns an error.

Just something to watch out and be careful about.  Checking for != 0 is 
what e.g. draft-shin-ngtrans-application-transition-01.txt recommends 
anyway.

I think if there are any other patches in the KAME repository which check 
for '> 0', they should be changed.

-- 
Pekka Savola                 "Tell me of difficulties surmounted,
Netcore Oy                   not those you stumble over and fall"
Systems. Networks. Security.  -- Robert Jordan: A Crown of Swords

--- netperf-2.1pl3/netlib.c~	Thu May  2 10:43:47 2002
+++ netperf-2.1pl3/netlib.c	Thu May  2 10:43:47 2002
@@ -1901,7 +1901,7 @@
   hints.ai_family = af;
   hints.ai_socktype = SOCK_STREAM;
   hints.ai_flags = AI_PASSIVE;
-  if (getaddrinfo(hostname, pbuf, &hints, &res) > 0) {
+  if (getaddrinfo(hostname, pbuf, &hints, &res) != 0) {
       fprintf(where,
 	      "establish_control: could not resolve the destination %s\n",
 	      hostname);