From c4b4eeee2433c3b16ed9390d1b7487c2c98aaee3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Remko=20Tron=C3=A7on?= Date: Sun, 17 Jun 2012 10:09:45 +0200 Subject: Fixed potential uncaught exception in HTTPConnectProxiedConnection. diff --git a/Swiften/Network/HTTPConnectProxiedConnection.cpp b/Swiften/Network/HTTPConnectProxiedConnection.cpp index 7bd7e41..a88ded1 100644 --- a/Swiften/Network/HTTPConnectProxiedConnection.cpp +++ b/Swiften/Network/HTTPConnectProxiedConnection.cpp @@ -61,14 +61,24 @@ void HTTPConnectProxiedConnection::initializeProxy() { void HTTPConnectProxiedConnection::handleProxyInitializeData(boost::shared_ptr data) { SWIFT_LOG(debug) << byteArrayToString(ByteArray(data->begin(), data->end())) << std::endl; std::vector tmp = String::split(byteArrayToString(ByteArray(data->begin(), data->end())), ' '); - if(tmp.size() > 1) { - int status = boost::lexical_cast (tmp[1].c_str()); - SWIFT_LOG(debug) << "Proxy Status: " << status << std::endl; - if (status / 100 == 2) { // all 2XX states are OK - setProxyInitializeFinished(true); - return; + if (tmp.size() > 1) { + try { + int status = boost::lexical_cast(tmp[1]); + SWIFT_LOG(debug) << "Proxy Status: " << status << std::endl; + if (status / 100 == 2) { // all 2XX states are OK + setProxyInitializeFinished(true); + } + else { + SWIFT_LOG(debug) << "HTTP Proxy returned an error: " << byteArrayToString(ByteArray(data->begin(), data->end())) << std::endl; + setProxyInitializeFinished(false); + } } - SWIFT_LOG(debug) << "HTTP Proxy returned an error: " << byteArrayToString(ByteArray(data->begin(), data->end())) << std::endl; + catch (boost::bad_lexical_cast&) { + SWIFT_LOG(warning) << "Unexpected response: " << tmp[1] << std::endl; + setProxyInitializeFinished(false); + } + } + else { + setProxyInitializeFinished(false); } - setProxyInitializeFinished(false); } -- cgit v0.10.2-6-g49f6