X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=lib%2Fcanon-host.c;h=c29f314314f4a457c64e5a997f22eee565b90d3e;hb=c5ce79f4c514b37b5756e85530112d778cff302a;hp=dcbec53385c1edd087d39fad9b9abaae2555dd23;hpb=a4eb413867359e1afd4caa3068f1968889e2e17a;p=gnulib.git diff --git a/lib/canon-host.c b/lib/canon-host.c index dcbec5338..c29f31431 100644 --- a/lib/canon-host.c +++ b/lib/canon-host.c @@ -1,6 +1,6 @@ /* Host name canonicalization - Copyright (C) 2005 Free Software Foundation, Inc. + Copyright (C) 2005, 2006 Free Software Foundation, Inc. Written by Derek Price . @@ -18,9 +18,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#ifdef HAVE_CONFIG_H -# include -#endif +#include #include "canon-host.h" @@ -71,7 +69,12 @@ canon_host_r (char const *host, int *cherror) status = getaddrinfo (host, NULL, &hints, &res); if (!status) { - retval = strdup (res->ai_canonname); + /* http://lists.gnu.org/archive/html/bug-coreutils/2006-09/msg00300.html + says Darwin 7.9.0 getaddrinfo returns 0 but sets + res->ai_canonname to NULL. */ + retval = strdup (res->ai_canonname ? res->ai_canonname : host); + if (!retval && cherror) + *cherror = EAI_MEMORY; freeaddrinfo (res); } else if (cherror)