// sleep until we see an answer to this, interface to mtasker
- ret=arecvfrom(const_cast<char *>(buf.data()), buf.size(), 0, ip, &len, qid,
+ ret=arecvfrom(buf, 0, ip, &len, qid,
domain, type, queryfd, now);
}
else {
// unexpected count has already been done @ pdns_recursor.cc
goto out;
}
-
+
+ lwr->d_records.reserve(mdp.d_answers.size());
for(const auto& a : mdp.d_answers)
lwr->d_records.push_back(a.first);
int asendto(const char *data, size_t len, int flags, const ComboAddress& ip, uint16_t id,
const DNSName& domain, uint16_t qtype, int* fd);
-int arecvfrom(char *data, size_t len, int flags, const ComboAddress& ip, size_t *d_len, uint16_t id,
+int arecvfrom(std::string& packet, int flags, const ComboAddress& ip, size_t *d_len, uint16_t id,
const DNSName& domain, uint16_t qtype, int fd, struct timeval* now);
class LWResException : public PDNSException
}
// -1 is error, 0 is timeout, 1 is success
-int arecvfrom(char *data, size_t len, int flags, const ComboAddress& fromaddr, size_t *d_len,
+int arecvfrom(std::string& packet, int flags, const ComboAddress& fromaddr, size_t *d_len,
uint16_t id, const DNSName& domain, uint16_t qtype, int fd, struct timeval* now)
{
static optional<unsigned int> nearMissLimit;
pident.type = qtype;
pident.remote=fromaddr;
- string packet;
int ret=MT->waitEvent(pident, &packet, g_networkTimeoutMsec, now);
if(ret > 0) {
return -1;
*d_len=packet.size();
- memcpy(data,packet.c_str(),min(len,*d_len));
+
if(*nearMissLimit && pident.nearMisses > *nearMissLimit) {
g_log<<Logger::Error<<"Too many ("<<pident.nearMisses<<" > "<<*nearMissLimit<<") bogus answers for '"<<domain<<"' from "<<fromaddr.toString()<<", assuming spoof attempt."<<endl;
g_stats.spoofCount++;
DNSRecord dr=*j;
dr.d_ttl-=d_now.tv_sec;
+ ret.reserve(ret.size() + 1 + signatures.size() + authorityRecs.size());
ret.push_back(dr);
for(const auto& signature : signatures) {
}
}
+ ret.reserve(ret.size() + signatures.size() + authorityRecs.size());
+
for(const auto& signature : signatures) {
DNSRecord dr;
dr.d_type=QType::RRSIG;