record.ttl = (input[pos] << 24) | (input[pos + 1] << 16) | (input[pos + 2] << 8) | input[pos + 3];
pos += 4;
- //record.rdlength = input[pos] << 8 | input[pos + 1];
+ uint16_t rdlength = input[pos] << 8 | input[pos + 1];
pos += 2;
switch (record.type)
break;
}
+ case QUERY_TXT:
+ {
+ if (pos + rdlength > input_size)
+ throw Exception("Unable to unpack txt resource record");
+
+ record.rdata = std::string(reinterpret_cast<const char *>(input + pos), rdlength);
+ pos += rdlength;
+
+ if (record.rdata.find_first_of("\r\n\0", 0, 3) != std::string::npos)
+ throw Exception("Invalid character in txt record");
+
+ break;
+ }
default:
break;
}
}
}
- void Process(DNS::Request* req)
+ void Process(DNS::Request* req) CXX11_OVERRIDE
{
if ((unloading) || (req->creator->dying))
throw Exception("Module is being unloaded");
// Update name in the original request so question checking works for PTR queries
req->question.name = p.question.name;
- if (SocketEngine::SendTo(this, buffer, len, 0, &this->myserver.sa, this->myserver.sa_size()) != len)
+ if (SocketEngine::SendTo(this, buffer, len, 0, this->myserver) != len)
throw Exception("DNS: Unable to send query");
// Add timer for timeout
ServerInstance->Timers.AddTimer(req);
}
- void RemoveRequest(DNS::Request* req)
+ void RemoveRequest(DNS::Request* req) CXX11_OVERRIDE
{
if (requests[req->id] == req)
requests[req->id] = NULL;
}
- std::string GetErrorStr(Error e)
+ std::string GetErrorStr(Error e) CXX11_OVERRIDE
{
switch (e)
{
delete request;
}
- bool Tick(time_t now)
+ bool Tick(time_t now) CXX11_OVERRIDE
{
ServerInstance->Logs->Log(MODNAME, LOG_DEBUG, "cache: purging DNS cache");
ConfigTag* tag = ServerInstance->Config->ConfValue("dns");
DNSServer = tag->getString("server");
SourceIP = tag->getString("sourceip");
- SourcePort = tag->getInt("sourceport", 0, 0, 65535);
+ SourcePort = tag->getUInt("sourceport", 0, 0, UINT16_MAX);
if (DNSServer.empty())
FindDNSServer();
this->manager.Rehash(DNSServer, SourceIP, SourcePort);
}
- void OnUnloadModule(Module* mod)
+ void OnUnloadModule(Module* mod) CXX11_OVERRIDE
{
for (unsigned int i = 0; i <= MAX_REQUEST_ID; ++i)
{
}
}
- Version GetVersion()
+ Version GetVersion() CXX11_OVERRIDE
{
return Version("DNS support", VF_CORE|VF_VENDOR);
}