mirror of
https://github.com/apple/swift-nio-http2
synced 2026-11-25 04:47:50 +00:00
Motivation: We discovered that this code path can result in an arithmetic overflow in the case where the content-length header has INT_MIN value. Since negative content-lengths don't have any meaning anyway we may as well throw if we encounter one so the decoding can be aborted. Modifications: * ContentLengthVerifier init throws a `ContentLengthHeaderNegative` error when the decoded value is < 0. * ContentLengthVerifier init throws a `ContentLengthHeaderMalformedValue` error when the value cannot be decoded, e.g. it is out of bounds for Int or is an invalid string. Result: We will no longer panic for INT_MIN content-lengths and will fail decoding if one of various invalid values is encountered.