Change in pysim[master]: cards: reset uninitalized EF.AD

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

laforge gerrit-no-reply at lists.osmocom.org
Sun May 17 07:34:14 UTC 2020


laforge has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/18206 )

Change subject: cards: reset uninitalized EF.AD
......................................................................

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
---
M pySim/cards.py
1 file changed, 7 insertions(+), 2 deletions(-)

Approvals:
  laforge: Looks good to me, approved
  Jenkins Builder: Verified



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 @@
 		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
 

-- 
To view, visit https://gerrit.osmocom.org/c/pysim/+/18206
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I57cf53e0c540469f11b6d85bd3daf3f9e14c237e
Gerrit-Change-Number: 18206
Gerrit-PatchSet: 4
Gerrit-Owner: dexter <pmaier at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20200517/16d1bc9a/attachment.htm>


More information about the gerrit-log mailing list