This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RESEND-2][PATCH][BZ #13760] Fix dns lookup for AF_UNSPEC whenresponse for T_A exceeds buffer size


On Wed, Mar 28, 2012 at 4:15 PM, Andreas Jaeger <aj@suse.com> wrote:
> This code is rather confusing. Your analysis and fix looks fine. I suggest
> to add a short comment before the line you change to explain what is tested.
>

Hi,

I have attached an updated patch with an explanatory comment on top of
my change. Is this good enough?

-- 
Siddhesh Poyarekar
http://siddhesh.in
diff --git a/resolv/nss_dns/dns-host.c b/resolv/nss_dns/dns-host.c
index 01369f6..10aecb8 100644
--- a/resolv/nss_dns/dns-host.c
+++ b/resolv/nss_dns/dns-host.c
@@ -1219,7 +1219,13 @@ gaih_getanswer (const querybuf *answer1, int anslen1, const querybuf *answer2,
 				  &first);
   if ((status == NSS_STATUS_SUCCESS || status == NSS_STATUS_NOTFOUND
        || (status == NSS_STATUS_TRYAGAIN
-	   && (errno != ERANGE || *h_errnop != NO_RECOVERY)))
+	   /* We want to look at the second answer in case of an
+	      NSS_STATUS_TRYAGAIN only if the error is non-recoverable, i.e.
+	      *h_errnop is NO_RECOVERY. If not, and if the failure was due to
+	      an insufficient buffer (ERANGE), then we need to drop the results
+	      and pass on the NSS_STATUS_TRYAGAIN to the caller so that it can
+	      repeat the query with a larger buffer.  */
+	   && (*errnop != ERANGE || *h_errnop == NO_RECOVERY)))
       && answer2 != NULL && anslen2 > 0)
     {
       enum nss_status status2 = gaih_getanswer_slice(answer2, anslen2, qname,

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]