about summary refs log tree commit diff
path: root/nss/test-netdb.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2001-08-24 20:38:43 +0000
committerUlrich Drepper <drepper@redhat.com>2001-08-24 20:38:43 +0000
commitbb84d3b33c5d8b5a13606006ecd7d0e45a8ecf90 (patch)
tree2c493239c2a83d922b29862d2ad9de86cfcd10d6 /nss/test-netdb.c
parentaf8bf6bd492830cfa5fbe9ae7d25fe0734ca207a (diff)
downloadglibc-bb84d3b33c5d8b5a13606006ecd7d0e45a8ecf90.tar.gz
glibc-bb84d3b33c5d8b5a13606006ecd7d0e45a8ecf90.tar.xz
glibc-bb84d3b33c5d8b5a13606006ecd7d0e45a8ecf90.zip
Update.
	* nss/test-netdb.c (test_hosts): Don't segfault if gethostname
	returns NULL.
Diffstat (limited to 'nss/test-netdb.c')
-rw-r--r--nss/test-netdb.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/nss/test-netdb.c b/nss/test-netdb.c
index 8ae6d12fc0..a701b49b77 100644
--- a/nss/test-netdb.c
+++ b/nss/test-netdb.c
@@ -185,12 +185,15 @@ test_hosts (void)
   if (gethostname (name, namelen) == 0)
     {
       printf ("Hostname: %s\n", name);
-      hptr1 = gethostbyname (name);
-      output_hostent ("gethostbyname (gethostname(...))", hptr1);
+      if (name != NULL)
+	{
+	  hptr1 = gethostbyname (name);
+	  output_hostent ("gethostbyname (gethostname(...))", hptr1);
+	}
     }
 
   ip.s_addr = htonl (INADDR_LOOPBACK);
-  hptr1 = gethostbyaddr ((char *)&ip, sizeof(ip), AF_INET);
+  hptr1 = gethostbyaddr ((char *) &ip, sizeof(ip), AF_INET);
   if (hptr1 != NULL)
     {
       printf ("official name of 127.0.0.1: %s\n", hptr1->h_name);