<p>laforge has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.osmocom.org/c/pysim/+/25798">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">commands: fix update_binary() with non-zero offset<br><br>In Icc240d5c8c04198640eb118565ea99f10ba27466 we introduced support for<br>writing files > 255 bytes by splitting the write into multiple chunks.<br><br>However, at the same time, that commit broke support for writing data at<br>non-zero offsets.  Unfortunately, this is used extensively within<br>pySim-prog e.g. for writing K + OP/OPc data to sysmoISIM-SJA2 and sysmoUSIM-SJS1<br>cards.<br><br>This commit fixes the related problem.<br><br>Change-Id: Ie1aeaab29701946233ed73db3331039690d695da<br>Fixes: Icc240d5c8c04198640eb118565ea99f10ba27466<br>Closes: OS#5254<br>---<br>M pySim/commands.py<br>1 file changed, 2 insertions(+), 2 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/98/25798/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/pySim/commands.py b/pySim/commands.py</span><br><span>index eb8217d..cd2b5b3 100644</span><br><span>--- a/pySim/commands.py</span><br><span>+++ b/pySim/commands.py</span><br><span>@@ -172,11 +172,11 @@</span><br><span>               self.select_path(ef)</span><br><span>                 total_data = ''</span><br><span>              total_sw = "9000"</span><br><span style="color: hsl(0, 100%, 40%);">-             chunk_offset = offset</span><br><span style="color: hsl(120, 100%, 40%);">+         chunk_offset = 0</span><br><span>             while chunk_offset < data_length:</span><br><span>                         chunk_len = min(255, data_length - chunk_offset)</span><br><span>                     # chunk_offset is bytes, but data slicing is hex chars, so we need to multiply by 2</span><br><span style="color: hsl(0, 100%, 40%);">-                     pdu = self.cla_byte + 'd6%04x%02x' % (chunk_offset, chunk_len) + data[chunk_offset*2 : (chunk_offset+chunk_len)*2]</span><br><span style="color: hsl(120, 100%, 40%);">+                    pdu = self.cla_byte + 'd6%04x%02x' % (offset + chunk_offset, chunk_len) + data[chunk_offset*2 : (chunk_offset+chunk_len)*2]</span><br><span>                  chunk_data, chunk_sw = self._tp.send_apdu(pdu)</span><br><span>                       if chunk_sw == total_sw:</span><br><span>                             total_data += chunk_data</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/c/pysim/+/25798">change 25798</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.osmocom.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.osmocom.org/c/pysim/+/25798"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: pysim </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: Ie1aeaab29701946233ed73db3331039690d695da </div>
<div style="display:none"> Gerrit-Change-Number: 25798 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: laforge <laforge@osmocom.org> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>