From: Remi Gacogne Date: Fri, 11 Dec 2015 10:10:43 +0000 (+0100) Subject: Fix dnsdist console client sending empty lines X-Git-Tag: dnsdist-1.0.0-alpha1~78^2^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0877da986ffab36b3ba6908a6ab0ad09689b9788;p=pdns Fix dnsdist console client sending empty lines There is no point for the console client to send empty lines to the server. Just in case, fix the server to not abort the connection when receiving such empty lines. Reported by @gryphius as a follow-up on #3015. --- diff --git a/pdns/dnsdist-console.cc b/pdns/dnsdist-console.cc index 41d17b246..48151caa7 100644 --- a/pdns/dnsdist-console.cc +++ b/pdns/dnsdist-console.cc @@ -60,6 +60,10 @@ void doClient(ComboAddress server, const std::string& command) if(line=="quit") break; + /* no need to send an empty line to the server */ + if(line.empty()) + continue; + string response; string msg=sodEncryptSym(line, g_key, ours); putMsgLen32(fd, msg.length()); @@ -207,6 +211,14 @@ try uint32_t len; if(!getMsgLen32(fd, &len)) break; + + if (len == 0) { + /* just ACK an empty message + with an empty response */ + putMsgLen32(fd, 0); + continue; + } + boost::scoped_array msg(new char[len]); readn2(fd, msg.get(), len);