One function
_parse in wbond/asn1crypto
The author described this change as “Ensure a ValueError is raised when DER-encoded value does not have necessary header bytes”. It counts as a record because the check below fails on the code as it stood at d2240365c and passes on 72e76c16f, with nothing else changed between the two runs.
Projectwbond/asn1crypto
Fix saved2017-02-07
Sharing licenceMIT · LICENSE
Change size+2 −2
What the code was meant to do, written into the code itself as a docstring
Parses a byte string into component parts :param encoded_data: A byte string that contains BER-encoded data :param data_len: The integer length of the encoded data :param pointer: The index in the byte string to parse from :param lengths_only: A boolean to cause the call to return a 2-element tuple of the integer number of bytes in the header and the integer number of bytes in the contents. Internal use only. :return: A 2-element tuple: - 0: A tuple of (class_, method, tag, header, content, trailer) - 1: An integer indicating how many bytes were consumed
The change
| 22 | 22 | - 1: An integer indicating how many bytes were consumed | |
| 23 | 23 | """ | |
| 24 | 24 | ||
| 25 | - | if data_len == 0: | |
| 26 | - | return ((None, None, None, None, None, None), pointer) | |
| 25 | + | if data_len < pointer + 2: | |
| 26 | + | raise ValueError(_INSUFFICIENT_DATA_MESSAGE % (2, data_len - pointer)) | |
| 27 | 27 | ||
| 28 | 28 | start = pointer | |
| 29 | 29 | first_octet = ord(encoded_data[pointer]) if _PY2 else encoded_data[pointer] |
The check that tells the two apart
fail→pass·tests/test_core.py::CoreTests::test_truncated_1
Check file tests/test_core.py, taken without changes from the fix and copied onto the older code, so the exact same check runs against both versions.
Origin and history
The code before itd2240365c670d679129df5589e429f0382d16445
Broken version dated2017-02-01
Moduleasn1crypto.parser
Units changed_parse
Fingerprint199ec313ceaa557f
Checked2026-08-18 by goldset/0.1
Every field above is generated by our program. None of it is written by hand.
Other bugs found in wbond/asn1crypto
- 2021-12-05Fix Clearance type definition
- 2021-11-21Fix tagging for RoleSyntax and SecurityCategory
- 2021-08-14_parse
- 2019-09-23_dump_header
- 2017-11-28Fix type checking in pem.armor()
- 2016-03-29uri_to_iri