lynxis lazus has uploaded this change for review. ( https://gerrit.osmocom.org/c/pysim/+/43197?usp=email ) Change subject: pySim/apdu: protect SW access from None ...................................................................... pySim/apdu: protect SW access from None If SW hasn't been set yet or is empty, protect access to sw Change-Id: Iff7fe02f700e0eb42766a3264a856fc7947cdcd2 --- M pySim/apdu/__init__.py 1 file changed, 7 insertions(+), 6 deletions(-) git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/97/43197/1 diff --git a/pySim/apdu/__init__.py b/pySim/apdu/__init__.py index 84ac83a..4344d3e 100644 --- a/pySim/apdu/__init__.py +++ b/pySim/apdu/__init__.py @@ -134,11 +134,12 @@ if callable(method): return method() # default case: only 9000 is success - if self.sw == b'\x90\x00': - return True - # This is not really a generic positive APDU SW but specific to UICC/SIM - if self.sw[0] == 0x91: - return True + if self.sw: + if self.sw == b'\x90\x00': + return True + # This is not really a generic positive APDU SW but specific to UICC/SIM + if self.sw[0] == 0x91: + return True return False @@ -423,7 +424,7 @@ def input_tpdu(self, tpdu:Tpdu): # handle SW=61xx / 6Cxx - if tpdu.sw[0] == 0x61 or tpdu.sw[0] == 0x6C: + if tpdu.sw and (tpdu.sw[0] == 0x61 or tpdu.sw[0] == 0x6C): self.state = 'WAIT_GET_RESPONSE' # handle successive 61/6c responses by stupid phone/modem OS if tpdu.ins != 0xC0: -- To view, visit https://gerrit.osmocom.org/c/pysim/+/43197?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: newchange Gerrit-Project: pysim Gerrit-Branch: master Gerrit-Change-Id: Iff7fe02f700e0eb42766a3264a856fc7947cdcd2 Gerrit-Change-Number: 43197 Gerrit-PatchSet: 1 Gerrit-Owner: lynxis lazus <lynxis@fe80.eu>