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.orgfixeria has submitted this change and it was merged. ( https://gerrit.osmocom.org/c/osmocom-bb/+/15331 )
Change subject: trx_toolkit/data_msg.py: fix message length check in parse_msg()
......................................................................
trx_toolkit/data_msg.py: fix message length check in parse_msg()
Unlike DATA_MSG.HDR_LEN, the CHDR_LEN is a constant that defines
length of the common header, which is mandatory for every version.
DATA_MSG.HDR_LEN in its turn defines length of the whole header,
including the version specific fields. Thus we need to know the
header version before using it.
In DATA_MSG.parse_msg() we need to parse the common header first,
so then we know the version and length of the whole header. After
that we can safely use DATA_MSG.HDR_LEN.
Change-Id: I2809f5f96209eed64bdabf7a15575144313f7cc9
---
M src/target/trx_toolkit/data_msg.py
1 file changed, 8 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 a1046ec..c5d284d 100644
--- a/src/target/trx_toolkit/data_msg.py
+++ b/src/target/trx_toolkit/data_msg.py
@@ -275,9 +275,9 @@
# Parses a TRX DATA message
def parse_msg(self, msg):
- # Make sure we have at least header
- if len(msg) < self.HDR_LEN:
- raise ValueError("Message is to short")
+ # Make sure we have at least common header
+ if len(msg) < self.CHDR_LEN:
+ raise ValueError("Message is to short: missing common header")
# Parse version and TDMA TN
self.ver = (msg[0] >> 4)
@@ -286,6 +286,11 @@
# Parse TDMA FN
self.fn = struct.unpack(">L", msg[1:5])[0]
+ # Make sure we have the whole header,
+ # including the version specific fields
+ if len(msg) < self.HDR_LEN:
+ raise ValueError("Message is to short: missing version specific header")
+
# Specific message part
self.parse_hdr(msg)
--
To view, visit https://gerrit.osmocom.org/c/osmocom-bb/+/15331
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmocom-bb
Gerrit-Branch: master
Gerrit-Change-Id: I2809f5f96209eed64bdabf7a15575144313f7cc9
Gerrit-Change-Number: 15331
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/f7ae71c2/attachment.htm>