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

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

fixeria gerrit-no-reply at lists.osmocom.org
Thu Aug 29 13:27:08 UTC 2019


fixeria has uploaded this change for review. ( 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(-)



  git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/32/15332/1

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-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190829/53073692/attachment.htm>


More information about the gerrit-log mailing list