storage/memory: avoid overflow in shard counts
This commit is contained in:
parent
f3468edf19
commit
7166c1da17
1 changed files with 2 additions and 1 deletions
|
@ -4,6 +4,7 @@ package memory
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
|
"math"
|
||||||
"net"
|
"net"
|
||||||
"runtime"
|
"runtime"
|
||||||
"sync"
|
"sync"
|
||||||
|
@ -79,7 +80,7 @@ func (cfg Config) LogFields() log.Fields {
|
||||||
func (cfg Config) Validate() Config {
|
func (cfg Config) Validate() Config {
|
||||||
validcfg := cfg
|
validcfg := cfg
|
||||||
|
|
||||||
if cfg.ShardCount <= 0 {
|
if cfg.ShardCount <= 0 || cfg.ShardCount > (math.MaxInt/2) {
|
||||||
validcfg.ShardCount = defaultShardCount
|
validcfg.ShardCount = defaultShardCount
|
||||||
log.Warn("falling back to default configuration", log.Fields{
|
log.Warn("falling back to default configuration", log.Fields{
|
||||||
"name": Name + ".ShardCount",
|
"name": Name + ".ShardCount",
|
||||||
|
|
Loading…
Add table
Reference in a new issue