From a755b8f47eb518cfd9fbb62dc925321beb4c136b Mon Sep 17 00:00:00 2001 From: Andrew Gaul Date: Fri, 11 Jun 2021 23:40:33 +0900 Subject: [PATCH] Avoid integer overflow in large range requests (#510) --- fakestorage/object.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fakestorage/object.go b/fakestorage/object.go index 4e97ace7a6..18f4a1c7a1 100644 --- a/fakestorage/object.go +++ b/fakestorage/object.go @@ -9,6 +9,7 @@ import ( "errors" "fmt" "io" + "math" "net/http" "sort" "strconv" @@ -544,7 +545,7 @@ func (s *Server) handleRange(obj Object, r *http.Request) (start, end int, conte var err error if end, err = strconv.Atoi(rangeParts[1]); err != nil { end = len(obj.Content) - } else { + } else if end != math.MaxInt64 { end++ } if end > len(obj.Content) {