From: Remi Gacogne Date: Fri, 18 Mar 2016 09:55:38 +0000 (+0100) Subject: dnsdist: Prevent EOF error for empty console response w/o sodium X-Git-Tag: dnsdist-1.0.0-beta1~84^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e4ef64beea862790bf81f8554cc23aded72e758e;p=pdns dnsdist: Prevent EOF error for empty console response w/o sodium Prevent the "Fatal error: EOF while reading message" error when the server send an empty response to a single console command. It was caused by calling `readn2()` for a 0-sized read. When libsodium support is enabled, padding prevents 0-sized responses anyway. --- diff --git a/pdns/dnsdist-console.cc b/pdns/dnsdist-console.cc index 8e9dc5914..f9fafc60f 100644 --- a/pdns/dnsdist-console.cc +++ b/pdns/dnsdist-console.cc @@ -33,18 +33,23 @@ void doClient(ComboAddress server, const std::string& command) readn2(fd, (char*)theirs.value, sizeof(theirs.value)); if(!command.empty()) { - string response; string msg=sodEncryptSym(command, g_key, ours); putMsgLen32(fd, msg.length()); if(!msg.empty()) writen2(fd, msg); uint32_t len; - getMsgLen32(fd, &len); - boost::scoped_array resp(new char[len]); - readn2(fd, resp.get(), len); - msg.assign(resp.get(), len); - msg=sodDecryptSym(msg, g_key, theirs); - cout< 0) { + boost::scoped_array resp(new char[len]); + readn2(fd, resp.get(), len); + msg.assign(resp.get(), len); + msg=sodDecryptSym(msg, g_key, theirs); + cout<