diff --git a/libsolidity/codegen/ABIFunctions.cpp b/libsolidity/codegen/ABIFunctions.cpp index cfbb01ec6..ffced74c5 100644 --- a/libsolidity/codegen/ABIFunctions.cpp +++ b/libsolidity/codegen/ABIFunctions.cpp @@ -1187,19 +1187,14 @@ string ABIFunctions::abiDecodingFunctionArrayAvailableLength(ArrayType const& _t dst := add(array, 0x20) let src := offset - - // TODO add check that we can actually load from all - // offset pointers, i.e. as below, but with stride being 0x20. - - if gt(add(src, mul(length, )), end) { - - } - + if gt(add(src, mul(length, )), end) { + + } for { let i := 0 } lt(i, length) { i := add(i, 1) } { let innerOffset := (src) - // TODO add overflow check + if gt(innerOffset, 0xffffffffffffffff) { } let elementPos := add(offset, innerOffset) let elementPos := src @@ -1218,11 +1213,11 @@ string ABIFunctions::abiDecodingFunctionArrayAvailableLength(ArrayType const& _t templ("dynamic", _type.isDynamicallySized()); templ("load", _fromMemory ? "mload" : "calldataload"); templ("dynamicBase", _type.baseType()->isDynamicallyEncoded()); - if (!_type.baseType()->isDynamicallyEncoded()) - templ( - "revertInvalidStride", - revertReasonIfDebug("ABI decoding: invalid calldata array stride") - ); + templ( + "revertInvalidStride", + revertReasonIfDebug("ABI decoding: invalid calldata array stride") + ); + templ("revertStringOffset", revertReasonIfDebug("ABI decoding: invalid calldata array offset")); templ("decodingFun", abiDecodingFunction(*_type.baseType(), _fromMemory, false)); return templ.render(); }); diff --git a/test/libsolidity/semanticTests/abiencodedecode/offset_overflow_in_array_decoding.sol b/test/libsolidity/semanticTests/abiencodedecode/offset_overflow_in_array_decoding.sol index a7e335e47..40d633d96 100644 --- a/test/libsolidity/semanticTests/abiencodedecode/offset_overflow_in_array_decoding.sol +++ b/test/libsolidity/semanticTests/abiencodedecode/offset_overflow_in_array_decoding.sol @@ -26,4 +26,4 @@ contract Test { // ==== // compileViaYul: also // ---- -// test() -> 0x01e240 +// test() -> FAILURE diff --git a/test/libsolidity/semanticTests/abiencodedecode/offset_overflow_in_array_decoding_2.sol b/test/libsolidity/semanticTests/abiencodedecode/offset_overflow_in_array_decoding_2.sol index 88ff3510b..d21f0111b 100644 --- a/test/libsolidity/semanticTests/abiencodedecode/offset_overflow_in_array_decoding_2.sol +++ b/test/libsolidity/semanticTests/abiencodedecode/offset_overflow_in_array_decoding_2.sol @@ -27,4 +27,4 @@ contract Test { // ==== // compileViaYul: also // ---- -// withinArray() -> 0x03c480 +// withinArray() -> FAILURE diff --git a/test/libsolidity/semanticTests/abiencodedecode/offset_overflow_in_array_decoding_3.sol b/test/libsolidity/semanticTests/abiencodedecode/offset_overflow_in_array_decoding_3.sol index 30fc8731e..2ac68257b 100644 --- a/test/libsolidity/semanticTests/abiencodedecode/offset_overflow_in_array_decoding_3.sol +++ b/test/libsolidity/semanticTests/abiencodedecode/offset_overflow_in_array_decoding_3.sol @@ -20,4 +20,4 @@ contract Test { // ==== // compileViaYul: also // ---- -// test() -> 0x01e240 +// test() -> FAILURE