Skip to content
This repository was archived by the owner on Mar 27, 2026. It is now read-only.

Commit 54172e8

Browse files
authored
Merge pull request #14 from ronfrenk/read_tag_fix
Fixed a bug in read_tag
2 parents c542867 + af1268d commit 54172e8

3 files changed

Lines changed: 7 additions & 3 deletions

File tree

emv/protocol/data.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,10 @@ def read_tag(data):
4545
if is_two_byte(data[i]):
4646
i += 1
4747
tag += [data[i]]
48-
i += 1
4948
while len(data) > i and is_continuation(data[i]):
50-
tag += [data[i]]
5149
i += 1
50+
tag += [data[i]]
51+
i += 1
5252
else:
5353
i += 1
5454
return tag, i

emv/protocol/structures.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def unmarshal(cls, data):
5151
i += tag_len
5252
if len(data) <= i:
5353
log.info("Invalid TLV - read beyond end of buffer at %s: %s", tag, data)
54-
return data
54+
return tlv
5555

5656
length, length_len = read_length(data[i:])
5757
i += length_len

emv/protocol/test/test_structures.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ def test_tlv(self):
3131
tlv = TLV.unmarshal(data)
3232
self.assertEqual(tlv[(0x9F, 0x17)][0], 3)
3333

34+
data = unformat_bytes("DF DF 39 01 07")
35+
tlv = TLV.unmarshal(data)
36+
self.assertEqual(tlv[(0xDF, 0xDF, 0x39)][0], 7)
37+
3438
def test_length_parsing(self):
3539
data = unformat_bytes("42 01 03")
3640
tlv = TLV.unmarshal(data)

0 commit comments

Comments
 (0)