Change in ...osmocom-bb[master]: trx_toolkit/data_msg.py: fix: make sure header version is known

fixeria gerrit-no-reply at lists.osmocom.org
Thu Aug 29 19:36:51 UTC 2019


fixeria has submitted this change and it was merged. ( https://gerrit.osmocom.org/c/osmocom-bb/+/15332 )

Change subject: trx_toolkit/data_msg.py: fix: make sure header version is known
......................................................................

trx_toolkit/data_msg.py: fix: make sure header version is known

Before using DATA_MSG.HDR_LEN, we need to make sure that a parsed
header version is known and supported. Otherwise we will get an
IndexError exception.

Change-Id: Ie1887aa8709da1a2a287aa58a7873e72c0b4ed33
---
M src/target/trx_toolkit/data_msg.py
1 file changed, 5 insertions(+), 3 deletions(-)

Approvals:
  Jenkins Builder: Verified
  pespin: Looks good to me, approved



diff --git a/src/target/trx_toolkit/data_msg.py b/src/target/trx_toolkit/data_msg.py
index c5d284d..a1c41c0 100644
--- a/src/target/trx_toolkit/data_msg.py
+++ b/src/target/trx_toolkit/data_msg.py
@@ -279,11 +279,13 @@
 		if len(msg) < self.CHDR_LEN:
 			raise ValueError("Message is to short: missing common header")
 
-		# Parse version and TDMA TN
+		# Parse the header version first
 		self.ver = (msg[0] >> 4)
-		self.tn = (msg[0] & 0x07)
+		if not self.ver in self.known_versions:
+			raise ValueError("Unknown TRXD header version %d" % self.ver)
 
-		# Parse TDMA FN
+		# Parse TDMA TN and FN
+		self.tn = (msg[0] & 0x07)
 		self.fn = struct.unpack(">L", msg[1:5])[0]
 
 		# Make sure we have the whole header,

-- 
To view, visit https://gerrit.osmocom.org/c/osmocom-bb/+/15332
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmocom-bb
Gerrit-Branch: master
Gerrit-Change-Id: Ie1887aa8709da1a2a287aa58a7873e72c0b4ed33
Gerrit-Change-Number: 15332
Gerrit-PatchSet: 1
Gerrit-Owner: fixeria <axilirator at gmail.com>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <axilirator at gmail.com>
Gerrit-Reviewer: pespin <pespin at sysmocom.de>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190829/e12f2bc9/attachment.html>


More information about the gerrit-log mailing list