Check for valid checksum (#20878)

Add a few safety measures for checksums.
This commit is contained in:
Klaus Post 2025-01-28 16:59:23 -08:00 committed by GitHub
parent 4ee62606e4
commit abb385af41
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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
}