Browse Source

compiles correctly

pull/7481/head
chrislu 2 weeks ago
parent
commit
95ca9335ce
  1. 9
      weed/s3api/s3api_object_handlers.go

9
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 // For small files stored inline in entry.Content
if len(entry.Content) > 0 && totalSize == int64(len(entry.Content)) { if len(entry.Content) > 0 && totalSize == int64(len(entry.Content)) {
if isRangeRequest { 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 return err
} }
_, err := w.Write(entry.Content) _, err := w.Write(entry.Content)

Loading…
Cancel
Save