aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Welte <laforge@osmocom.org>2021-10-14 19:13:08 +0200
committerHarald Welte <laforge@osmocom.org>2021-10-14 19:13:08 +0200
commit80901d6d39fd05b923c48145147c47f0ad5252ca (patch)
treecc6b30f6874b97253ebc2d26519df4d070d6be06
parent4c1dca04a57f1f46c262868729805e832db334a2 (diff)
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
-rw-r--r--pySim/commands.py4
1 files changed, 2 insertions, 2 deletions
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 @@ class SimCardCommands(object):
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