LCBH / pssi

Automatically exported from code.google.com/p/pssi
GNU General Public License v3.0
0 stars 0 forks source link

IndexError: list index out of range #5

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. insert a bank card (maybe not EMV)
2.  ./pssi.py plugins/emv

What is the expected output?
Traceback (most recent call last):
  File "./pssi.py", line 108, in <module>
    main()
  File "./pssi.py", line 100, in main
    dumper.startDump()
  File "/Users/rousseau/Documents/sc/pssi/trunk/pssi/dumper.py", line 35, in startDump
    content = structure_parser.parseCard(card)
  File "/Users/rousseau/Documents/sc/pssi/trunk/pssi/structure_parser.py", line 338, in parseCard
    card["Content"] = parseCardStruct(connection, plugin.getRootStructure())
  File "/Users/rousseau/Documents/sc/pssi/trunk/pssi/structure_parser.py", line 229, in parseCardStruct
    entry[addr] = parseCardStruct(connection, field[3], [], sizeParsed, defaultStruct)
  File "/Users/rousseau/Documents/sc/pssi/trunk/pssi/structure_parser.py", line 134, in parseCardStruct
    entry[number] = parseTLV(cardData)
  File "/Users/rousseau/Documents/sc/pssi/trunk/pssi/structure_parser.py", line 81, in parseTLV
    if data[0] == 0x81 and len(data)>0: 
IndexError: list index out of range

What do you see instead?
no crash

What version of the product are you using? On what operating system?

Please provide any additional information below.
My card is a french carte bleue expired in 2008. It may NOT be an EMV card. But 
I think PSSI should not crash with non compliant cards.

Original issue reported on code.google.com by ludovic....@gmail.com on 11 Nov 2010 at 10:59

GoogleCodeExporter commented 8 years ago
When parseTLV() crashes the parameter data initialy contained [0, 0, 0, 0, 35, 
8, 64, 2, 80, 9, 120, 7, 18, 36, 0]

Just before the line
        if data[0] == 0x81 and len(data)>0: 
data contains
[0, 0, 0, 35, 8, 64, 2, 80, 9, 120, 7, 18, 36, 0]
[0, 35, 8, 64, 2, 80, 9, 120, 7, 18, 36, 0]
[8, 64, 2, 80, 9, 120, 7, 18, 36, 0]
[]

I propose to first check that len(data)>0 before accessing the first element.
With this change I have no crash and a normal display.

Patch attached.

Original comment by ludovic....@gmail.com on 11 Nov 2010 at 11:12

Attachments:

GoogleCodeExporter commented 8 years ago
This issue was closed by revision r39.

Original comment by eric.bou...@gmail.com on 11 Nov 2010 at 3:10