mirror of
https://github.com/minio/minio
synced 2024-11-05 17:34:01 +00:00
fix wrong actual part size assignment in CopyObjectPart (#6652)
This commit fixes a wrong assignment to `actualPartSize`. The `actualPartSize` for an encrypted src object is not `srcInfo.Size` because that's the encrypted object size which is larger than the actual object size. So the actual part size for an encrypted object is the decrypted size of `srcInfo.Size`.
This commit is contained in:
parent
c0b4bf0a3e
commit
586466584f
1 changed files with 10 additions and 16 deletions
|
@ -1448,11 +1448,17 @@ func (api objectAPIHandlers) CopyObjectPartHandler(w http.ResponseWriter, r *htt
|
|||
defer gr.Close()
|
||||
srcInfo := gr.ObjInfo
|
||||
|
||||
var actualPartSize int64
|
||||
actualPartSize = srcInfo.Size
|
||||
actualPartSize := srcInfo.Size
|
||||
if crypto.IsEncrypted(srcInfo.UserDefined) {
|
||||
actualPartSize, err = srcInfo.DecryptedSize()
|
||||
if err != nil {
|
||||
writeErrorResponse(w, toAPIErrorCode(err), r.URL)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// Special care for CopyObjectPart
|
||||
if partRangeErr := checkCopyPartRangeWithSize(rs, srcInfo.Size); partRangeErr != nil {
|
||||
if partRangeErr := checkCopyPartRangeWithSize(rs, actualPartSize); partRangeErr != nil {
|
||||
writeCopyPartErr(w, partRangeErr, r.URL)
|
||||
return
|
||||
}
|
||||
|
@ -1463,23 +1469,11 @@ func (api objectAPIHandlers) CopyObjectPartHandler(w http.ResponseWriter, r *htt
|
|||
}
|
||||
|
||||
// Get the object offset & length
|
||||
startOffset, length, _ := rs.GetOffsetLength(srcInfo.Size)
|
||||
|
||||
startOffset, length, _ := rs.GetOffsetLength(actualPartSize)
|
||||
if rangeHeader != "" {
|
||||
actualPartSize = length
|
||||
}
|
||||
|
||||
if objectAPI.IsEncryptionSupported() {
|
||||
if crypto.IsEncrypted(srcInfo.UserDefined) {
|
||||
decryptedSize, decryptErr := srcInfo.DecryptedSize()
|
||||
if decryptErr != nil {
|
||||
writeErrorResponse(w, toAPIErrorCode(err), r.URL)
|
||||
return
|
||||
}
|
||||
startOffset, length, _ = rs.GetOffsetLength(decryptedSize)
|
||||
}
|
||||
}
|
||||
|
||||
/// maximum copy size for multipart objects in a single operation
|
||||
if isMaxAllowedPartSize(length) {
|
||||
writeErrorResponse(w, ErrEntityTooLarge, r.URL)
|
||||
|
|
Loading…
Reference in a new issue