From: Bert Hubert Date: Thu, 13 May 2010 17:16:47 +0000 (+0000) Subject: fix up NSEC3 rendering/generation/parsing X-Git-Tag: rec-3.3~88 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8b606f6e44223fb3892587cb4c3e2317e614b862;p=pdns fix up NSEC3 rendering/generation/parsing git-svn-id: svn://svn.powerdns.com/pdns/trunk/pdns@1614 d19b8d6e-7fed-0310-83ef-9ca221ded41b --- diff --git a/pdns/nsecrecords.cc b/pdns/nsecrecords.cc index 98b9d874d..5a0681563 100644 --- a/pdns/nsecrecords.cc +++ b/pdns/nsecrecords.cc @@ -108,8 +108,8 @@ NSEC3RecordContent::NSEC3RecordContent(const string& content, const string& zone rtr.xfr16BitInt(d_iterations); rtr.xfrHexBlob(d_salt); - rtr.xfrHexBlob(d_nexthash); - + rtr.xfrBase32HexBlob(d_nexthash); + while(!rtr.eof()) { uint16_t type; rtr.xfrType(type); @@ -127,7 +127,7 @@ void NSEC3RecordContent::toPacket(DNSPacketWriter& pw) pw.xfr8BitInt(d_nexthash.length()); pw.xfrBlob(d_nexthash); - + uint8_t res[34]; memset(res, 0, sizeof(res)); @@ -157,8 +157,9 @@ NSEC3RecordContent::DNSRecordContent* NSEC3RecordContent::make(const DNSRecord & pr.xfrBlob(ret->d_salt, len); pr.xfr8BitInt(len); + pr.xfrBlob(ret->d_nexthash, len); - + string bitmap; pr.xfrBlob(bitmap); @@ -171,11 +172,11 @@ NSEC3RecordContent::DNSRecordContent* NSEC3RecordContent::make(const DNSRecord & throw MOADNSException("NSEC3 record with impossibly small bitmap"); if(bitmap[0]) - throw MOADNSException("Can't deal with NSEC mappings > 255 yet"); + throw MOADNSException("Can't deal with NSEC3 mappings > 255 yet"); unsigned int bitmaplen=bitmap[1]; if(bitmap.size()!=2+bitmaplen) - throw MOADNSException("Can't deal with multi-part NSEC mappings yet"); + throw MOADNSException("Can't deal with multi-part NSEC3 mappings yet"); for(unsigned int n=0 ; n < bitmaplen ; ++n) { uint8_t val=bitmap[2+n]; @@ -198,7 +199,6 @@ string NSEC3RecordContent::getZoneRepresentation() const rtw.xfrHexBlob(d_salt); rtw.xfrBase32HexBlob(d_nexthash); - for(set::const_iterator i=d_set.begin(); i!=d_set.end(); ++i) { ret+=" "; ret+=NumberToType(*i); @@ -222,8 +222,8 @@ NSEC3PARAMRecordContent::NSEC3PARAMRecordContent(const string& content, const st { RecordTextReader rtr(content, zone); rtr.xfr8BitInt(d_algorithm); - rtr.xfr8BitInt(d_flags); - rtr.xfr16BitInt(d_iterations); + rtr.xfr8BitInt(d_flags); + rtr.xfr16BitInt(d_iterations); rtr.xfrHexBlob(d_salt); } diff --git a/pdns/rcpgenerator.cc b/pdns/rcpgenerator.cc index 54bc3d931..6485c5e80 100644 --- a/pdns/rcpgenerator.cc +++ b/pdns/rcpgenerator.cc @@ -245,6 +245,17 @@ void RecordTextReader::xfrHexBlob(string& val) HEXDecode(d_string.c_str()+pos, d_string.c_str() + d_pos, val); } +void RecordTextReader::xfrBase32HexBlob(string& val) +{ + skipSpaces(); + int pos=(int)d_pos; + while(d_pos < d_end && !dns_isspace(d_string[d_pos])) + d_pos++; + + val=fromBase32Hex(string(d_string.c_str()+pos, d_pos-pos)); +} + + void RecordTextWriter::xfrBase32HexBlob(const string& val) { if(!d_string.empty()) diff --git a/pdns/rcpgenerator.hh b/pdns/rcpgenerator.hh index 151a83da2..2dc9bedc6 100644 --- a/pdns/rcpgenerator.hh +++ b/pdns/rcpgenerator.hh @@ -54,7 +54,7 @@ public: void xfrLabel(string& val, bool compress=false); void xfrText(string& val, bool multi=false); void xfrHexBlob(string& val); - + void xfrBase32HexBlob(string& val); void xfrBlob(string& val, int len=-1);