use strconv.ParseUint instead of strconv.ParseInt

Co-authored-by: Kévin Dunglas <kevin@dunglas.fr>
This commit is contained in:
WeidiDeng 2024-12-18 08:07:34 +08:00 committed by GitHub
parent 6db43b6079
commit f0801b9da5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -141,13 +141,10 @@ func (c *client) Do(p map[string]string, req io.Reader) (r io.Reader, err error)
// check for CONTENT_LENGTH, since the lack of it or wrong value will cause the backend to hang
if clStr, ok := p["CONTENT_LENGTH"]; !ok {
return nil, caddyhttp.Error(http.StatusLengthRequired, nil)
} else {
cl, err := strconv.ParseInt(clStr, 10, 64)
} else if _, err := strconv.ParseUint(clStr, 10, 64); err != nil {
// stdlib won't return a negative Content-Length, but we check just in case,
// the most likely cause is from a missing content length, which is -1
if err != nil || cl < 0 {
return nil, caddyhttp.Error(http.StatusLengthRequired, err)
}
return nil, caddyhttp.Error(http.StatusLengthRequired, err)
}
writer := &streamWriter{c: c}