From be497f28e8c911ec13ea18b2ebb1663888998419 Mon Sep 17 00:00:00 2001 From: Wei-Ning Huang Date: Mon, 22 Apr 2019 15:25:54 +0800 Subject: core: vm: add sanity check for updateConfiguration (#383) --- core/vm/oracle_contracts.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/core/vm/oracle_contracts.go b/core/vm/oracle_contracts.go index 2dc1ce54f..35a9e5861 100644 --- a/core/vm/oracle_contracts.go +++ b/core/vm/oracle_contracts.go @@ -1708,6 +1708,18 @@ func (g *GovernanceContract) updateConfiguration(cfg *rawConfigStruct) ([]byte, return nil, errExecutionReverted } + // Sanity checks. + if cfg.MinStake.Cmp(big.NewInt(0)) <= 0 || + cfg.LockupPeriod.Cmp(big.NewInt(0)) <= 0 || + cfg.BlockGasLimit.Cmp(big.NewInt(0)) <= 0 || + cfg.MinGasPrice.Cmp(big.NewInt(0)) <= 0 || + cfg.LambdaBA.Cmp(big.NewInt(0)) <= 0 || + cfg.LambdaDKG.Cmp(big.NewInt(0)) <= 0 || + cfg.RoundLength.Cmp(big.NewInt(0)) <= 0 || + cfg.MinBlockInterval.Cmp(big.NewInt(0)) <= 0 { + return nil, errExecutionReverted + } + g.state.UpdateConfigurationRaw(cfg) g.state.emitConfigurationChangedEvent() -- cgit