From: Brian W. <bwe...@xb...> - 2008-08-19 19:17:32
|
On Tue, 19 Aug 2008, Luis Silva wrote: > :) Ok sorry for this. The problem is that I sent this email first and got an > error and forgot to format the second time. I'm sending you the code in > attached. OK. I think you're correct that a type 4 NXDOMAIN could be cached incorrectly. Does the patch below look correct? Brian Index: org/xbill/DNS/Cache.java =================================================================== RCS file: /cvsroot/dnsjava/dnsjava/org/xbill/DNS/Cache.java,v retrieving revision 1.116 diff -u -r1.116 Cache.java --- org/xbill/DNS/Cache.java 5 Dec 2006 01:05:06 -0000 1.116 +++ org/xbill/DNS/Cache.java 19 Aug 2008 19:16:56 -0000 @@ -628,7 +628,8 @@ int type = answers[i].getType(); Name name = answers[i].getName(); cred = getCred(Section.ANSWER, isAuth); - if ((type == qtype || qtype == Type.ANY) && + if (rcode == Rcode.NOERROR && + (type == qtype || qtype == Type.ANY) && name.equals(curname)) { addRRset(answers[i], cred); @@ -679,14 +680,13 @@ } if (!completed) { /* This is a negative response or a referral. */ - int cachetype = (rcode == Rcode.NXDOMAIN) ? 0 : qtype; - if (soa != null || ns == null) { + if (rcode == Rcode.NXDOMAIN) { /* Negative response */ cred = getCred(Section.AUTHORITY, isAuth); SOARecord soarec = null; if (soa != null) soarec = (SOARecord) soa.first(); - addNegative(curname, cachetype, soarec, cred); + addNegative(curname, 0, soarec, cred); if (response == null) { int responseType; if (rcode == Rcode.NXDOMAIN) @@ -695,8 +695,8 @@ responseType = SetResponse.NXRRSET; response = SetResponse.ofType(responseType); } - /* NXT records are not cached yet. */ - } else { + /* DNSSEC records are not cached. */ + } else if (ns != null) { /* Referral response */ cred = getCred(Section.AUTHORITY, isAuth); addRRset(ns, cred); |