return 0;
}
+bool validDNSName(const DNSName &name)
+{
+ string::size_type pos, length;
+ char c;
+ for(const auto& s : name.getRawLabels()) {
+ length=s.length();
+ for(pos=0; pos < length; ++pos) {
+ c=s[pos];
+ if(!((c >= 'a' && c <= 'z') ||
+ (c >= 'A' && c <= 'Z') ||
+ (c >= '0' && c <= '9') ||
+ c =='-' || c == '_' || c=='*' || c=='.' || c=='/' || c=='@' || c==' ' || c=='\\' || c==':'))
+ return false;
+ }
+ }
+ return true;
+}
+
DNSPacket *PacketHandler::question(DNSPacket *p)
{
DNSPacket *ret;
// XXX FIXME do this in DNSPacket::parse ?
- // if(!validDNSName(p->qdomain)) {
- // if(d_logDNSDetails)
- // L<<Logger::Error<<"Received a malformed qdomain from "<<p->getRemote()<<", '"<<p->qdomain<<"': sending servfail"<<endl;
- // S.inc("corrupt-packets");
- // S.ringAccount("remotes-corrupt", p->d_remote);
- // S.inc("servfail-packets");
- // r->setRcode(RCode::ServFail);
- // return r;
- // }
+ if(!validDNSName(p->qdomain)) {
+ if(d_logDNSDetails)
+ L<<Logger::Error<<"Received a malformed qdomain from "<<p->getRemote()<<", '"<<p->qdomain<<"': sending servfail"<<endl;
+ S.inc("corrupt-packets");
+ S.ringAccount("remotes-corrupt", p->d_remote);
+ S.inc("servfail-packets");
+ r->setRcode(RCode::ServFail);
+ return r;
+ }
if(p->d.opcode) { // non-zero opcode (again thanks RA!)
if(p->d.opcode==Opcode::Update) {
S.inc("dnsupdate-queries");