From: Remi Gacogne Date: Tue, 15 Sep 2020 14:33:07 +0000 (+0200) Subject: dnsdist: Only copy what we need from the response buffer X-Git-Tag: auth-4.5.0-alpha0~14^2~10 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=1d705e71ba0c2fcc91d09d60c4d8509b38ccad7f;p=thirdparty%2Fpdns.git dnsdist: Only copy what we need from the response buffer --- diff --git a/pdns/dnsdist-tcp.cc b/pdns/dnsdist-tcp.cc index e3e8d88ce3..f1383a0d09 100644 --- a/pdns/dnsdist-tcp.cc +++ b/pdns/dnsdist-tcp.cc @@ -323,7 +323,6 @@ static IOState handleResponseSent(std::shared_ptr& s } } - bool IncomingTCPConnectionState::canAcceptNewQueries() const { if (d_isXFR) { @@ -573,10 +572,13 @@ static bool handleQuery(std::shared_ptr& state, cons /* prepend the size. Yes, this is not the most efficient way but it prevents mistakes that could occur if we had to deal with the size during the processing, especially alignment issues */ + /* first we need to resize to the size that is actually used, since we allocated more to be able to insert + EDNS or Proxy Protocol values */ + dq.size = state->d_buffer.size(); + state->d_buffer.resize(dq.len); state->d_buffer.insert(state->d_buffer.begin(), sizeBytes, sizeBytes + 2); dq.len = dq.len + 2; dq.dh = reinterpret_cast(&state->d_buffer.at(0)); - dq.size = state->d_buffer.size(); state->d_buffer.resize(dq.len); bool proxyProtocolPayloadAdded = false;