From: bert hubert Date: Sun, 6 Mar 2016 09:59:23 +0000 (+0100) Subject: make sure our recursor cache is blind for edns subnet - THIS CODE NEEDS TO BE IMPROVE... X-Git-Tag: rec-4.0.0-alpha2~3^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b3cb172a1128e1bece62e1067caf29d71fcf55cd;p=thirdparty%2Fpdns.git make sure our recursor cache is blind for edns subnet - THIS CODE NEEDS TO BE IMPROVED @rgacogne --- diff --git a/pdns/recpacketcache.cc b/pdns/recpacketcache.cc index 73756cd8e1..bd03e2a534 100644 --- a/pdns/recpacketcache.cc +++ b/pdns/recpacketcache.cc @@ -62,7 +62,29 @@ uint32_t RecursorPacketCache::canHashPacket(const std::string& origPacket) for(; p < end && *p; ++p) { // XXX if you embed a 0 in your qname we'll stop lowercasing there const char l = dns_tolower(*p); // label lengths can safely be lower cased ret=burtle((const unsigned char*)&l, 1, ret); + } // XXX the embedded 0 in the qname will break the subnet stripping + + // this code will only function properly with *1* EDNS option + struct dnsheader* dh = (struct dnsheader*)origPacket.c_str(); + if(ntohs(dh->arcount)==1 && p+12 < end) { + const unsigned char *q = (const unsigned char*) p; + q+=5; + unsigned int optlen=(0x100*q[9] + q[10]); + /* + cout<<"Option length: "<< optlen < p) { + /* + cout<<"Had "<<(end-p)<<" bytes left to hash, removing "<