laforge has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/36899?usp=email )
Change subject: commands.py: Resolve possible variable use before assignment ......................................................................
commands.py: Resolve possible variable use before assignment
pySim/commands.py:223:18: E0606: Possibly using variable 'skip' before assignment (possibly-used-before-assignment)
Let's raise an exception in the erroneous case.
Change-Id: Id1a892c3446e472699e77f076c2414277e92c98d --- M pySim/commands.py 1 file changed, 15 insertions(+), 0 deletions(-)
Approvals: Jenkins Builder: Verified laforge: Looks good to me, approved
diff --git a/pySim/commands.py b/pySim/commands.py index 9a49124..08537bd 100644 --- a/pySim/commands.py +++ b/pySim/commands.py @@ -211,6 +211,7 @@ # checking if the length of the remaining TLV string matches # what we get in the length field. # See also ETSI TS 102 221, chapter 11.1.1.3.0 Base coding. + # TODO: this likely just is normal BER-TLV ("All data objects are BER-TLV except if otherwise # defined.") exp_tlv_len = int(fcp[2:4], 16) if len(fcp[4:]) // 2 == exp_tlv_len: skip = 4 @@ -218,6 +219,7 @@ exp_tlv_len = int(fcp[2:6], 16) if len(fcp[4:]) // 2 == exp_tlv_len: skip = 6 + raise ValueError('Cannot determine length of TLV-length')
# Skip FCP tag and length tlv = fcp[skip:]