Repository navigation
fix(sctp): rebuild a last chunk short of its padding as captured (#1474) - #1477
Conversation
|
Verdict: NEEDS CHANGES at Required: honour the short-padding record only on the last item in the packet (chunk, parameter or cause), or document and test the alternative.
Confirmed fine:
Minor: Separate defect, filed as its own issue: an INIT or ABORT whose final parameter or cause is unpadded at the end of the packet is rejected at parse time. This happens on |
e583895 to
3c064da
Compare
|
Verdict: NEEDS CHANGES at
Everything else checked out:
|
A final SCTP chunk may arrive with fewer pad octets than its length calls for, or none. Parsing read what was there, but the rebuild zero-filled the rest, so 17 octets in gave 20 out. - `_keep_padding` now keeps a chunk's, parameter's or cause's `padding` in the info when it is short as well as when it is non-zero, so the record is the octets as captured, possibly `b''`. - `_restore_padding` hands a short record's width to the schema as `__padding__`, which `padding_length` packs to. The `pre_pack` of the chunk, parameter and cause bases resets the key per schema, so one chunk's record cannot shorten the next through the shared context. - Only the last item of a list keeps that record; an earlier chunk, and the items nested in it, pack to the full aligned width. - The five #1474 rows leave the transport edge-case known-failure table. New tests/protocols/transport/test_sctp_unpadded_last_chunk_unit.py.
25f82aa to
efa8793
Compare
|
Verdict: GOOD TO GO at
Non-blocking: |
|
Coverage: 89.56% (unit tier, Python 3.14,
Per-file detail: the |
) (#1481) The span of a chunk's nested parameter or error cause list counts the chunk's trailing padding, which the last chunk of a packet may omit (RFC 9260 Sec. 3.2). The last item then read past the data and parsing raised ProtocolError for INIT, INIT ACK, HEARTBEAT, HEARTBEAT ACK, ABORT and ERROR. - Clamp the span to the octets present by wrapping nested_length in bounded, so the final item reads only the padding there is; the #1477 short-padding record then rebuilds it byte-exactly. New tests/protocols/transport/test_sctp_unpadded_final_param_unit.py.
Please follow the guide below
make pylint,make mypy,make isort)make testpasses, and a test case covers the change: a test covers it, and the legs below pass; the full suite was not rundocs/source/changelog/and regeneratedCHANGELOG.md, if the change is user-visible: N/A — centralised in docs(changelog): shared 1.5.0 changelog — long-lived, merges last (#610, #616, #617, #618, #620) #657What 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
Closes #1474. A last chunk with fewer pad octets than its
lengthcalls for, or none, now rebuilds as captured through bothfrom_data(info)andfrom_data(info.to_dict()). Before,padding_length(pcapkit/protocols/schema/transport/sctp.py:84) always packed the full width, so 17 octets in gave 20 out.Why the existing
paddingkey. #1223 already keeps a chunk's, parameter's or cause'spaddingininfowhen a fresh build would not reproduce it (non-zero). A short pad is the same situation, so_keep_paddingnow also keeps it when it is short, possibly asb''. It is the same key, holding the octets as captured, and it already round-trips throughto_dict(). A__short_read__-style dunder would duplicate that record.trailercannot carry it either, because it follows the chunk, which would still pad itself. No new key, so no!.On rebuild,
_restore_paddinggives the schema a__padding__width thatpadding_lengthpacks to. Thepre_packofChunk,ParameterandErrorCauseresets the key for each schema, becauseSchema.packshares one context across siblings. Only the last item of a list keeps the record: an earlier chunk, and anything nested in it, packs to the full aligned width even if an editedinfosays otherwise.maketakes nopaddingkeyword, as the data-model docstrings now say.The five #1474
Gaprows are deleted from the transport edge table. New moduletests/protocols/transport/test_sctp_unpadded_last_chunk_unit.py: onorigin/mainsources, 14 failed and 6 passed; with this fix, 8 passed (12 subtests). The SCTP, transport-edge, capture-runtime andtests/projectlegs pass. The per-frameto_dict()hashes overexamples/captures(1616 frames) matchorigin/main.Out of scope: an INIT or ABORT whose final parameter or cause is also unpadded is still rejected at parse ("option that runs past the end of the data"), not mis-rebuilt.