fix(storage): bounds-check the file basename in PurgeUploads Walk callback (#4860)

This commit is contained in:
Milos Gajdos authored and GitHub committed 2026-04-22 11:07:45 -07:00
commit f3af4de047
1 file changed
+6 -1
+6 -1
View File
@@ -71,7 +71,12 @@ func getOutstandingUploads(ctx context.Context, driver storageDriver.StorageDriv
err = driver.Walk(ctx, root, func(fileInfo storageDriver.FileInfo) error {
filePath := fileInfo.Path()
_, file := path.Split(filePath)
if file[0] == '_' {
// path.Split returns file == "" for paths that end in "/" (a
// bare directory such as the bucket root when S3 reports an
// empty Key / common prefix). Indexing file[0] then panics
// with 'index out of range [0] with length 0' and takes the
// whole PurgeUploads goroutine down (#4713).
if len(file) > 0 && file[0] == '_' {
// Reserved directory
inUploadDir = (file == "_uploads")