X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;ds=sidebyside;f=lib%2Fcanon-host.c;h=50ba67a6cfd11222cc91936c79acb2ad684d28b4;hb=6b78d03bdd89f7c8dec8756bf296b75b156b90f3;hp=e2bd1a773b0cebf8d2232e49322dd13e25d3f38e;hpb=639a9c73113836fec5694af9a938a6556e7dbc3c;p=gnulib.git diff --git a/lib/canon-host.c b/lib/canon-host.c index e2bd1a773..50ba67a6c 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, 2007 Free Software Foundation, Inc. Written by Derek Price . @@ -18,14 +18,13 @@ 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" +#include + #include "getaddrinfo.h" -#include "strdup.h" /* Store the last error for the single-threaded version of this function. */ static int last_cherror; @@ -71,7 +70,10 @@ 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);