From: Aki Tuomi Date: Wed, 25 Jun 2014 22:33:23 +0000 (+0300) Subject: Add some sanity checks X-Git-Tag: auth-3.4.0-rc1~112^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fpull%2F1491%2Fhead;p=thirdparty%2Fpdns.git Add some sanity checks --- diff --git a/modules/remotebackend/httpconnector.cc b/modules/remotebackend/httpconnector.cc index 6731a16c5c..7986938acc 100644 --- a/modules/remotebackend/httpconnector.cc +++ b/modules/remotebackend/httpconnector.cc @@ -345,16 +345,22 @@ int HTTPConnector::recv_message(rapidjson::Document &output) { int rd; arl.initialize(&resp); + while(arl.ready() == false) { rd = d_socket->readWithTimeout(buffer, sizeof(buffer), timeout); - if (rd>0) - buffer[rd] = 0; + if (rd<0) { + delete d_socket; + d_socket = NULL; + return -1; + } + buffer[rd] = 0; arl.feed(std::string(buffer, rd)); } + arl.finalize(); if (resp.status < 200 || resp.status >= 400) { - // bad + // bad. return -1; }