Repository navigation
fix: preserve bitlist input when reusing bytes - #566
kutluhaneth46 wants to merge 1 commit into
Conversation
Non-byte-aligned BitList deserialize with reuseBytes cleared the delimiter bit in the caller's buffer. Check the length limit before slicing, and always copy when the padding bit must be cleared. Fixes ChainSafe#559
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
This looks like the same fix as #563 (opened 19 Nov): the same I ran both test files against |
|
Thanks @erkancamli for checking both branches. You are right. #563 opened first and lands the same fix (limit check before copy, unconditional slice when clearing the padding bit). Its doc comment on Happy to pull any of my tests into #563 if anything is still missing there. |
|
Closing as a duplicate of #563 (opened earlier with the same bitlist reuseBytes fix). |
Motivation
With
reuseBytes: true, decoding a non-byte-aligned bitlist clears its padding bit in the input buffer. Decoding the same bytes again can then return a different length or throw (see #559).Description
Check the bit length against the type limit before slicing, and always copy when the padding bit must be cleared so the caller buffer stays intact. Byte-aligned paths still reuse the input buffer.
Adds a regression suite for
BitListTypeandProgressiveBitListTypecovering the two-decode case, over-limit rejection before slice/subarray, and Buffer inputs.Fixes #559
Local:
pnpm exec vitest run test/unit/bitList-reuseBytes.test.ts --coverage.enabled=false(34/34 PASS)