about summary refs log tree commit diff
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2008-05-17 19:54:58 +0000
committerUlrich Drepper <drepper@redhat.com>2008-05-17 19:54:58 +0000
commit343996c47ca25b7aadd8bcf1f0775841754a8099 (patch)
tree93cc90778dee4ed73ef5d2f936d1e17b7437016d
parent74e133858878bf14222273726f8b9d72b39df01e (diff)
downloadglibc-343996c47ca25b7aadd8bcf1f0775841754a8099.tar.gz
glibc-343996c47ca25b7aadd8bcf1f0775841754a8099.tar.xz
glibc-343996c47ca25b7aadd8bcf1f0775841754a8099.zip
* resolv/nss_dns/dns-host.c (gaih_getanswer_slice): If there are
	no answers return NSS_STATUS_NOTFOUND.
	(gaih_getanswer): Don't call gaih_getanswer_slice if the answer
	buffer does not have any content.

	* nscd/servicescache.c: Likewise.
-rw-r--r--ChangeLog9
-rw-r--r--resolv/nss_dns/dns-host.c16
2 files changed, 19 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index 110f60889c..688d38d059 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2008-05-17  Ulrich Drepper  <drepper@redhat.com>
+
+	* resolv/nss_dns/dns-host.c (gaih_getanswer_slice): If there are
+	no answers return NSS_STATUS_NOTFOUND.
+	(gaih_getanswer): Don't call gaih_getanswer_slice if the answer
+	buffer does not have any content.
+
 2008-05-16  Ulrich Drepper  <drepper@redhat.com>
 
 	* string/strcasestr.c (CMP_FUNC): Use __strncasecmp, not strncasecmp.
@@ -174,7 +181,7 @@
 	* nscd/hstcache.c: Likewise.
 	* nscd/initgrcache.c: Likewise.
 	* nscd/pwdcache.c: Likewise.
-	* nscd/servicecache.c: Likewise.
+	* nscd/servicescache.c: Likewise.
 
 2008-05-10  Roland McGrath  <roland@redhat.com>
 
diff --git a/resolv/nss_dns/dns-host.c b/resolv/nss_dns/dns-host.c
index c52f9f7f84..d998ebf4f5 100644
--- a/resolv/nss_dns/dns-host.c
+++ b/resolv/nss_dns/dns-host.c
@@ -990,6 +990,9 @@ gaih_getanswer_slice (const querybuf *answer, int anslen, const char *qname,
   char *h_name = NULL;
   int h_namelen = 0;
 
+  if (ancount == 0)
+    return NSS_STATUS_NOTFOUND;
+
   while (ancount-- > 0 && cp < end_of_message && had_error == 0)
     {
       n = __ns_name_unpack (answer->buf, end_of_message, cp,
@@ -1164,12 +1167,15 @@ gaih_getanswer (const querybuf *answer1, int anslen1, const querybuf *answer2,
 {
   int first = 1;
 
-  enum nss_status status = gaih_getanswer_slice(answer1, anslen1, qname,
-						&pat, &buffer, &buflen,
-						errnop, h_errnop, ttlp,
-						&first);
+  enum nss_status status = NSS_STATUS_NOTFOUND;
+
+  if (anslen1 > 0)
+    status = gaih_getanswer_slice(answer1, anslen1, qname,
+				  &pat, &buffer, &buflen,
+				  errnop, h_errnop, ttlp,
+				  &first);
   if ((status == NSS_STATUS_SUCCESS || status == NSS_STATUS_NOTFOUND)
-      && answer2 != NULL)
+      && answer2 != NULL && anslen2 > 0)
     status = gaih_getanswer_slice(answer2, anslen2, qname,
 				  &pat, &buffer, &buflen,
 				  errnop, h_errnop, ttlp, &first);