fix(verify): do not panic when constructor args are longer than the bytecode - #16366
Open
mkzung wants to merge 3 commits into
Open
fix(verify): do not panic when constructor args are longer than the bytecode#16366mkzung wants to merge 3 commits into
mkzung wants to merge 3 commits into
Conversation
mkzung
requested review from
0xrusowsky,
DaniPopes,
figtracer,
grandizzy,
mablr,
mattsse and
stevencartavia
as code owners
August 25, 2026 17:39
Contributor
✅ Changelog foundThe deterministic check will validate the changed entry. |
stevencartavia
force-pushed
the
fix/verify-bytecode-args-longer-than-code
branch
from
August 25, 2026 17:55
0128ba6 to
91004c5
Compare
stevencartavia
approved these changes
Aug 25, 2026
stevencartavia
enabled auto-merge (squash)
August 25, 2026 17:55
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.
Motivation
forge verify-bytecodepanics instead of reporting a mismatch when--constructor-argsis longer than the code at the address.is_partial_matchstrips the args off the end of both buffers without checking either is that long:Both operands are
usize, and the args come from the command line while the on-chain side is whatever the address holds, so the subtraction underflows:mablr raised this on #16054.
Solution
checked_subon both, returningfalsewhen either is too short. A pair like that is a mismatch, and the caller already treatsfalseas one.The test asserts
Nonefrommatch_bytecodeswith four bytes of local code, two on chain and 32 bytes of args. It panics on master and passes with the change, and reverting only thechecked_subwith the test kept brings the panic back.forge-verifygoes from 56 tests to 57, all passing.Not addressed here, because it is a behavioural call rather than a crash: the stripped suffix is still never compared with the args that were supplied, so two different sets of the same length read alike. That is the wider half of mablr's point. Happy to follow it up separately if you want the matcher to check the suffix.
PR Checklist