core/vm: prevent overflow #29023 (#1244)

This commit is contained in:
Daniel Liu 2025-07-26 17:44:45 +08:00 committed by GitHub
parent 42d3549e2c
commit 6f6e08f83b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -187,7 +187,12 @@ func makeCallVariantGasCallEIP2929(oldCalculator gasFunc) gasFunc {
// outside of this function, as part of the dynamic gas, and that will make it
// also become correctly reported to tracers.
contract.Gas += coldCost
return gas + coldCost, nil
var overflow bool
if gas, overflow = math.SafeAdd(gas, coldCost); overflow {
return 0, ErrGasUintOverflow
}
return gas, nil
}
}