From b666f2860b2735eb61fe5a03dd90c3af8eed1ec3 Mon Sep 17 00:00:00 2001 From: Josh Bleecher Snyder Date: Mon, 1 May 2017 07:36:43 -0700 Subject: [PATCH] runtime: use 64 bit calculation in overLoadFactor overLoadFactor used a uintptr for its calculations. When the number of potential buckets was large, perhaps due to a coding error or corrupt/malicious user input leading to a very large map size hint, this led to overflow on 32 bit systems. This overflow resulted in an infinite loop. Prevent it by always using a 64 bit calculation. Updates #20195 Change-Id: Iaabc710773cd5da6754f43b913478cc5562d89a2 Reviewed-on: https://go-review.googlesource.com/42185 Run-TryBot: Josh Bleecher Snyder TryBot-Result: Gobot Gobot Reviewed-by: Keith Randall --- src/runtime/hashmap.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/runtime/hashmap.go b/src/runtime/hashmap.go index 0c9505e655..c6c2fa5fdf 100644 --- a/src/runtime/hashmap.go +++ b/src/runtime/hashmap.go @@ -985,7 +985,7 @@ func hashGrow(t *maptype, h *hmap) { // overLoadFactor reports whether count items placed in 1<= bucketCnt && float32(count) >= loadFactor*float32((uintptr(1)<= bucketCnt && float32(count) >= loadFactor*float32((uint64(1)<