]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Add some sanity checks 1491/head
authorAki Tuomi <cmouse@desteem.org>
Wed, 25 Jun 2014 22:33:23 +0000 (01:33 +0300)
committerAki Tuomi <cmouse@desteem.org>
Wed, 25 Jun 2014 22:33:23 +0000 (01:33 +0300)
modules/remotebackend/httpconnector.cc

index 6731a16c5cd461dcf212d62fe824a990e2e19512..7986938acc2c3c0c17796411159432c7325ea410 100644 (file)
@@ -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;
     }