mirror of
https://gitea.osmocom.org/sim-card/pysim.git
synced 2026-03-16 18:38:32 +03:00
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
This commit is contained in:
@@ -1224,6 +1224,13 @@ class TransRecEF(TransparentEF):
|
|||||||
Returns:
|
Returns:
|
||||||
abstract_data; dict representing the decoded data
|
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 len(raw_hex_data) // 2 < self.__get_rec_len():
|
||||||
|
return {'raw': raw_hex_data}
|
||||||
|
|
||||||
method = getattr(self, '_decode_record_hex', None)
|
method = getattr(self, '_decode_record_hex', None)
|
||||||
if callable(method):
|
if callable(method):
|
||||||
return method(raw_hex_data)
|
return method(raw_hex_data)
|
||||||
@@ -1251,6 +1258,11 @@ class TransRecEF(TransparentEF):
|
|||||||
Returns:
|
Returns:
|
||||||
abstract_data; dict representing the decoded data
|
abstract_data; dict representing the decoded data
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
# See comment in decode_record_hex (above)
|
||||||
|
if len(raw_bin_data) < self.__get_rec_len():
|
||||||
|
return {'raw': b2h(raw_bin_data)}
|
||||||
|
|
||||||
method = getattr(self, '_decode_record_bin', None)
|
method = getattr(self, '_decode_record_bin', None)
|
||||||
if callable(method):
|
if callable(method):
|
||||||
return method(raw_bin_data)
|
return method(raw_bin_data)
|
||||||
|
|||||||
Reference in New Issue
Block a user