dexter has uploaded this change for review.
filesystem: do not decode short TransRecEF records
A TransRecEF is based on a TransparentEF. This means that a TransRecEF
is basically normal TransparentEF that holds a record oriented data
structure. This also requires that the total length of the TransRecEF
is a multiple of the record length of the data structure that is stored
in it. When this is not the case, the last record will be cut short and
the decoding will fail. We should guard against this case.
Related: OS#6598
Change-Id: Ib1dc4d7ce306f1f0b080bb4b6abc36e72431d3fa
---
M pySim/filesystem.py
1 file changed, 12 insertions(+), 0 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/70/39670/1
diff --git a/pySim/filesystem.py b/pySim/filesystem.py
index 246afb0..f00698b 100644
--- a/pySim/filesystem.py
+++ b/pySim/filesystem.py
@@ -1224,6 +1224,13 @@
Returns:
abstract_data; dict representing the decoded data
"""
+
+ # The record data length should always be equal or at least greater than the record length defined for the
+ # TransRecEF. Short records may be occur when the length of the underlying TransparentEF is not a multiple
+ # of the TransRecEF record length.
+ if self.__get_rec_len() >= len(raw_hex_data):
+ return {'short_record': raw_hex_data}
+
method = getattr(self, '_decode_record_hex', None)
if callable(method):
return method(raw_hex_data)
@@ -1251,6 +1258,11 @@
Returns:
abstract_data; dict representing the decoded data
"""
+
+ # See comment in decode_record_hex (above)
+ if self.__get_rec_len() >= len(raw_bin_data):
+ return {'short_record': b2h(raw_bin_data)}
+
method = getattr(self, '_decode_record_bin', None)
if callable(method):
return method(raw_bin_data)
To view, visit change 39670. To unsubscribe, or for help writing mail filters, visit settings.