From abd5ca5d4960765f25da426c3dd20e2316d75b59 Mon Sep 17 00:00:00 2001
From: Edwin Mons <edwin.mons@isode.com>
Date: Fri, 28 Sep 2018 16:17:55 +0200
Subject: Catch numeric cast errors in BoostConnectionServer

When BoostConnectionServer tries to set up a listener, it casts an int
to an unsigned short, which may throw an uncaught exception if the cast
fails.

Test-Information:

Unit tests pass on Debian 9
Test server code no longer crashes when it tries to set up a listener on
an invalid port.

Change-Id: If6b920e54481ce6bf174df01d14ad12eff90e3f4

diff --git a/Swiften/Network/BoostConnectionServer.cpp b/Swiften/Network/BoostConnectionServer.cpp
index 34b5799..f25f915 100644
--- a/Swiften/Network/BoostConnectionServer.cpp
+++ b/Swiften/Network/BoostConnectionServer.cpp
@@ -58,6 +58,9 @@ boost::optional<BoostConnectionServer::Error> BoostConnectionServer::tryStart()
             return UnknownError;
         }
     }
+    catch (const boost::numeric::bad_numeric_cast&) {
+        return UnknownError;
+    }
     return boost::optional<Error>();
 }
 
-- 
cgit v0.10.2-6-g49f6