From 95ca9335ce12bc895f1a1c81f0abe30c37bed06b Mon Sep 17 00:00:00 2001 From: chrislu Date: Mon, 17 Nov 2025 12:51:31 -0800 Subject: [PATCH] compiles correctly --- weed/s3api/s3api_object_handlers.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/weed/s3api/s3api_object_handlers.go b/weed/s3api/s3api_object_handlers.go index 71ff0041f..f53460054 100644 --- a/weed/s3api/s3api_object_handlers.go +++ b/weed/s3api/s3api_object_handlers.go @@ -691,7 +691,14 @@ func (s3a *S3ApiServer) streamFromVolumeServers(w http.ResponseWriter, r *http.R // For small files stored inline in entry.Content if len(entry.Content) > 0 && totalSize == int64(len(entry.Content)) { if isRangeRequest { - _, err := w.Write(entry.Content[offset : offset+size]) + // Safely convert int64 to int for slice indexing + start := int(offset) + end := start + int(size) + // Bounds check (should already be validated, but double-check) + if start < 0 || end > len(entry.Content) || end < start { + return fmt.Errorf("invalid range for inline content: start=%d, end=%d, len=%d", start, end, len(entry.Content)) + } + _, err := w.Write(entry.Content[start:end]) return err } _, err := w.Write(entry.Content)