Change in pysim[master]: commands: fix update_binary() with 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
Thu Oct 14 17:15:46 UTC 2021


laforge has uploaded this change for review. ( https://gerrit.osmocom.org/c/pysim/+/25798 )


Change subject: commands: fix update_binary() with non-zero offset
......................................................................

commands: fix update_binary() with non-zero offset

In Icc240d5c8c04198640eb118565ea99f10ba27466 we introduced support for
writing files > 255 bytes by splitting the write into multiple chunks.

However, at the same time, that commit broke support for writing data at
non-zero offsets.  Unfortunately, this is used extensively within
pySim-prog e.g. for writing K + OP/OPc data to sysmoISIM-SJA2 and sysmoUSIM-SJS1
cards.

This commit fixes the related problem.

Change-Id: Ie1aeaab29701946233ed73db3331039690d695da
Fixes: Icc240d5c8c04198640eb118565ea99f10ba27466
Closes: OS#5254
---
M pySim/commands.py
1 file changed, 2 insertions(+), 2 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/98/25798/1

diff --git a/pySim/commands.py b/pySim/commands.py
index eb8217d..cd2b5b3 100644
--- a/pySim/commands.py
+++ b/pySim/commands.py
@@ -172,11 +172,11 @@
 		self.select_path(ef)
 		total_data = ''
 		total_sw = "9000"
-		chunk_offset = offset
+		chunk_offset = 0
 		while chunk_offset < data_length:
 			chunk_len = min(255, data_length - chunk_offset)
 			# chunk_offset is bytes, but data slicing is hex chars, so we need to multiply by 2
-			pdu = self.cla_byte + 'd6%04x%02x' % (chunk_offset, chunk_len) + data[chunk_offset*2 : (chunk_offset+chunk_len)*2]
+			pdu = self.cla_byte + 'd6%04x%02x' % (offset + chunk_offset, chunk_len) + data[chunk_offset*2 : (chunk_offset+chunk_len)*2]
 			chunk_data, chunk_sw = self._tp.send_apdu(pdu)
 			if chunk_sw == total_sw:
 				total_data += chunk_data

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

Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: Ie1aeaab29701946233ed73db3331039690d695da
Gerrit-Change-Number: 25798
Gerrit-PatchSet: 1
Gerrit-Owner: laforge <laforge at osmocom.org>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20211014/0d355b7b/attachment.htm>


More information about the gerrit-log mailing list