Permalink
Browse files

rec: Treat requestor's payload size lower than 512 as equal to 512

(cherry picked from commit 3201574)
  • Loading branch information...
rgacogne committed Jun 22, 2017
1 parent ff2a5c0 commit a5c9534d02f9ccd84787bcdd253c5b817f92d797
Showing with 8 additions and 4 deletions.
  1. +8 −4 pdns/pdns_recursor.cc
View
@@ -694,12 +694,16 @@ void startDoResolve(void *p)
if (t_queryring)
t_queryring->push_back(make_pair(dc->d_mdp.d_qname, dc->d_mdp.d_qtype));
uint32_t maxanswersize= dc->d_tcp ? 65535 : min((uint16_t) 512, g_udpTruncationThreshold);
uint16_t maxanswersize = dc->d_tcp ? 65535 : min(static_cast<uint16_t>(512), g_udpTruncationThreshold);
EDNSOpts edo;
bool haveEDNS=false;
if(getEDNSOpts(dc->d_mdp, &edo)) {
if(!dc->d_tcp)
maxanswersize = min(edo.d_packetsize, g_udpTruncationThreshold);
if(!dc->d_tcp) {
/* rfc6891 6.2.3:
"Values lower than 512 MUST be treated as equal to 512."
*/
maxanswersize = min(static_cast<uint16_t>(edo.d_packetsize >= 512 ? edo.d_packetsize : 512), g_udpTruncationThreshold);
}
dc->d_ednsOpts = edo.d_options;
haveEDNS=true;
@@ -1086,7 +1090,7 @@ void startDoResolve(void *p)
if(i->d_type != QType::OPT) // their TTL ain't real
minTTL = min(minTTL, i->d_ttl);
i->d_content->toPacket(pw);
if(pw.size() > maxanswersize) {
if(pw.size() > static_cast<size_t>(maxanswersize)) {
pw.rollback();
if(i->d_place==DNSResourceRecord::ANSWER) // only truncate if we actually omitted parts of the answer
{

0 comments on commit a5c9534

Please sign in to comment.