pySim.tlv: Fix from_dict of nested TLVs

The existing logic is wrong.  How we call from_dict() doesn't differ if
a member IE itself contains a nested collection: We always must pass a
single-entry dict with the snak-case name of the class to from_dict().

Change-Id: Ic1f9db45db75b887227c2e20785198814cbab0f5
Fixes: OS#6453
This commit is contained in:
Harald Welte
2024-07-31 23:14:54 +02:00
parent d3fb38965b
commit d81c2086c8

View File

@@ -495,12 +495,7 @@ class TLV_IE_Collection(metaclass=TlvCollectionMeta):
# resolve the class for that name; create an instance of it
cls = self.members_by_name[k]
inst = cls()
if cls.nested_collection_cls:
# in case of collections, we want to pass the raw "value" portion to from_dict,
# as to_dict() below intentionally omits the collection-class-name as key
inst.from_dict(i[k])
else:
inst.from_dict({k: i[k]})
inst.from_dict({k: i[k]})
res.append(inst)
else:
raise ValueError('%s: Unknown TLV Class %s in %s; expected %s' %