Change in pysim[master]: commands: Fix read_binary() for non-zero offset

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
Fri Oct 15 18:24:28 UTC 2021


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

Change subject: commands: Fix read_binary() for non-zero offset
......................................................................

commands: Fix read_binary() for non-zero offset

Similar to the fix in Ie1aeaab29701946233ed73db3331039690d695da
for update_binary(), read_binary() also contained a bug when treating
non-zero offsets.

Change-Id: Ic5c2f0ad1c1ec9c4e9c97e72895382f7b6fa9470
Related: OS#5254
---
M pySim/commands.py
1 file changed, 5 insertions(+), 4 deletions(-)

Approvals:
  laforge: Looks good to me, approved
  dexter: Looks good to me, but someone else must approve
  osmith: Looks good to me, but someone else must approve
  Jenkins Builder: Verified



diff --git a/pySim/commands.py b/pySim/commands.py
index cd2b5b3..d53cb3e 100644
--- a/pySim/commands.py
+++ b/pySim/commands.py
@@ -141,13 +141,14 @@
 		if length is None:
 			length = self.__len(r) - offset
 		total_data = ''
-		while offset < length:
-			chunk_len = min(255, length-offset)
-			pdu = self.cla_byte + 'b0%04x%02x' % (offset, chunk_len)
+		chunk_offset = 0
+		while chunk_offset < length:
+			chunk_len = min(255, length-chunk_offset)
+			pdu = self.cla_byte + 'b0%04x%02x' % (offset + chunk_offset, chunk_len)
 			data,sw = self._tp.send_apdu(pdu)
 			if sw == '9000':
 				total_data += data
-				offset += chunk_len
+				chunk_offset += chunk_len
 			else:
 				raise ValueError('Failed to read (offset %d)' % (offset))
 		return total_data, sw

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

Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: Ic5c2f0ad1c1ec9c4e9c97e72895382f7b6fa9470
Gerrit-Change-Number: 25801
Gerrit-PatchSet: 2
Gerrit-Owner: laforge <laforge at osmocom.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter <pmaier at sysmocom.de>
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-Reviewer: osmith <osmith at sysmocom.de>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20211015/b78099ba/attachment.htm>


More information about the gerrit-log mailing list