From 3fb48318049ef945cd725ebd4f4827bd5a9ec350 Mon Sep 17 00:00:00 2001 From: Jack Date: Wed, 10 Aug 2016 02:30:41 -0400 Subject: [PATCH] raise exception when curr_pos > 100 and json fails to decode --- lbrynet/reflector/server/server.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/lbrynet/reflector/server/server.py b/lbrynet/reflector/server/server.py index c1098dc40..d2569b6aa 100644 --- a/lbrynet/reflector/server/server.py +++ b/lbrynet/reflector/server/server.py @@ -45,23 +45,22 @@ class ReflectorServer(Protocol): extra_data = None response = None curr_pos = 0 - size_of_message = len(response_msg) while 1: next_close_paren = response_msg.find('}', curr_pos) if next_close_paren != -1: curr_pos = next_close_paren + 1 try: response = json.loads(response_msg[:curr_pos]) - failed_to_decode = False except ValueError: - failed_to_decode = True + if curr_pos > 100: + raise Exception("error decoding response") + else: + pass else: extra_data = response_msg[curr_pos:] break else: break - if size_of_message > 100 and failed_to_decode: - raise Exception("error decoding response") return response, extra_data def handle_request(self, request_dict):