fix(pcapng): walk the journal entry instead of splitting it on b'\n\n' - #728
Conversation
42933aa to
d23bffa
Compare
|
❌ NEEDS CHANGES @ |
|
❌ NEEDS CHANGES @ First independent review, different model from the author. Everything below is evidence I obtained myself.
Required change. The reader's position is well defined after a bad terminator, so bailing is a policy choice, not a necessity — and it is the shape this docstring's own #678 note argues against ("aborted the whole extraction rather than this one entry"), one level down. Either drop Minor, not blocking. Counts (repo venv 3.14.7, ❌ NEEDS CHANGES @ |
- SystemdJournalExportBlock.post_process split self.entry on b'\n\n' before reading a field, delimiting a length-prefixed format by content. A binary value containing b'\n\n' was cut mid-value into a bogus field in a spurious entry (#723 defect A); a 2,570-octet value is worse, since struct.pack('<Q', 2570) starts with b'\n\n', landing the split inside the length prefix and reading zero fields (defect B). - Rewrote the loop to walk self.entry once, length-prefix driven; folds in #722's terminator check so both fixes coexist, and retires its newline-restoration, which only undid what slicing had taken away. - A trailing separator landing on the block's last octet was indistinguishable from plain EOF and swallowed instead of ending the entry, writing a rebuilt length one octet short. Now tracked so a real blank line still starts the next entry. - Cross-review found the added `malformed` flag broke the *outer* per-entry loop, widening #722's per-entry terminator check into a per-block one and silently dropping well-formed entries behind a bad one. Removed it; the existing `break` already scopes the check to its own entry. Its `:1832` twin was already dead (EOF-only, where the walk ends regardless) -- confirmed and dropped too. - Tests for both #723 defects, #722's fixtures, the alignment gap, and a well-formed entry surviving a bad terminator ahead of it. Tests: 86 passed, 1753 subtests; pcapng.py coverage stays 100% statements/branches (551/78).
d23bffa to
dcd4808
Compare
|
Fixed @ Added two tests pinning behaviour relative to Abort-the-block-on-any-corruption was considered as deliberate hardening and rejected as the 86 passed, 1753 subtests branch-only; 92 passed, 2113 subtests merged into |
|
✅ GOOD TO MERGE @ |
|
✅ GOOD TO MERGE @ Second review; supersedes the ❌ NEEDS CHANGES on
Counts reproduced independently: branch-only 86 passed / 1753 subtests, Round-trip — and the rebuild is Caveats, none blocking: (a) no round-trip test exercises the rebuild path with empty entries present; (b) #728 walks into the block's NUL padding in more situations, so padding adjacent to non-NUL garbage can synthesise an empty-key junk field ✅ GOOD TO MERGE @ |
Please follow the guide below
make pylint,make mypy,make isort)make testpasses, and a test case covers the changeWhat is the purpose of your pull request?
fix— corrects a defectDescription of your pull request and other information
Fixes #723.
First review caught a regression against #722: the
malformedflag this rewrite added brokethe outer per-entry loop, so a bad terminator ended the whole block, not just its entry --
silently dropping every well-formed entry behind it, contradicting the "nothing of #722's is
lost" claim this PR originally made. Fixed by dropping
malformedentirely (its:1832twinwas already dead); the existing per-entry
breakis now the only effect. Alternative consideredand rejected as the default: abort the rest of the block on any corruption, as deliberate
hardening -- open for the maintainer to reconsider.
Also fixes an independent alignment gap: a trailing separator landing on the block's last octet
was indistinguishable from EOF and swallowed, so a rebuild wrote
lengthone octet short.Tests:
tests/protocols/misc/test_pcapng_unit.py, 86 passed, 1753 subtests.Coverage:
pcapng.py100% stmts/branches (551/78).