From 7166c1da175ce77f46ab4e0924ad821b32d92e46 Mon Sep 17 00:00:00 2001 From: Jimmy Zelinskie Date: Sat, 15 Jan 2022 14:33:45 -0500 Subject: [PATCH] storage/memory: avoid overflow in shard counts --- storage/memory/peer_store.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/storage/memory/peer_store.go b/storage/memory/peer_store.go index 5e95e31..d958919 100644 --- a/storage/memory/peer_store.go +++ b/storage/memory/peer_store.go @@ -4,6 +4,7 @@ package memory import ( "encoding/binary" + "math" "net" "runtime" "sync" @@ -79,7 +80,7 @@ func (cfg Config) LogFields() log.Fields { func (cfg Config) Validate() Config { validcfg := cfg - if cfg.ShardCount <= 0 { + if cfg.ShardCount <= 0 || cfg.ShardCount > (math.MaxInt/2) { validcfg.ShardCount = defaultShardCount log.Warn("falling back to default configuration", log.Fields{ "name": Name + ".ShardCount",