-
-
Notifications
You must be signed in to change notification settings - Fork 819
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix[codegen]: zero-length dynarray abi_decode
validation
#4060
fix[codegen]: zero-length dynarray abi_decode
validation
#4060
Conversation
--------- Co-authored-by: cyberthirst <[email protected]> Co-authored-by: Robert Chen <[email protected]>
can we get more efficient? this check is redundant except in the case where length is 0 (and therefore the loop is skipped) |
we could, but i'm going to punt it as an optimizer problem (for @harkal 😀 ) |
lgtm |
assert t.count < 2**64 # sanity check | ||
|
||
# note: this add does not risk arithmetic overflow because | ||
# length is bounded by count * elemsize. | ||
item_end = add_ofst(ir_node, _abi_payload_size(ir_node)) | ||
|
||
# if the subtype is dynamic, the length check is performed in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe reformulate the comment a bit - the length check was performed even before. what was missing was the in-bounds check ["assert", ["le", item_end, hi]]
the whole this test fails (ie doesn't raise) def test_abi_decode_dynarray_complex(env, tx_failed, get_contract):
code = """
struct Point:
x: uint256
y: uint256
@external
def run(x: Bytes[32 * 8]):
y: Bytes[32 * 8] = x
decoded_y1: DynArray[Point, 3] = _abi_decode(y, DynArray[Point, 3])
"""
c = get_contract(code)
payload = (
0x20,
0x03,
*_replicate(0x03, 3),
)
data = _abi_payload_from_tuple(payload)
with tx_failed():
c.run(data) the payload for the dynarray is |
add decode tests for dynarrays
add more abi decode tests
remove asserts from tests which fail in the decoder
abi_decode
validation
What I did
fix an edge case in abi decode validation
reported by @chen-robert
How I did it
How to verify it
Commit message
Description for the changelog
Cute Animal Picture