From 1b238f368ae775eefa65abab957c227babb95323 Mon Sep 17 00:00:00 2001 From: chrislu Date: Mon, 17 Nov 2025 17:14:53 -0800 Subject: [PATCH] Update s3api_object_handlers.go --- weed/s3api/s3api_object_handlers.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/weed/s3api/s3api_object_handlers.go b/weed/s3api/s3api_object_handlers.go index 1b7ce6337..1662fb8c0 100644 --- a/weed/s3api/s3api_object_handlers.go +++ b/weed/s3api/s3api_object_handlers.go @@ -699,7 +699,8 @@ func (s3a *S3ApiServer) streamFromVolumeServers(w http.ResponseWriter, r *http.R if len(entry.Content) > 0 && totalSize == int64(len(entry.Content)) { if isRangeRequest { // Safely convert int64 to int for slice indexing - validate BEFORE WriteHeader - if offset < 0 || offset > int64(math.MaxInt) || size < 0 || size > int64(math.MaxInt) { + // Use MaxInt32 for portability across 32-bit and 64-bit platforms + if offset < 0 || offset > int64(math.MaxInt32) || size < 0 || size > int64(math.MaxInt32) { // Early validation error: write proper HTTP response BEFORE headers w.Header().Set("Content-Range", fmt.Sprintf("bytes */%d", totalSize)) w.WriteHeader(http.StatusRequestedRangeNotSatisfiable)