From: Pieter Lexis Date: Wed, 21 Feb 2018 11:58:06 +0000 (+0100) Subject: ixfrdist: Read only the amount of bytes we need X-Git-Tag: dnsdist-1.3.0~82^2~1 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=352df81e4a15154d6008468a53d2e770326a0253;p=pdns ixfrdist: Read only the amount of bytes we need spotted by @rgacogne --- diff --git a/pdns/ixfrdist.cc b/pdns/ixfrdist.cc index f2f615112..c6337553e 100644 --- a/pdns/ixfrdist.cc +++ b/pdns/ixfrdist.cc @@ -23,6 +23,7 @@ #include "config.h" #endif #include +#include #include #include #include @@ -619,8 +620,7 @@ void handleTCPRequest(int fd, boost::any&) { return; } - char buf[4096]; - // Discard the first 2 bytes (qlen) + char buf[65535]; int res; res = recv(cfd, &buf, 2, 0); if (res != 2) { @@ -636,7 +636,8 @@ void handleTCPRequest(int fd, boost::any&) { } } - res = recv(cfd, &buf, sizeof(buf), 0); + size_t toRead = std::min(static_cast(ntohs((buf[0]<<8) + buf[1])), sizeof(buf)); + res = recv(cfd, &buf, toRead, 0); if (res == -1) { auto savedErrno = errno;