Repository navigation
test(compress): wire-byte regression for zlib_codec at protocol < 31 (RP28.i) - #4870
Merged
Merged
Conversation
oferchen
force-pushed
the
test/rp28-i-zlib-codec-proto-lt-31
branch
2 times, most recently
from
May 24, 2026 16:26
6847f69 to
3299c22
Compare
2 tasks done
oferchen
force-pushed
the
test/rp28-i-zlib-codec-proto-lt-31
branch
from
May 24, 2026 16:35
3299c22 to
f4a8e62
Compare
1 task done
oferchen
force-pushed
the
test/rp28-i-zlib-codec-proto-lt-31
branch
from
May 24, 2026 16:49
f4a8e62 to
b54db4e
Compare
…(RP28.i) Pins the wire-byte divergence between protocol 30 and protocol 31 in ZlibTokenEncoder::see_token when the input straddles the 0xFFFF chunk boundary. Protocol < 31 leaves the offset cursor un-advanced and re-inserts the same window into the deflate dictionary each iteration, matching the upstream data-duplicating bug behaviour kept for compatibility with pre-31 peers (token.c:473). The test asserts: - both protocols terminate with END_FLAG and emit at least one DEFLATED_DATA block; - protocol 30 output differs from protocol 31 for the same fixture; - protocol 31 and protocol 32 produce byte-identical output (shared >= 31 branch); - every supported pre-31 version (28, 29, 30) diverges from the modern baseline. Backend-portable: compares relative byte sequences rather than pinning backend-specific compressed payload bytes.
Line 35 starts with ">= 31" which markdown parses as a blockquote marker; clippy doc_lazy_continuation then flags lines 36-38 for missing markers. Rewrap so no continuation line begins with ">".
…e bytes The previous fixture (0x10001-byte see_buf + ASCII-only literal) gave a 2-byte tail divergence between the protocol-31 and protocol-30 dictionaries, which is too short for deflate's >= 3-byte minimum-match to encode as different back-references. Both protocol families compressed to byte-identical output, so the assertion never tripped even though the protocol-version gate at zlib_codec.rs:131 was the intended subject. Bump see_buf size to 0xFFFF + 4 to produce a 4-byte tail divergence, and prefix the literal with [0xFF, 0x00, 0x01, 0x02] so deflate finds the sequence at the protocol-31 dictionary tail at a small back-reference distance versus the interior of the protocol-30 dictionary at a much larger distance. The encoded distances and lengths diverge, so the wire bytes diverge. Verified end-to-end: tests pass with the protocol-version gate in place, and flipping the gate to `if false` reproduces the original divergence failures (confirming the test catches gate removal).
oferchen
force-pushed
the
test/rp28-i-zlib-codec-proto-lt-31
branch
from
May 24, 2026 18:26
9241548 to
4ceb7f0
Compare
oferchen
added a commit
that referenced
this pull request
Aug 24, 2026
…(RP28.i) (#4870) * test(compress): wire-byte regression for zlib_codec at protocol < 31 (RP28.i) Pins the wire-byte divergence between protocol 30 and protocol 31 in ZlibTokenEncoder::see_token when the input straddles the 0xFFFF chunk boundary. Protocol < 31 leaves the offset cursor un-advanced and re-inserts the same window into the deflate dictionary each iteration, matching the upstream data-duplicating bug behaviour kept for compatibility with pre-31 peers (token.c:473). The test asserts: - both protocols terminate with END_FLAG and emit at least one DEFLATED_DATA block; - protocol 30 output differs from protocol 31 for the same fixture; - protocol 31 and protocol 32 produce byte-identical output (shared >= 31 branch); - every supported pre-31 version (28, 29, 30) diverges from the modern baseline. Backend-portable: compares relative byte sequences rather than pinning backend-specific compressed payload bytes. * style(compress): apply rustfmt to zlib_codec_proto_lt_31.rs * ci(compress): retrigger fmt+clippy on zlib_codec_proto_lt_31 * ci(compress): retrigger CI on RP28.i after master fmt fixup #4891 * fix(tests): rewrap zlib_codec doc to avoid blockquote misparse Line 35 starts with ">= 31" which markdown parses as a blockquote marker; clippy doc_lazy_continuation then flags lines 36-38 for missing markers. Rewrap so no continuation line begins with ">". * fix(tests): rewrite RP28.i fixture so see_token gate manifests in wire bytes The previous fixture (0x10001-byte see_buf + ASCII-only literal) gave a 2-byte tail divergence between the protocol-31 and protocol-30 dictionaries, which is too short for deflate's >= 3-byte minimum-match to encode as different back-references. Both protocol families compressed to byte-identical output, so the assertion never tripped even though the protocol-version gate at zlib_codec.rs:131 was the intended subject. Bump see_buf size to 0xFFFF + 4 to produce a 4-byte tail divergence, and prefix the literal with [0xFF, 0x00, 0x01, 0x02] so deflate finds the sequence at the protocol-31 dictionary tail at a small back-reference distance versus the interior of the protocol-30 dictionary at a much larger distance. The encoded distances and lengths diverge, so the wire bytes diverge. Verified end-to-end: tests pass with the protocol-version gate in place, and flipping the gate to `if false` reproduces the original divergence failures (confirming the test catches gate removal).
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.
Summary
crates/protocol/tests/zlib_codec_proto_lt_31.rs, a wire-byteregression test that pins the protocol-version gate in
ZlibTokenEncoder::see_token.see_tokenis fed0x10001bytes (one bytepast the 0xFFFF chunk boundary) so the inner chunk-feeding loop
iterates twice. At protocol < 31 the
offsetcursor never advancesand the same window is re-inserted into the deflate dictionary, which
is the upstream data-duplicating bug preserved for pre-31 wire
compatibility.
DEFLATED_DATA payload reflects the protocol-conditioned dictionary
state and therefore differs between the two branches.
Assertions
END_FLAGterminatorDEFLATED_DATAblock>= 31gateUpstream reference
The gate is implemented in upstream
token.c:send_deflated_token()lines 463-484 of
target/interop/upstream-src/rsync-3.4.1/token.c:The mirror lives in
crates/protocol/src/wire/compressed_token/zlib_codec.rsinside
ZlibTokenEncoder::see_token(theif self.protocol_version >= 31branch around line 131).
Backend portability
Exact bytes inside the DEFLATED_DATA payload depend on the active
flate2backend (defaultminiz_oxide, pluszlib-ngandzlib-rsfeature builds). The test pins relative wire-byte properties (framing
invariants plus inter-protocol inequality) rather than a backend-specific
byte sequence, so all three backends pass.
Test plan
default
zlib-ngbackend.default-features = false)also passes the same assertions.