Skip to content

Commit 4b9325c

Browse files
committed
esnure that implicitly tagged types are not probed for nesting. #13
1 parent d9f363f commit 4b9325c

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

Asn1Parser/Asn1Reader.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -169,10 +169,13 @@ void decode(Byte[] raw, Int32 pOffset) {
169169
}
170170
void parseNestedType() {
171171
// processing rules (assuming zero-based bits):
172-
// if bit 5 is set to "1", or the type is SEQUENCE/SET -- the type is constructed. Unroll nested types.
173-
// if bit 5 is set to "0", attempt to resolve nested types only for UNIVERSAL tags.
174-
// some universal types cannot include nested types: skip them in advance.
175-
if (_excludedTags.Contains(Tag) || PayloadLength < 2) { return; }
172+
// -- if bit 5 is set to "1", or the type is SEQUENCE/SET -- the type is constructed. Unroll nested types.
173+
// -- if bit 5 is set to "0", attempt to resolve nested types only for UNIVERSAL tags.
174+
// -- if the value is implicitly tagged, it cannot contain nested types.
175+
// -- some universal types cannot include nested types: skip them in advance.
176+
if (_excludedTags.Contains(Tag) || PayloadLength < 2 || Tag > 127 & Tag < 160) {
177+
return;
178+
}
176179
Int64 start = PayloadStartOffset;
177180
Int32 length = PayloadLength;
178181
// BIT_STRING includes "unused bits" octet, do not count it in calculations

0 commit comments

Comments
 (0)