mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-06-19 13:21:37 +00:00
ABI.Pack returned `append(method.ID, arguments...)`. method.ID is derived from crypto.Keccak256(sig)[:4], which yields a slice of length 4 but capacity 32 (the full keccak hash buffer), and it is computed once and cached on the parsed method. When a method takes no arguments, the append has nothing to copy and returns method.ID's own backing array. The caller therefore received calldata that aliased the ABI's cached selector. Mutating that calldata, or a concurrent Pack of the same no-arg method, corrupted the cached selector and broke every subsequent encode of that method. (Methods with arguments always pack to >=32 bytes, so 4+32 > 32 forces a reallocation and they were never affected.) Copy method.ID into a fresh slice before appending the arguments so the returned calldata never shares storage with the cached selector. Add a regression test that packs a no-arg method, mutates the result, and verifies both the cached selector and a subsequent pack are unaffected. |
||
|---|---|---|
| .. | ||
| abigen | ||
| bind | ||
| abi.go | ||
| abi_test.go | ||
| abifuzzer_test.go | ||
| argument.go | ||
| doc.go | ||
| error.go | ||
| error_handling.go | ||
| event.go | ||
| event_test.go | ||
| method.go | ||
| method_test.go | ||
| pack.go | ||
| pack_selector_alias_test.go | ||
| pack_test.go | ||
| packing_test.go | ||
| reflect.go | ||
| reflect_test.go | ||
| selector_parser.go | ||
| selector_parser_test.go | ||
| topics.go | ||
| topics_test.go | ||
| type.go | ||
| type_test.go | ||
| unpack.go | ||
| unpack_test.go | ||
| utils.go | ||