Package: inetutils
Version: 1.5
Author: Guillem Jover <guillem@hadrons.org>
Status: applied
Description:
 Avoid segfault by not passing NULL to gethostname.


2006-10-21  Guillem Jover  <guillem@hadrons.org>

	* libinetutils/localhost.c (localhost): Determine the FQDN only
	if gethostname did not fail.


Index: libinetutils/localhost.c
===================================================================
RCS file: /sources/inetutils/inetutils/libinetutils/localhost.c,v
retrieving revision 1.13
diff -u -r1.13 localhost.c
--- libinetutils/localhost.c	2 Dec 2005 14:05:28 -0000	1.13
+++ libinetutils/localhost.c	21 Oct 2006 13:32:06 -0000
@@ -77,22 +77,23 @@
       free (buf);
       buf = 0;
     }
+  else
+    /* Determine FQDN */
+    {
+      struct hostent *hp = gethostbyname(buf);
 
-  /* Determine FQDN */
-  {
-    struct hostent *hp = gethostbyname(buf);
+      if (hp)
+        {
+	  struct in_addr addr;
+	  addr.s_addr = *(unsigned int*) hp->h_addr;
+	  hp = gethostbyaddr((char *) &addr, sizeof(addr), AF_INET);
+	  if (hp)
+	    {
+	      free(buf);
+	      buf = strdup(hp->h_name);
+	    }
+        }
+    }
 
-    if (hp)
-      {
-	struct in_addr addr;
-	addr.s_addr = *(unsigned int*) hp->h_addr;
-	hp = gethostbyaddr((char *) &addr, sizeof(addr), AF_INET);
-	if (hp)
-	  {
-	    free(buf);
-	    buf = strdup(hp->h_name);
-	  }
-      }
-  }
   return buf;
 }
