laforge has uploaded this change for review.

View Change

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(-)

git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/99/36899/1
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:]

To view, visit change 36899. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: Id1a892c3446e472699e77f076c2414277e92c98d
Gerrit-Change-Number: 36899
Gerrit-PatchSet: 1
Gerrit-Owner: laforge <laforge@osmocom.org>
Gerrit-MessageType: newchange