]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Properly handle read errors (EOF and errors)
authorAki Tuomi <cmouse@desteem.org>
Thu, 15 Jan 2015 06:40:24 +0000 (08:40 +0200)
committerRuben Kerkhof <ruben@rubenkerkhof.com>
Tue, 20 Jan 2015 20:26:48 +0000 (21:26 +0100)
(cherry picked from commit 974427fd0afc3bf858f7b0a38f626bc3fd17ae61)

modules/remotebackend/httpconnector.cc

index efef0123b7a41a331c3904e94568255e430e743b..b74d105a9d92f56163a541a5e5ab5801078f6756 100644 (file)
@@ -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));
       }