mirror of
https://github.com/pgsty/minio.git
synced 2026-09-23 19:35:59 +03:00
fix: reject composite CRC64NVME trailers
Apply the full-object-only rule to declared streaming checksum trailers and cover the HTTP mutation path. Signed-off-by: Feng Ruohang <rh@vonng.com>
This commit is contained in:
@@ -716,7 +716,11 @@ func GetContentChecksum(h http.Header) (*Checksum, error) {
|
||||
return nil, ErrInvalidChecksum
|
||||
}
|
||||
res.Type |= ChecksumFullObject
|
||||
case xhttp.AmzChecksumTypeComposite, "":
|
||||
case xhttp.AmzChecksumTypeComposite:
|
||||
if res.Type.Base().Is(ChecksumCRC64NVME) {
|
||||
return nil, ErrInvalidChecksum
|
||||
}
|
||||
case "":
|
||||
default:
|
||||
return nil, ErrInvalidChecksum
|
||||
}
|
||||
|
||||
@@ -150,6 +150,16 @@ func TestChecksumAddToHeader(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestCRC64NVMECompositeTrailerIsInvalid(t *testing.T) {
|
||||
h := http.Header{}
|
||||
h.Set(xhttp.AmzTrailer, ChecksumCRC64NVME.Key())
|
||||
h.Set(xhttp.AmzChecksumType, xhttp.AmzChecksumTypeComposite)
|
||||
_, err := GetContentChecksum(h)
|
||||
if !errors.Is(err, ErrInvalidChecksum) {
|
||||
t.Fatalf("CRC64NVME/COMPOSITE trailer error = %v, want ErrInvalidChecksum", err)
|
||||
}
|
||||
}
|
||||
|
||||
// TestChecksumSerializeDeserialize checks AppendTo can be reversed by ChecksumFromBytes
|
||||
func TestChecksumSerializeDeserialize(t *testing.T) {
|
||||
myData := []byte("this-is-a-checksum-data-test")
|
||||
|
||||
Reference in New Issue
Block a user