aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhploetz <hploetz@f711b948-2313-0410-aaa9-d29f33439f0b>2007-06-12 17:44:16 +0000
committerhploetz <hploetz@f711b948-2313-0410-aaa9-d29f33439f0b>2007-06-12 17:44:16 +0000
commitdfb480db3a9061822a59ca0ed4a972717929d733 (patch)
tree13b2632e434656281eee4715aa909e87a08c8296
parentcc1e70d1245cd39c5dfa1d2e4115b2d17e3fc3a0 (diff)
Prevent read_binary_file from falling into an infinite loop
git-svn-id: svn+ssh://localhost/home/henryk/svn/cyberflex-shell/trunk@244 f711b948-2313-0410-aaa9-d29f33439f0b
-rw-r--r--cards/building_blocks.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/cards/building_blocks.py b/cards/building_blocks.py
index 070ae67..7edc395 100644
--- a/cards/building_blocks.py
+++ b/cards/building_blocks.py
@@ -107,6 +107,7 @@ class Card_with_read_binary:
contents = ""
had_one = False
+ self.last_size = -1
while True:
command = C_APDU(self.APDU_READ_BINARY, p1 = offset >> 8, p2 = (offset & 0xff))
result = self.send_apdu(command)
@@ -114,6 +115,11 @@ class Card_with_read_binary:
contents = contents + result.data
offset = offset + (len(result.data) / self.DATA_UNIT_SIZE)
+ if self.last_size == len(contents):
+ break
+ else:
+ self.last_size = len(contents)
+
if not self.check_sw(result.sw):
break
else: