From 352df81e4a15154d6008468a53d2e770326a0253 Mon Sep 17 00:00:00 2001 From: Pieter Lexis Date: Wed, 21 Feb 2018 12:58:06 +0100 Subject: [PATCH] ixfrdist: Read only the amount of bytes we need spotted by @rgacogne --- pdns/ixfrdist.cc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) 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; -- 2.40.0