prometheus/tsdb/index
George Krajcsovits 7d7b9eacff
Fix int32 overflow issues (#12978)
On a 32 bit architecture the size of int is 32 bits. Thus converting from
int64, uint64 can overflow it and flip the sign.

Try for yourself in playground:
package main

import "fmt"

func main() {
	x := int64(0x1F0000001)
	y := int64(1)
	z := int32(x - y) // numerically this is 0x1F0000000
	fmt.Printf("%v\n", z)
}

Prints -268435456 as if x was smaller.

Followup to #12650

Signed-off-by: György Krajcsovits <gyorgy.krajcsovits@grafana.com>
2023-10-16 16:23:26 +02:00
..
index.go Add context argument to LabelQuerier.LabelValues (#12665) 2023-09-14 16:02:04 +02:00
index_test.go Add context argument to LabelQuerier.LabelValues (#12665) 2023-09-14 16:02:04 +02:00
postings.go Revert ListPostings change (#12955) 2023-10-09 17:25:18 +02:00
postings_test.go Revert ListPostings change (#12955) 2023-10-09 17:25:18 +02:00
postingsstats.go Fix int32 overflow issues (#12978) 2023-10-16 16:23:26 +02:00
postingsstats_test.go Format Go source files using 'gofumpt -w -s -extra' 2021-11-02 19:52:34 +01:00