From a9ee78b75032c304ff57208cdf26201c2fbd5d96 Mon Sep 17 00:00:00 2001 From: Aki Tuomi Date: Thu, 26 Jun 2014 01:33:23 +0300 Subject: [PATCH] Add some sanity checks --- modules/remotebackend/httpconnector.cc | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) 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; } -- 2.47.2