validate:launcher: Handle validate report bigger than allowed by the socket

This almost never happens but I had a case where we had a report
with a GstSample in the caps that were reported leading to an
error printed.
This commit is contained in:
Thibault Saunier 2020-02-11 09:18:23 -03:00 committed by Thibault Saunier
parent d17c2ff65c
commit 2f135d430b

View file

@ -708,18 +708,25 @@ class GstValidateListener(socketserver.BaseRequestHandler, Loggable):
if raw_len == b'': if raw_len == b'':
return return
msglen = struct.unpack('>I', raw_len)[0] msglen = struct.unpack('>I', raw_len)[0]
try: e = None
msg = self.request.recv(msglen).decode('utf-8', 'ignore') raw_msg = bytes()
except UnicodeDecodeError as e: while msglen != len(raw_msg):
self.error("Could not decode message: %s - %s" % (msg, e)) raw_msg += self.request.recv(msglen - len(raw_msg))
if e is not None:
continue continue
try:
msg = raw_msg.decode('utf-8', 'ignore')
except UnicodeDecodeError as e:
self.error("%s Could not decode message: %s - %s" % (test.classname if test else "unknown", msg, e))
continue
if msg == '': if msg == '':
return return
try: try:
obj = json.loads(msg) obj = json.loads(msg)
except json.decoder.JSONDecodeError as e: except json.decoder.JSONDecodeError as e:
self.error("Could not deserialize: %s - %s" % (msg, e)) self.error("%s Could not decode message: %s - %s" % (test.classname if test else "unknown", msg, e))
continue continue
if test is None: if test is None: