Traceback on unknown TLV
mathieui opened this issue · 5 comments
mathieui commented
ChatSecure uses custom TLV values for their OTRDATA protocol, and it exposed a bug in potr:
File "/usr/lib64/python3.4/site-packages/potr/context.py", line 225, in receiveMessage
plaintext, tlvs = self.crypto.handleDataMessage(message)
File "/usr/lib64/python3.4/site-packages/potr/crypt.py", line 192, in handleDataMessage
tlvs = proto.TLV.parse(tlvData)
File "/usr/lib64/python3.4/site-packages/potr/proto.py", line 319, in parse
return [tlvClasses[typ].parsePayload(data[:length])] \
KeyError: 256
potr should check if the received TLVs are known before trying to get the relevant class. (and maybe return a custom exception when it isn’t known?)
koolfy commented
We should actually raise NotOTRMessage as it's used in the rest of the code.
I'm looking into why it's not the case here exactly, and fix this quickly :)
koolfy commented
Possible fix to test: 1422de3
I basically just implemented a new exception (insead of reusing NotOTRMessage which I didn't find to fit the bill quite right), and added a check against registered values of implemented TLV in the tlvClasses dict.
mathieui commented
Yes, looks good to me
koolfy commented
Great, I'm currently at 32C3 and (intentionally) don't have github credentials on my person :)
As soon as I get back, I'll merge the branch and prepare a new release.
koolfy commented
Merged in staging, closing for now.