mirror of
https://github.com/apple/swift-nio-http2
synced 2026-11-24 04:38:00 +00:00
* Refactor HPACK integer decoding Motivation: The HPACK integer decoding used a number of unchecked operations which can trap on some inputs. Since it is network reachable code, it should throw errors if the operations overflow. Modifications: - Add a failure case to the fuzz testing - Refactor the integer decoding to check for overflow on the arithmetic - This throws a new 'HPACKErrors.UnrepresentableInteger' error on overflow - Add a missing bounds check - Remove an unnecessary and incorrect path - Remove the default argument from the function driving the decoding, the default was not valid and would cause an assertion to fail if used - Return the decoded value as an `Int` rather than a `UInt` - More tests Result: Integer decoding is safer. * Use unchecked shifting * Use truncatingIfNeeded * make error internal