Repository navigation
asn1rt: fix ASN1Set.intersect() - #220
Merged
Merged
Conversation
is_ext() tested _er, which is an empty list (not None) for a non-extensible set, so intersect() treated every set as extensible and then iterated _ev, which is None. For extensible sets, intersect() called _init() without its two arguments, and step 4.3 copied root ranges (from .root) into the extension values, which _init() then could not sort against integers. Test _ev in is_ext(), pass sort_root and sort_ext to _init(), and only copy individual root values in step 4.3, since the root ranges are already merged into the extension ranges in step 4.1. Fixes pycrate-org#214
Member
|
Thanks for the fix ! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #214.
ASN1Set.intersect()in the runtime failed for integer sets in both cases from the issue, and the extensible case had one more problem past the one reported:ev=None):is_ext()testedself._er is not None, but__init__sets_er = []for a non-extensible set, so every set looked extensible.intersect()then iterated_ev, which isNone, and raisedTypeError: 'NoneType' object is not iterable.is_ext()now tests_ev, which isNoneexactly when the set is not extensible.ev=[]):ret._init()was called without itssort_root, sort_extarguments. With that fixed, step 4.3 still failed. It copies "root values not intersecting" fromself.rootandS.root, and for integer sets.rootalso holds theASN1RangeIntobjects. Those ranges went intoret._ev, and_init()then raisedASN1Err: ASN1RangeInt(0..10): unable to compare with 0. Step 4.3 now copies the individual root values (_rv) only; the root ranges are already merged intoret._erin step 4.1.Added
test_setobj_intersect()totest/test_asn1rt.pyand called it fromTestPycrate.test_asn1rtintest/test_pycrate.py. It runs the reproduction from the issue forev=Noneandev=[]and checks that the root is 5..10. It also checks that an individual root value outside the intersection ends up in the extension. It fails onmasterwith theTypeErrorabove and passes with the change. The rest oftest/test_asn1rt.pystill passes.