verify maxPartID in object options helpers (#17015)

This commit is contained in:
jiuker 2023-04-19 13:34:30 +08:00 committed by GitHub
parent 224d9a752f
commit 8a81e317d6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 0 deletions

View File

@ -2097,6 +2097,8 @@ func toAPIErrorCode(ctx context.Context, err error) (apiErr APIErrorCode) {
apiErr = ErrObjectLockInvalidHeaders apiErr = ErrObjectLockInvalidHeaders
case objectlock.ErrMalformedXML: case objectlock.ErrMalformedXML:
apiErr = ErrMalformedXML apiErr = ErrMalformedXML
case errInvalidMaxParts:
apiErr = ErrInvalidMaxParts
} }
// Compression errors // Compression errors

View File

@ -89,6 +89,9 @@ func getOpts(ctx context.Context, r *http.Request, bucket, object string) (Objec
if err != nil { if err != nil {
return opts, err return opts, err
} }
if isMaxPartID(partNumber) {
return opts, errInvalidMaxParts
}
if partNumber <= 0 { if partNumber <= 0 {
return opts, errInvalidArgument return opts, errInvalidArgument
} }

View File

@ -112,3 +112,6 @@ var errIAMNotInitialized = errors.New("IAM sub-system is being initialized, plea
// error returned when upload id not found // error returned when upload id not found
var errUploadIDNotFound = errors.New("Specified Upload ID is not found") var errUploadIDNotFound = errors.New("Specified Upload ID is not found")
// error returned when PartNumber is greater than the maximum allowed 10000 parts
var errInvalidMaxParts = errors.New("Part number is greater than the maximum allowed 10000 parts")