aboutsummaryrefslogtreecommitdiffstats
path: root/pySim
diff options
context:
space:
mode:
authorPhilipp Maier <pmaier@sysmocom.de>2020-05-11 21:28:52 +0200
committerlaforge <laforge@osmocom.org>2020-05-17 07:34:14 +0000
commit7f9f64ac2a239659b99a52809669e300bd20f75b (patch)
tree54c50ae0c0a3baebb8f860038d203649b24b8c42 /pySim
parent7f1d3c496f2202f942ecd306c6fd43650f18f348 (diff)
cards: reset uninitalized EF.AD
The contents of EF.AD me be uninitalized (all bytes set to 0xff). If this is the case reset all bytes of the file to 0x00 and continue the update of EF.AD with this value. Change-Id: I57cf53e0c540469f11b6d85bd3daf3f9e14c237e
Diffstat (limited to 'pySim')
-rw-r--r--pySim/cards.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/pySim/cards.py b/pySim/cards.py
index f469cae..1c0add0 100644
--- a/pySim/cards.py
+++ b/pySim/cards.py
@@ -148,8 +148,13 @@ class Card(object):
if mnclen > 3:
raise RuntimeError('unable to calculate proper mnclen')
- data = self._scc.read_binary(EF['AD'], length=None, offset=0)
- content = data[0][0:6] + "%02X" % mnclen
+ data, sw = self._scc.read_binary(EF['AD'], length=None, offset=0)
+
+ # Reset contents to EF.AD in case the file is uninintalized
+ if data.lower() == "ffffffff":
+ data = "00000000"
+
+ content = data[0:6] + "%02X" % mnclen
data, sw = self._scc.update_binary(EF['AD'], content)
return sw