Skip to content

Commit

Permalink
[evm precompiles] do *not* ignore unmarshal return value
Browse files Browse the repository at this point in the history
Because `unmarshal` is marked as `discardable` we silently ignored the
return value of `unmarshal`, which in some test cases indicated that
the source value does not fit into target bigint
  • Loading branch information
Vindaar committed Jun 28, 2024
1 parent 5308ddc commit 09755bd
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion constantine/ethereum_evm_precompiles.nim
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,8 @@ func parseRawUint[Name: static Algebra](
## Return false if the integer is larger than the field modulus.
## Returns true on success.
var big {.noInit.}: Fp[Name].getBigInt()
big.unmarshal(src, bigEndian)
if not big.unmarshal(src, bigEndian):
return cttEVM_IntLargerThanModulus # `dst` too small for `src`!

if not bool(big < Fp[Name].getModulus()):
return cttEVM_IntLargerThanModulus
Expand Down

0 comments on commit 09755bd

Please sign in to comment.