From 77cb1ea6d8a3e1f8d54dbcf2690034bf3aa83a83 Mon Sep 17 00:00:00 2001 From: Ashley Svetlik Date: Fri, 14 Jun 2019 13:44:04 -0500 Subject: [PATCH] Claified the arithmetic behind the max op.value --- roaring/roaring.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/roaring/roaring.go b/roaring/roaring.go index 31916445f..f1593df9c 100644 --- a/roaring/roaring.go +++ b/roaring/roaring.go @@ -3961,7 +3961,10 @@ func (op *op) UnmarshalBinary(data []byte) error { _, _ = h.Write(data[0:9]) if op.typ > 1 { - if 1152921504606847000 < int(op.value) { + // The maximum integer value for a int64 is 9223372036854775807 + maxInt := 9223372036854775807 + maxOpValue := maxInt/8-13 + if maxOpValue < int(op.value) { return fmt.Errorf("too big") } if len(data) < int(13+op.value*8) {