diff options
author | Harald Welte <laforge@osmocom.org> | 2024-05-17 11:11:24 +0200 |
---|---|---|
committer | Harald Welte <laforge@osmocom.org> | 2024-05-22 18:03:59 +0200 |
commit | 45b7d0126b82c2bdefeb80ebb2b6b9b41a84789b (patch) | |
tree | 034e20661ab36f0ad3f76879ef3c6f7bdc3001ce | |
parent | 73a5c74114ffdda7295f2d8b2f329a535e062cb3 (diff) |
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
-rw-r--r-- | pySim/commands.py | 2 |
1 files changed, 2 insertions, 0 deletions
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 @@ class SimCardCommands: # 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 @@ class SimCardCommands: 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:] |