fix: listParts crash when partNumberMarker is expected (#620)

fixes https://github.com/minio/minio/issues/21098
This commit is contained in:
Harshavardhana 2025-04-04 06:15:36 -07:00
parent eafeb27e90
commit 6640be3bed
2 changed files with 38 additions and 4 deletions

View File

@ -1,4 +1,4 @@
// Copyright (c) 2015-2023 MinIO, Inc.
// Copyright (c) 2015-2025 MinIO, Inc.
//
// This file is part of MinIO Object Storage stack
//
@ -928,7 +928,19 @@ func (er erasureObjects) ListObjectParts(ctx context.Context, bucket, object, up
}
start := objectPartIndexNums(partNums, partNumberMarker)
if start != -1 {
if partNumberMarker > 0 && start == -1 {
// Marker not present among what is present on the
// server, we return an empty list.
return result, nil
}
if partNumberMarker > 0 && start != -1 {
if start+1 >= len(partNums) {
// Marker indicates that we are the end
// of the list, so we simply return empty
return result, nil
}
partNums = partNums[start+1:]
}

View File

@ -1378,6 +1378,24 @@ func testListObjectPartsStale(obj ObjectLayer, instanceType string, disks []stri
},
},
},
// partinfos - 4.
{
Bucket: bucketNames[0],
Object: objectNames[0],
MaxParts: 2,
IsTruncated: false,
UploadID: uploadIDs[0],
PartNumberMarker: 4,
},
// partinfos - 5.
{
Bucket: bucketNames[0],
Object: objectNames[0],
MaxParts: 2,
IsTruncated: false,
UploadID: uploadIDs[0],
PartNumberMarker: 100,
},
}
// Collection of non-exhaustive ListObjectParts test cases, valid errors
@ -1412,10 +1430,14 @@ func testListObjectPartsStale(obj ObjectLayer, instanceType string, disks []stri
{bucketNames[0], objectNames[0], uploadIDs[0], 0, 10, partInfos[0], nil, true},
// Test case with maxParts set to less than number of parts (Test number 13).
{bucketNames[0], objectNames[0], uploadIDs[0], 0, 3, partInfos[1], nil, true},
// Test case with partNumberMarker set (Test number 14)-.
// Test case with partNumberMarker set (Test number 14).
{bucketNames[0], objectNames[0], uploadIDs[0], 0, 2, partInfos[2], nil, true},
// Test case with partNumberMarker set (Test number 15)-.
// Test case with partNumberMarker set (Test number 15).
{bucketNames[0], objectNames[0], uploadIDs[0], 3, 2, partInfos[3], nil, true},
// Test case with partNumberMarker set (Test number 16).
{bucketNames[0], objectNames[0], uploadIDs[0], 4, 2, partInfos[4], nil, true},
// Test case with partNumberMarker set (Test number 17).
{bucketNames[0], objectNames[0], uploadIDs[0], 100, 2, partInfos[5], nil, true},
}
for i, testCase := range testCases {