Skip to content

Commit 5723673

Browse files
authored
Don't crash on large array (#981)
Thanks to @Mike4751 for the fix Closes #979
1 parent 2b5138f commit 5723673

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1414

1515
## Changed
1616
- `AbiFunction` and `AbiBytes` parser is now more strict
17+
- We now check length of AbiArrayDynamic and don't crash in case it's too large
1718
- SMT queries now run in separate processes, which allows us to better manage
1819
timeouts and memory usage by the SMT solver.
1920
- We now allow limiting the SMT solver's memory usage via `--smt-memory` (in MB).

src/EVM/ABI.hs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,9 @@ getAbi t = label (Text.unpack (abiTypeSolidity t)) $
257257

258258
AbiArrayDynamicType t' -> do
259259
AbiUInt _ n <- label "array length" (getAbi (AbiUIntType 256))
260-
AbiArrayDynamic t' <$>
260+
let maxLen = fromIntegral (maxBound :: Int) :: Word256
261+
if n > maxLen then fail "array length exceeds maximum Int"
262+
else AbiArrayDynamic t' <$>
261263
label "array body" (getAbiSeq (unsafeInto n) (repeat t'))
262264

263265
AbiTupleType ts ->

0 commit comments

Comments
 (0)