[pyasn1-users] Parse Errors
Brought to you by:
elie
|
From: Mike M. <mik...@gm...> - 2016-01-19 03:04:22
|
I've run into some problems decoding multiple extended tags starting
with 9F (9F02, 9F03, 9F06, etc). If I make the following changes,
they decode perfectly. The reason it's a problem is because the
tagId's end up being < 31. This makes me wonder if the tag number
should be 0x80 after the SHL 7 instead of 0. Otherwise it seems as
though (for instance) 82 and 9F02 would decode/encode incorrectly.
Applied against 1.8 (the tests still all pass, but I haven't worked on
the encoder side, obviously)
diff --git a/berdecoder.py b/berdecoder.py
index 61bfbce..4bf7ce4 100644
--- a/berdecoder.py
+++ b/berdecoder.py
@@ -643,8 +643,10 @@ class Decoder:
tagClass = t&0xC0
tagFormat = t&0x20
tagId = t&0x1F
+ short = True
if tagId == 0x1F:
tagId = 0
+ short = False
while 1:
if not substrate:
raise error.SubstrateUnderrunError(
@@ -658,7 +660,7 @@ class Decoder:
lastTag = tag.Tag(
tagClass=tagClass, tagFormat=tagFormat, tagId=tagId
)
- if tagId < 31:
+ if short:
# cache short tags
self.__tagCache[firstOctet] = lastTag
if tagSet is None:
|