From 91049c8af8255fedea9e151490fa13b4a023b743 Mon Sep 17 00:00:00 2001 From: Neil Booth Date: Thu, 27 Aug 2015 15:09:00 +0900 Subject: [PATCH] Protect proxy against ill-formed server responses --- lib/network_proxy.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/network_proxy.py b/lib/network_proxy.py index eb666b7d4..d440ff99c 100644 --- a/lib/network_proxy.py +++ b/lib/network_proxy.py @@ -16,6 +16,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . +import sys +import traceback import threading import Queue @@ -73,7 +75,11 @@ class NetworkProxy(util.DaemonThread): continue if response is None: break - self.process(response) + # Protect against ill-formed or malicious server responses + try: + self.process(response) + except: + traceback.print_exc(file=sys.stderr) self.trigger_callback('stop') if self.network: self.network.stop()