Repository navigation
refactor(decode): delete the unreachable dispatchOne header parser (#88) - #106
Merged
Merged
Conversation
`dispatchOne` was a third copy of the field-header parser, private to the input stream and called from nowhere. Being dead, it had drifted: it read the fixlen word without `fixlenWordValid` (§4.6), the array count without the ARRAY_MAX ceiling (§6.2) and the array fixlen word without `arrayFixlenWordValid` (§4.8), and it folded every truncation into `error_`, i.e. it would have reported INCOMPLETE input as INVALID. Wiring it up would have re-opened exactly the hole `nestedArrayCountCeiling()` closed: `05 <count=2^62> 20` takes the `count * element_size` skip, wraps size_t to zero bytes and decodes COMPLETE a message §6.2 requires to be INVALID. Delete it, and point the one doc comment that named it (`@ref dispatchOne` on the §7.3 tag-match seam) at the two parsers that actually perform the skip, `parseTopLevel` and `dispatchLevel`. `headerParsersEnforceCeilings()` guards both halves of this. It drives the §4.6/§4.8/§6.2 violations through the callback entry point — the API a per-field dispatcher serves — and, because an unreachable parser cannot be reached by feeding bytes at all, also scans the header source and requires every `(id<<3)|type` decode site to carry the three ceiling checks. That structural half fails on the parent commit, naming sofab.hpp:4381. Closes #88.
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.
The finding
IStreamImpl::dispatchOnewas a third copy of the field-header parser, private and called from nowhere —grep -rn dispatchOnefound only its definition and a stale@refin the §7.3 doc comment.Being dead, it had drifted away from the two live copies (
parseFieldHeader,dispatchLevel) and enforced none of the ceilings they do:fixlenWordValid()(§4.6),ARRAY_MAXcheck (§6.2),arrayFixlenWordValid()(§4.8),error_, i.e. INCOMPLETE input reported as INVALID.Wiring it up would have re-opened the hole
nestedArrayCountCeiling()was added for:05 <count=2^62> 20takes thecount * element_sizeskip, wrapssize_tto zero bytes, and a message §6.2 requires to be INVALID decodes COMPLETE.The change
dispatchOne.parseTopLevelat the top level,dispatchLevelinside a sequence.No public API and no wire behaviour changes: the function was private and unreachable.
Regression test
headerParsersEnforceCeilings()intest/test_roundtrip.cpp, wired into the normal suite, in two halves:2^62, integer-array count2^31, reserved fixlen subtype,stringelement in a fixlen array) are fed through the callback entry point, the API a per-field dispatcher serves, and must all beInvalidMessage; a legal fp32 array still decodes.include/sofab/sofab.hpp(path baked in by CMake, same tricktest_vectorsuses for the shared vectors) and requires every(id<<3)|typedecode site to carryfixlenWordValid,arrayFixlenWordValidandARRAY_MAX.Half 2 fails on the parent commit with three failures naming
sofab.hpp:4381— the dead parser — and passes here. The README'stest_roundtripbullet documents the structural check.Closes #88.