Repository navigation
fix(ipv6): CALIPSO make() writes a corrupt length on overflow and raises raw errors for a bad pad - #1409
Merged
Conversation
JarryShaw
force-pushed
the
fix/1408-calipso-make-validation
branch
from
October 8, 2026 03:58
638cddb to
5a3cfb5
Compare
Contributor
|
Coverage: 89.41% (unit tier, Python 3.14,
Per-file detail: the |
Owner
Author
|
Cross-review verdict on
Everything else holds:
|
…ses raw errors for a bad pad _make_opt_calipso in HOPOPT and IPv6-Opts now raises ProtocolError when the bitmap plus pad would exceed the 255 octets Opt Data Len can count, when pad is not bytes/bytearray, and when the bitmap is a bare int or str or holds an octet that is not an int in 0-255. Bytes-like objects and iterables of ints build unchanged. _read_opt_calipso no longer rejects an odd Cmpt Length, which RFC 5570 section 5.2 permits and make() builds; it now rejects a Cmpt Length that Opt Data Len does not cover. Closes #1408
JarryShaw
force-pushed
the
fix/1408-calipso-make-validation
branch
from
October 8, 2026 04:20
5a3cfb5 to
c228007
Compare
Owner
Author
|
Delta verdict on
|
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) — not runmake testpasses, and a test case covers the change — the new module,util/run_unittest_leg.py protocols/internet(566 OK) andtests/project(399 passed, 1 skipped)What is the purpose of your pull request?
fix— corrects a defectfeat— adds a featureperf— changes performance, not behaviourrefactor— changes neither behaviour nor performancetest— tests onlydocs— documentation onlyci— workflows or build toolingrelease— bumps the version or rolls up a distributionchore— anything elseDescription of your pull request and other information
CALIPSO changes in HOPOPT and IPv6-Opts:
make()overflow:8 + bitmap + pad > 255now raisesProtocolError. Before, a 248-octet pad wrote length00and a 1000-octet pad wrotef0.make()bad pad: a non-bytespad now raisesProtocolError, notstruct.errororTypeError.make()bad bitmap: an octet out of 0–255 or not anintraisedValueError/TypeError, astrbitmap raisedTypeError, and anintbitmap was misbuilt (4became 4 zero octets). All now raiseProtocolError. Abooloctet, whichmainwrote as01, is now rejected too.Cmpt Length(behaviour change):make()emitted it but the reader rejected it. RFC 5570 §5.2 sizes the bitmap in 32-bit quanta ("0 bits, 32 bits, 64 bits, 96 bits"), and §5.1.3 says why. So the reader now accepts it. It still rejects aCmpt LengththatOpt Data Lendoes not cover.Valid input builds unchanged bytes. That covers the 255-octet boundary and any bytes-like object (
bytearray,memoryview) or iterable of ints (tuple,list,range, a generator); each matchesmain's octets.Tests:
test_ipv6_calipso_make_validation_unit.pypasses 7 tests and 56 subtests. Onorigin/main's two source files, 36 subtests fail (18 per protocol). The equal-output cases pass on both.Closes #1408