[Pdns-dev] Re: Possible bug --> confirmed bug --> patch
Lorens Kockum
pdns-9874 at tagged.lorens.org
Wed Oct 13 01:18:06 CEST 2004
On Tue, Oct 05, 2004, Lorens Kockum wrote on pdns-users:
> So, some kind of bug in in the AXFR of NAPTR records.
> Reported as bug 23:
> http://ds9a.nl/cgi-bin/cvstrac/pdns/tktview?tn=23
A case was missing for parsing NAPTR in incoming packets.
I haven't coded C++ for almost four years, and I probably broke
some kind of coding style conventions, but it "works for me"(TM).
I'm sure Duane will be happy to proofread and test :-)
Lorens Kockum
(on time paid for by InitialesOnline SA (Paris),
copyright on code granted to PowerDNS BV, etc. etc.)
--
#include <std_disclaim.h> Lorens Kockum
-------------- next part --------------
diff -ru pdns-2.9.16/pdns/dnspacket.cc pdns-2.9.16fixbug23/pdns/dnspacket.cc
--- pdns-2.9.16/pdns/dnspacket.cc 2004-02-04 23:41:17.000000000 +0100
+++ pdns-2.9.16fixbug23/pdns/dnspacket.cc 2004-10-12 23:57:04.000000000 +0200
@@ -1283,7 +1283,7 @@
break;
- case QType::SRV: // rfc 2025
+ case QType::SRV: // rfc 2052
// priority goes into mx-priority
rr.priority=(datapos[0] << 8) + datapos[1];
// rest glue together
@@ -1294,6 +1294,50 @@
rr.content+=" "+itoa(port)+" "+part;
break;
+ case QType::NAPTR: // rfc 2915
+ {
+ const string quote="\"";
+ const string space=" ";
+
+ int order;
+ int pref;
+ string flags, services, regex, replacement, result;
+
+ order=(datapos[0] << 8) + datapos[1];
+
+ // "pref" should maybe be put into rr.priority, but that
+ // might have unintended side effects that I cannot
+ // evaluate at this time.
+ //
+ // Lorens Kockum 2004-10-12
+
+ pref=(datapos[2] << 8) + datapos[3];
+
+ // The following would be a good subject for a mini-
+ // function with boundary checking, which could be
+ // reused in a lot of places in this file (see FIXME
+ // at beginning of function).
+
+ offset = 4 ;
+ flags.assign((const char *)datapos+offset+1,(int)datapos[offset]);
+ offset+=flags.size()+1;
+ services.assign((const char *)datapos+offset+1,(int)datapos[offset]);
+ offset+=services.size()+1;
+ regex.assign((const char *)datapos+offset+1,(int)datapos[offset]);
+ offset+=regex.size()+1;
+
+ expand(datapos+offset,end,replacement);
+
+ if (!replacement.size()) replacement = "." ;
+
+ rr.content = itoa(order) \
+ + " " + itoa(pref) \
+ + " " + quote + flags + quote \
+ + " " + quote + services + quote \
+ + " " + quote + regex + quote \
+ + " " + replacement;
+ }
+ break;
case QType::RP:
offset+=expand(datapos+offset,end,rr.content);
More information about the Pdns-dev
mailing list