getaddrinfo: Return EAI_NODATA if gethostbyname2_r reports NO_DATA [BZ #21922]

Message ID 20170808170144.407DB4029923B@oldenburg.str.redhat.com
State New
Headers show

Commit Message

Florian Weimer Aug. 8, 2017, 5:01 p.m.
2017-08-08  Florian Weimer  <fweimer@redhat.com>

	[BZ #21922]
	* sysdeps/posix/getaddrinfo.c (gaih_inet): Report EAI_NODATA error
	coming from gethostbyname2_r.

Patch

diff --git a/sysdeps/posix/getaddrinfo.c b/sysdeps/posix/getaddrinfo.c
index 9d9e7e2..0cf87c2 100644
--- a/sysdeps/posix/getaddrinfo.c
+++ b/sysdeps/posix/getaddrinfo.c
@@ -619,6 +619,14 @@  gaih_inet (const char *name, const struct gaih_service *service,
 			}
 		      *pat = addrmem;
 		    }
+		  else
+		    {
+		      if (h_errno == NO_DATA)
+			result = -EAI_NODATA;
+		      else
+			result = -EAI_NONAME;
+		      goto free_and_return;
+		    }
 		}
 	      else
 		{