You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When parse response with dynamicBytes by method decodeSingleType, from ABIDecoding file, to array of responses set not new Data with bounds [0<..count], but slice for example on screenshot [32<..64]
And when i try to decode my values from this responses array with slices, ABIDecoder checks only size of data to avoid out of bounds
guard data.count >= pointer + type.memoryUsage else {return (nil, nil)}
and this data has correct size, and this check is succeed, but data is slice with bounds [32<..64], and it is crashed in
let elementItself = data[pointer ..< pointer + type.memoryUsage]
because pointer = 0, and type.memoryUsage = 32
What are the steps to reproduce?
1 request aggregated method for getting balances of some different tokens by methods "balanceOf" and "getEthBalance" , for example for 3 tokens from one wallet in one network with "createReadOperation" from Web3.Contract with aggregate ABI
2 try to decode response with contract's method contract.methods[methodName].decodeReturnData
3 app is crashed
What is the expected behavior?
I expect that work fine and not crashed, i think this fix solved the problem
replace
let elementItself = data[pointer ..< pointer + type.memoryUsage]
to
let elementItself = data[data.indices.startIndex + Int(pointer) ..< data.indices.startIndex + Int(pointer + type.memoryUsage)]
it will more safe, than previous because protect us from any slices of data
What is the error thrown?
EXC_BREAKPOINT (code=1, subcode=0x1aeb9fcb4)
What's the stack trace said?
#2 0x0000000103462ab8 in static ABIDecoder.followTheData(type:data:pointer:) at web3swift/Sources/Web3Core/EthereumABI/ABIDecoding.swift:191
What happened?
When parse response with dynamicBytes by method decodeSingleType, from ABIDecoding file, to array of responses set not new Data with bounds [0<..count], but slice for example on screenshot [32<..64]
And when i try to decode my values from this responses array with slices, ABIDecoder checks only size of data to avoid out of bounds
guard data.count >= pointer + type.memoryUsage else {return (nil, nil)}
and this data has correct size, and this check is succeed, but data is slice with bounds [32<..64], and it is crashed in
let elementItself = data[pointer ..< pointer + type.memoryUsage]
because pointer = 0, and type.memoryUsage = 32
What are the steps to reproduce?
1 request aggregated method for getting balances of some different tokens by methods "balanceOf" and "getEthBalance" , for example for 3 tokens from one wallet in one network with "createReadOperation" from Web3.Contract with aggregate ABI
2 try to decode response with contract's method contract.methods[methodName].decodeReturnData
3 app is crashed
What is the expected behavior?
I expect that work fine and not crashed, i think this fix solved the problem
replace
let elementItself = data[pointer ..< pointer + type.memoryUsage]
to
let elementItself = data[data.indices.startIndex + Int(pointer) ..< data.indices.startIndex + Int(pointer + type.memoryUsage)]
it will more safe, than previous because protect us from any slices of data
What is the error thrown?
EXC_BREAKPOINT (code=1, subcode=0x1aeb9fcb4)
What's the stack trace said?
#2 0x0000000103462ab8 in static ABIDecoder.followTheData(type:data:pointer:) at web3swift/Sources/Web3Core/EthereumABI/ABIDecoding.swift:191
OS version
iOS 16.1.1
Library version
"branch" : "develop",
"revision" : "2357868ce27009c5dec6b7a9f64d0a520e85b9af"
The text was updated successfully, but these errors were encountered: