From abb385af41d63b2710add2e90b9601806d2a1003 Mon Sep 17 00:00:00 2001 From: Klaus Post Date: Tue, 28 Jan 2025 16:59:23 -0800 Subject: [PATCH] Check for valid checksum (#20878) Add a few safety measures for checksums. --- cmd/utils.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cmd/utils.go b/cmd/utils.go index 00724474c..f8067992f 100644 --- a/cmd/utils.go +++ b/cmd/utils.go @@ -271,10 +271,12 @@ func validateLengthAndChecksum(r *http.Request) bool { if err != nil { return false } - if !cs.Type.IsSet() { + if cs == nil || !cs.Type.IsSet() { return false } - r.Body = hash.NewChecker(r.Body, cs.Type.Hasher(), cs.Raw, r.ContentLength) + if cs.Valid() && !cs.Type.Trailing() { + r.Body = hash.NewChecker(r.Body, cs.Type.Hasher(), cs.Raw, r.ContentLength) + } return true }