diff options
Diffstat (limited to 'Swiften/Parser/PayloadParsers/S5BProxyRequestParser.cpp')
| -rw-r--r-- | Swiften/Parser/PayloadParsers/S5BProxyRequestParser.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/Swiften/Parser/PayloadParsers/S5BProxyRequestParser.cpp b/Swiften/Parser/PayloadParsers/S5BProxyRequestParser.cpp index 502f400..7a5a1fd 100644 --- a/Swiften/Parser/PayloadParsers/S5BProxyRequestParser.cpp +++ b/Swiften/Parser/PayloadParsers/S5BProxyRequestParser.cpp | |||
| @@ -5,7 +5,7 @@ | |||
| 5 | */ | 5 | */ |
| 6 | 6 | ||
| 7 | /* | 7 | /* |
| 8 | * Copyright (c) 2015-2016 Isode Limited. | 8 | * Copyright (c) 2015-2018 Isode Limited. |
| 9 | * All rights reserved. | 9 | * All rights reserved. |
| 10 | * See the COPYING file for more information. | 10 | * See the COPYING file for more information. |
| 11 | */ | 11 | */ |
| @@ -13,6 +13,7 @@ | |||
| 13 | #include <Swiften/Parser/PayloadParsers/S5BProxyRequestParser.h> | 13 | #include <Swiften/Parser/PayloadParsers/S5BProxyRequestParser.h> |
| 14 | 14 | ||
| 15 | #include <boost/lexical_cast.hpp> | 15 | #include <boost/lexical_cast.hpp> |
| 16 | #include <boost/numeric/conversion/cast.hpp> | ||
| 16 | #include <boost/optional.hpp> | 17 | #include <boost/optional.hpp> |
| 17 | 18 | ||
| 18 | namespace Swift { | 19 | namespace Swift { |
| @@ -27,15 +28,14 @@ void S5BProxyRequestParser::handleStartElement(const std::string& element, const | |||
| 27 | if (element == "streamhost") { | 28 | if (element == "streamhost") { |
| 28 | if (attributes.getAttributeValue("host") && attributes.getAttributeValue("jid") && attributes.getAttributeValue("port")) { | 29 | if (attributes.getAttributeValue("host") && attributes.getAttributeValue("jid") && attributes.getAttributeValue("port")) { |
| 29 | std::string host = attributes.getAttributeValue("host").get_value_or(""); | 30 | std::string host = attributes.getAttributeValue("host").get_value_or(""); |
| 30 | int port = -1; | 31 | unsigned short port = 0; |
| 31 | JID jid = attributes.getAttributeValue("jid").get_value_or(""); | 32 | JID jid = attributes.getAttributeValue("jid").get_value_or(""); |
| 32 | 33 | ||
| 33 | try { | 34 | try { |
| 34 | port = boost::lexical_cast<int>(attributes.getAttributeValue("port").get()); | 35 | port = boost::numeric_cast<unsigned short>(boost::lexical_cast<int>(attributes.getAttributeValue("port").get())); |
| 35 | } catch (boost::bad_lexical_cast &) { | 36 | } catch (...) { |
| 36 | port = -1; | ||
| 37 | } | 37 | } |
| 38 | if (!host.empty() && port != -1 && jid.isValid()) { | 38 | if (!host.empty() && port != 0 && jid.isValid()) { |
| 39 | S5BProxyRequest::StreamHost streamHost; | 39 | S5BProxyRequest::StreamHost streamHost; |
| 40 | streamHost.host = host; | 40 | streamHost.host = host; |
| 41 | streamHost.port = port; | 41 | streamHost.port = port; |
Swift