Unexpected IndexError exception on malformed input
See original GitHub issueWhen running the following code with the latest version of asn1crypto on the attached input in an unexpected IndexError exception:
import sys
from asn1crypto.core import Sequence
with open(sys.argv[1], 'rb') as f:
data = f.read()
parsed = Sequence.load(data)
parsed.copy() # force parsing
parsed.dump(force=True)
$ python3 asn2crypto_repro.py testcase.txt
Traceback (most recent call last):
File "asn2crypto_repro.py", line 6, in <module>
parsed = Sequence.load(data)
File "/home/user/.local/lib/python3.8/site-packages/asn1crypto/core.py", line 230, in load
value, _ = _parse_build(encoded_data, spec=spec, spec_params=kwargs, strict=strict)
File "/home/user/.local/lib/python3.8/site-packages/asn1crypto/core.py", line 5668, in _parse_build
info, new_pointer = _parse(encoded_data, encoded_len, pointer)
File "/home/user/.local/lib/python3.8/site-packages/asn1crypto/parser.py", line 175, in _parse
num = ord(encoded_data[pointer]) if _PY2 else encoded_data[pointer]
IndexError: index out of range
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (1 by maintainers)
Top Results From Across the Web
Which exception should I raise on bad/illegal argument ...
Used when keyword arguments are missing that were required for the specific call, or argument values are individually valid but inconsistent with each...
Read more >Malformed input or input contains unmappable characters
Malformed input or input contains unmappable characters. Problem. Errors/failures in the Git Integration for Jira application indexing. Diagnosis.
Read more >Git Integration for Jira Server - Confluence - Atlassian
Enable the Git Integration for Jira app in Jira Administration → Manage apps. Start a reindex of the Git Integration for Jira app....
Read more >Bug listing with status RESOLVED with resolution TEST ...
... moves unexpectedly" status:RESOLVED resolution:TEST-REQUEST severity:major ... Bug:93685 - "app-office/lyx kyb input errors for accented characters" ...
Read more >Lecture 1
Exceptions do not occur because of a malformed Python statement or program but ... Examples include those demonstrated above: ZeroDivisionError, IndexError, ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

I think we can improve the parse functions to be sure to raise a ValueError
whoops 😃