LudovicRousseau / pyscard-contrib

Contribution for PySCard
46 stars 20 forks source link

failed to parse ATR 3F 6A 00 00 00 64 01 50 01 0C 82 01 01 A9 #2

Closed dgeng closed 8 years ago

dgeng commented 8 years ago
macbook:parseATR james$ python parseATR.py 3F 6A 00 00 00 64 01 50 01 0C 82 01 01 A9
ATR: 3F 6A 00 00 00 64 01 50 01 0C 82 01 01 A9
Traceback (most recent call last):
  File "parseATR.py", line 1321, in <module>
    text = atr_display_txt(atr)
  File "parseATR.py", line 1108, in atr_display_txt
    return atr_display(atr, colorize_txt)
  File "parseATR.py", line 1225, in atr_display
    t = analyse_histrorical_bytes(atr["hb"])
  File "parseATR.py", line 997, in analyse_histrorical_bytes
    [t, a] = compact_tlv(historical_bytes)
  File "parseATR.py", line 931, in compact_tlv
    sw1 = historical_bytes[0]
IndexError: list index out of range
dgeng commented 8 years ago

I discovered this issue when I did the below

macbook:tmp james$ ls -l /usr/local/share/pcsc/smartcard_list.txt
-rw-r--r--  1 root  admin  234566 Jan  6 14:45 /usr/local/share/pcsc/smartcard_list.txt
macbook:parseATR james$ python stress_test.py > out.log
Traceback (most recent call last):
  File "stress_test.py", line 61, in <module>
    stress(List)
  File "stress_test.py", line 44, in stress
    txt = parseATR.atr_display_txt(parseATR.parseATR(atr))
  File "/private/tmp/pyscard-contrib/parseATR/parseATR.py", line 1108, in atr_display_txt
    return atr_display(atr, colorize_txt)
  File "/private/tmp/pyscard-contrib/parseATR/parseATR.py", line 1225, in atr_display
    t = analyse_histrorical_bytes(atr["hb"])
  File "/private/tmp/pyscard-contrib/parseATR/parseATR.py", line 997, in analyse_histrorical_bytes
    [t, a] = compact_tlv(historical_bytes)
  File "/private/tmp/pyscard-contrib/parseATR/parseATR.py", line 931, in compact_tlv
    sw1 = historical_bytes[0]
IndexError: list index out of range
LudovicRousseau commented 8 years ago

Fixed in https://github.com/LudovicRousseau/pyscard-contrib/commit/72c826fe601e6357b27e431d4e9093b94a9c60d6

It now works. See https://smartcard-atr.appspot.com/parse?ATR=3F6A000000640150010C820101A9