]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
dnsdsit: reset IncomingTCPConnectionState's buffer with clear() instead of resize() 13146/head
authorCharles-Henri Bruyand <charles-henri.bruyand@open-xchange.com>
Wed, 16 Aug 2023 15:20:21 +0000 (17:20 +0200)
committerCharles-Henri Bruyand <charles-henri.bruyand@open-xchange.com>
Wed, 16 Aug 2023 16:18:26 +0000 (18:18 +0200)
pdns/dnsdist-tcp.cc

index 7b99f6be7d1e103f60215eac20bc51372dd09ba5..2a1d7b80eebbb06c4fbf5551cc78d341b20a2457 100644 (file)
@@ -252,7 +252,7 @@ bool IncomingTCPConnectionState::canAcceptNewQueries(const struct timeval& now)
 
 void IncomingTCPConnectionState::resetForNewQuery()
 {
-  d_buffer.resize(sizeof(uint16_t));
+  d_buffer.clear();
   d_currentPos = 0;
   d_querySize = 0;
   d_state = State::waitingForQuery;
@@ -875,6 +875,7 @@ void IncomingTCPConnectionState::handleIO(std::shared_ptr<IncomingTCPConnectionS
       if (!state->d_lastIOBlocked && (state->d_state == IncomingTCPConnectionState::State::waitingForQuery ||
                                       state->d_state == IncomingTCPConnectionState::State::readingQuerySize)) {
         DEBUGLOG("reading query size");
+        state->d_buffer.resize(sizeof(uint16_t));
         iostate = state->d_handler.tryRead(state->d_buffer, state->d_currentPos, sizeof(uint16_t));
         if (state->d_currentPos > 0) {
           /* if we got at least one byte, we can't go around sending responses */