mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-10-20 21:14:25 +02:00
s3: reject UploadPart checksum algorithms conflicting with the upload
An UploadPart that explicitly selects a different checksum algorithm than the one declared at CreateMultipartUpload would store a checksum CompleteMultipartUpload could never accept. Reject the conflict up front with InvalidRequest, matching AWS.
This commit is contained in:
1 parent
f849b7c823
commit
b03419ee92
2 files changed
+39
-4
No files matched your search
@@ -446,11 +446,16 @@ func (s3a *S3ApiServer) PutObjectPartHandler(w http.ResponseWriter, r *http.Requ
|
||||
}
|
||||
|
||||
// Parts inherit the checksum algorithm declared at CreateMultipartUpload
|
||||
// when the request doesn't specify one (AWS behavior).
|
||||
// when the request doesn't specify one; a conflicting one is rejected.
|
||||
if headerName := string(uploadEntry.Extended[s3_constants.ExtChecksumAlgorithm]); headerName != "" {
|
||||
if algo, _, code := detectRequestedChecksumAlgorithm(r); code == s3err.ErrNone && algo == ChecksumAlgorithmNone {
|
||||
if name := checksumAlgorithmNameFromHeaderName(headerName); name != "" {
|
||||
r.Header.Set(s3_constants.AmzChecksumAlgorithm, name)
|
||||
if algo, reqHeaderName, code := detectRequestedChecksumAlgorithm(r); code == s3err.ErrNone {
|
||||
if algo == ChecksumAlgorithmNone {
|
||||
if name := checksumAlgorithmNameFromHeaderName(headerName); name != "" {
|
||||
r.Header.Set(s3_constants.AmzChecksumAlgorithm, name)
|
||||
}
|
||||
} else if reqHeaderName != headerName {
|
||||
s3err.WriteErrorResponse(w, r, s3err.ErrInvalidRequest)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user