From f967a8d87a6c31a037fba7adaf4819ebdb63f04c Mon Sep 17 00:00:00 2001 From: Jakob Ketterl Date: Fri, 22 Oct 2021 15:07:42 +0200 Subject: [PATCH] catch exceptions while parsing ax25 frames --- owrx/aprs/__init__.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/owrx/aprs/__init__.py b/owrx/aprs/__init__.py index 8001b72..27c2608 100644 --- a/owrx/aprs/__init__.py +++ b/owrx/aprs/__init__.py @@ -56,12 +56,15 @@ class Ax25Parser(PickleModule): for i in range(0, len(l), n): yield l[i:i + n] - return { - "destination": self.extractCallsign(ax25frame[0:7]), - "source": self.extractCallsign(ax25frame[7:14]), - "path": [self.extractCallsign(c) for c in chunks(ax25frame[14:control_pid], 7)], - "data": ax25frame[control_pid + 2 :], - } + try: + return { + "destination": self.extractCallsign(ax25frame[0:7]), + "source": self.extractCallsign(ax25frame[7:14]), + "path": [self.extractCallsign(c) for c in chunks(ax25frame[14:control_pid], 7)], + "data": ax25frame[control_pid + 2 :], + } + except (ValueError, IndexError): + logger.exception("error parsing ax25 frame") def extractCallsign(self, input): cs = bytes([b >> 1 for b in input[0:6]]).decode(encoding, "replace").strip()