laforge has uploaded this change for review.

View Change

pySim.ota: Handle cases where 'secured_data' is empty

while it's true that in situations where response_status == 'por_ok'
we are guaranteed to have a 'secured_data' key in the dict, its value
could well be b'', which in turn causes us to run into an exception,
calling a decoder on an empty byte value; let's avoid that.

Change-Id: I7c919f9987585d3b42347c54bd3082a54b8c2a0a
---
M pySim/ota.py
1 file changed, 15 insertions(+), 1 deletion(-)

git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/83/37483/1
diff --git a/pySim/ota.py b/pySim/ota.py
index c3a7512..00a4b6b 100644
--- a/pySim/ota.py
+++ b/pySim/ota.py
@@ -478,7 +478,7 @@
raise OtaCheckError('Unknown por_rc_cc_ds: %s' % spi['por_rc_cc_ds'])

# TODO: ExpandedRemoteResponse according to TS 102 226 5.2.2
- if res.response_status == 'por_ok':
+ if res.response_status == 'por_ok' and len(res['secured_data']):
dec = CompactRemoteResp.parse(res['secured_data'])
else:
dec = None

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

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