mirror of
https://github.com/minio/minio.git
synced 2025-02-04 02:15:59 -05: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
@ -1448,11 +1448,17 @@ func (api objectAPIHandlers) CopyObjectPartHandler(w http.ResponseWriter, r *htt
|
|||||||
defer gr.Close()
|
defer gr.Close()
|
||||||
srcInfo := gr.ObjInfo
|
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
|
// Special care for CopyObjectPart
|
||||||
if partRangeErr := checkCopyPartRangeWithSize(rs, srcInfo.Size); partRangeErr != nil {
|
if partRangeErr := checkCopyPartRangeWithSize(rs, actualPartSize); partRangeErr != nil {
|
||||||
writeCopyPartErr(w, partRangeErr, r.URL)
|
writeCopyPartErr(w, partRangeErr, r.URL)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -1463,23 +1469,11 @@ func (api objectAPIHandlers) CopyObjectPartHandler(w http.ResponseWriter, r *htt
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get the object offset & length
|
// Get the object offset & length
|
||||||
startOffset, length, _ := rs.GetOffsetLength(srcInfo.Size)
|
startOffset, length, _ := rs.GetOffsetLength(actualPartSize)
|
||||||
|
|
||||||
if rangeHeader != "" {
|
if rangeHeader != "" {
|
||||||
actualPartSize = length
|
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
|
/// maximum copy size for multipart objects in a single operation
|
||||||
if isMaxAllowedPartSize(length) {
|
if isMaxAllowedPartSize(length) {
|
||||||
writeErrorResponse(w, ErrEntityTooLarge, r.URL)
|
writeErrorResponse(w, ErrEntityTooLarge, r.URL)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user