add 32-bit tests; return errors in case of string-to-int overflows (#276)

This commit is contained in:
Alessandro Ros
2023-05-08 13:10:31 +02:00
committed by GitHub
parent 3d5496173d
commit a54a5946c7
22 changed files with 67 additions and 55 deletions

View File

@@ -150,11 +150,11 @@ func (res *Response) Unmarshal(br *bufio.Reader) error {
}
statusCodeStr := string(byts[:len(byts)-1])
statusCode64, err := strconv.ParseInt(statusCodeStr, 10, 32)
tmp, err := strconv.ParseUint(statusCodeStr, 10, 31)
if err != nil {
return fmt.Errorf("unable to parse status code")
}
res.StatusCode = StatusCode(statusCode64)
res.StatusCode = StatusCode(tmp)
byts, err = readBytesLimited(br, '\r', 255)
if err != nil {