From 69bdcf50228a947a39cbf0c9b25ec1f21eaaf276 Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Thu, 28 Dec 2023 09:21:17 +0100 Subject: [PATCH] Fix TLV_IE_Collection.from_tlv in certain situations The existing code used to produce an empty output in situations where a TLV_IE_Collection would be parsed from a single TLV only with some additional trailing padding: >>> from pySim.utils import h2b >>> from pySim.ts_31_102 import EF_CSGT >>> t = EF_CSGT.Csgt_TLV_Collection() >>> t.from_tlv(h2b('8906810300666f6fff')) [TextCsgType(foo)] >>> t.to_dict() [] This was caused by an early return (actually returning the decoded result) but *without updating self.children*. Change-Id: I1c84ccf698c6ff7e7f14242f9aaf7d15ac2239f4 --- pySim/tlv.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pySim/tlv.py b/pySim/tlv.py index 4ac5ebf6..ccf049e9 100644 --- a/pySim/tlv.py +++ b/pySim/tlv.py @@ -361,7 +361,7 @@ class TLV_IE_Collection(metaclass=TlvCollectionMeta): # obtain the tag at the start of the remainder tag, r = first._parse_tag_raw(remainder) if tag == None: - return res + break if tag in self.members_by_tag: cls = self.members_by_tag[tag] # create an instance and parse accordingly