From 411a7bb8029e2d67b5795a70675516174136dbe9 Mon Sep 17 00:00:00 2001 From: matejcik Date: Mon, 19 Apr 2021 16:53:30 +0200 Subject: [PATCH] fix(core/wire): handle codec errors better --- core/src/trezor/wire/__init__.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/core/src/trezor/wire/__init__.py b/core/src/trezor/wire/__init__.py index e06a41bcb7..b1e56e1a14 100644 --- a/core/src/trezor/wire/__init__.py +++ b/core/src/trezor/wire/__init__.py @@ -406,7 +406,14 @@ async def handle_session( if next_msg is None: # If the previous run did not keep an unprocessed message for us, # wait for a new one coming from the wire. - msg = await ctx.read_from_wire() + try: + msg = await ctx.read_from_wire() + except codec_v1.CodecError as exc: + if __debug__: + log.exception(__name__, exc) + await ctx.write(failure(exc)) + continue + else: # Process the message from previous run. msg = next_msg