Repository navigation
fix(ipv6)!: an extension header parsed with extension=True cannot rebuild from its own info (#1446) - #1449
Merged
Conversation
…uild from its own info (#1446) IPv6 hands each extension header the rest of the datagram with extension=True. The header parses only itself, and its info holds no payload, but its data kept every octet after it, so type(ex).from_data(ex.info).data came back short (8 of 442 octets on ipv6.pcap frame 16). Internet.__post_init__ now cuts data to the header's own length in extension mode, which covers HOPOPT, IPv6-Route, IPv6-Frag, IPv6-Opts, MH, AH, HIP and IPv6_Ext alike. The parent IPv6 rebuild already joins from_data(info).data per header, so it is unchanged.
Contributor
|
Coverage: 89.51% (unit tier, Python 3.14,
Per-file detail: the |
Owner
Author
|
Verdict: GOOD TO GO at
Nits, no change needed:
|
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.
make pylint,make mypy,make isort) — ran pylint/mypy/isort oninternet.pyonly; no new messages on the added linesmake testpasses, and a test case covers the change —protocols/internetleg, everytest_ipv6*/test_mh*module,test_option_roundtrip_unit,tests/projectWhat is the purpose of your pull request?
fix— corrects a defectfeat· [ ]perf· [ ]refactor· [ ]test· [ ]docs· [ ]ci· [ ]release· [ ]choreDescription of your pull request and other information
Closes #1446
An extension header parsed with
extension=Trueis handed the rest of the datagram, but parses only itself:infohas no payload and.payloadraisesUnsupportedCall.Internet.__post_init__now cuts.datato the header'slengthin that mode, sotype(ex).from_data(ex.info).data == ex.data. This keepsIPv6._make_dataas it is, since it already joinsfrom_data(info).dataper header. Carrying the remainder ininfowould have emitted those octets twice.Covers HOPOPT, IPv6-Route, IPv6-Frag, IPv6-Opts, MH, AH, HIP and IPv6_Ext. With HOPOPT + UDP, data/rebuilt goes from 28/8 to 8/8. On
ipv6.pcapframe 16 (Fragment), 442/8 becomes 8/8. IPv6 parent rebuilds stay exact, 247/247 acrossexamples/captures.Breaking (
!):data,bytes()andlen()of an extension-mode header now cover the header only. A standalone parse is unchanged.