mirror of
https://gitea.osmocom.org/sim-card/pysim.git
synced 2026-03-31 02:45:27 +03:00
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
This commit is contained in:
@@ -141,13 +141,14 @@ class SimCardCommands(object):
|
|||||||
if length is None:
|
if length is None:
|
||||||
length = self.__len(r) - offset
|
length = self.__len(r) - offset
|
||||||
total_data = ''
|
total_data = ''
|
||||||
while offset < length:
|
chunk_offset = 0
|
||||||
chunk_len = min(255, length-offset)
|
while chunk_offset < length:
|
||||||
pdu = self.cla_byte + 'b0%04x%02x' % (offset, chunk_len)
|
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)
|
data,sw = self._tp.send_apdu(pdu)
|
||||||
if sw == '9000':
|
if sw == '9000':
|
||||||
total_data += data
|
total_data += data
|
||||||
offset += chunk_len
|
chunk_offset += chunk_len
|
||||||
else:
|
else:
|
||||||
raise ValueError('Failed to read (offset %d)' % (offset))
|
raise ValueError('Failed to read (offset %d)' % (offset))
|
||||||
return total_data, sw
|
return total_data, sw
|
||||||
|
|||||||
Reference in New Issue
Block a user