mirror of
https://github.com/distribution/distribution.git
synced 2026-10-28 10:15:27 +08:00
fix(storage): bounds-check the file basename in PurgeUploads Walk callback (#4860)
This commit is contained in:
1 file changed
+6
-1
@@ -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")
|
||||
|
||||
|
||||
Reference in new issue
Block a user