Changeset 4489

Show
Ignore:
Timestamp:
07/07/06 04:10:28 (2 years ago)
Author:
erijo
Message:

Success for glibc's gethostbyname_r is defined in the manpage as:
[...] return 0 on success and non-zero on error. [...] *result will be NULL
on error or point to the result on success [...]

If we just check herror, it will fail for local aliases since herror is
set to 1 when looking up aliases from /etc/hosts (at least on my system).
Instead, do as the manpage suggests.

Thanks to Patrick Cernko for the initial patch.

Closes #705.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/licq/src/support.c

    r3523 r4489  
    238238  struct hostent *h_buf; 
    239239  int herror = 0; 
    240   gethostbyname_r(szHostName, h, buf, buflen, &h_buf, &herror); 
    241   return herror; 
     240  int retval = gethostbyname_r(szHostName, h, buf, buflen, &h_buf, &herror); 
     241  return ((retval == 0 && h_buf != NULL) ? 0 /* success */ : herror); 
    242242// Solaris, Irix 
    243243#elif defined(sun) || defined(__sgi)