From: Aki Tuomi Date: Thu, 15 Jan 2015 06:40:24 +0000 (+0200) Subject: Properly handle read errors (EOF and errors) X-Git-Tag: rec-3.7.0-rc1~22^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=974427fd0afc3bf858f7b0a38f626bc3fd17ae61;p=thirdparty%2Fpdns.git Properly handle read errors (EOF and errors) --- diff --git a/modules/remotebackend/httpconnector.cc b/modules/remotebackend/httpconnector.cc index efef0123b7..b74d105a9d 100644 --- a/modules/remotebackend/httpconnector.cc +++ b/modules/remotebackend/httpconnector.cc @@ -389,7 +389,11 @@ int HTTPConnector::recv_message(rapidjson::Document &output) { try { t0 = time((time_t*)NULL); while(arl.ready() == false && (labs(time((time_t*)NULL) - t0) <= timeout/1000)) { - rd = d_socket->readWithTimeout(buffer, sizeof(buffer), timeout); // if rd<=0 this will throw + rd = d_socket->readWithTimeout(buffer, sizeof(buffer), timeout); + if (rd==0) + throw NetworkError("EOF while reading"); + if (rd<0) + throw NetworkError(std::string(strerror(rd))); buffer[rd] = 0; arl.feed(std::string(buffer, rd)); }