Change in pysim[master]: commands.py: fix read_binary for lengths > 256

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/.

guilly@gmail.com gerrit-no-reply at lists.osmocom.org
Fri Apr 17 15:45:14 UTC 2020


guilly at gmail.com has uploaded this change for review. ( https://gerrit.osmocom.org/c/pysim/+/17848 )


Change subject: commands.py: fix read_binary for lengths > 256
......................................................................

commands.py: fix read_binary for lengths > 256

Change-Id: Ie9c61caa1412606254b44a3a24f26ad44950e73a
---
M pySim/commands.py
1 file changed, 8 insertions(+), 2 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/48/17848/1

diff --git a/pySim/commands.py b/pySim/commands.py
index cc7acc6..9369422 100644
--- a/pySim/commands.py
+++ b/pySim/commands.py
@@ -119,8 +119,14 @@
 			return (None, None)
 		if length is None:
 			length = self.__len(r) - offset
-		pdu = self.cla_byte + 'b0%04x%02x' % (offset, (min(256, length) & 0xff))
-		return self._tp.send_apdu(pdu)
+		total_data = ''
+		while offset < length:
+			data_chunk = (min(255, length-offset) & 0xff)
+			pdu = self.cla_byte + 'b0%04x%02x' % (offset, data_chunk)
+			data,sw = self._tp.send_apdu(pdu)
+			total_data += data
+			offset += data_chunk
+		return total_data, sw
 
 	def update_binary(self, ef, data, offset=0):
 		self.select_file(ef)

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

Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: Ie9c61caa1412606254b44a3a24f26ad44950e73a
Gerrit-Change-Number: 17848
Gerrit-PatchSet: 1
Gerrit-Owner: guilly at gmail.com <guilly at gmail.com>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20200417/565566da/attachment.htm>


More information about the gerrit-log mailing list