P1sec / pycrate

A Python library to ease the development of encoders and decoders for various protocols and file formats; contains ASN.1 and CSN.1 compilers.
GNU Lesser General Public License v2.1
382 stars 132 forks source link

ASN.1 compiler bug when a type name begins with a native type name and is followed by digits #99

Closed zpif closed 4 years ago

zpif commented 4 years ago

An ASN.1 file that I am working with defines the type "INTEGER8 ::= INTEGER (-128..127)". When this type us used, the parser (in function _parse_type_native) finds the native type "INTEGER" and then chokes on the "8" that is still left in the parser's input stream ("remaining textual definition, 8").

The issue is the definition of SYNT_RE_TYPE in utils.py, which needs to be adjusted so that the native type name also can not be followed by a digit for matching.

Minimal example: test.txt Patch for pycrate/pycrate_asn1c/utils.py utils.py.diff.txt

p1-bmu commented 4 years ago

Thanks for the report and patch. This is fixed in https://github.com/P1sec/pycrate/commit/1908a066bf65bc316e3e4a08079c186a3174b459.