From dfb480db3a9061822a59ca0ed4a972717929d733 Mon Sep 17 00:00:00 2001 From: hploetz Date: Tue, 12 Jun 2007 17:44:16 +0000 Subject: 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 --- cards/building_blocks.py | 6 ++++++ 1 file changed, 6 insertions(+) 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: -- cgit v1.2.3