◐ Shell
clean mode source ↗

Fix setting identifier truncation in SettingsFrame.serialize_body by bysiber · Pull Request #167 · python-hyper/hyperframe

and others added 2 commits

February 20, 2026 18:42
The bitmask `setting & 0xFF` truncates the 16-bit setting identifier
to only 8 bits. This silently corrupts any setting ID above 255 during
serialization.

The identifier field in SETTINGS frames is 16 bits wide (RFC 9113,
Section 6.5.1), and `_STRUCT_HL` already uses the `H` format
(unsigned short, 16 bits) for it. However, `& 0xFF` discards the
upper byte.

For the standard settings (0x01 through 0x08) this has no visible
effect since they all fit in 8 bits. But RFC 8701 GREASE values like
0x0a0a or 0x1a1a, as well as any future extension settings > 0xFF,
would be silently mangled on a serialize round-trip.

Change the mask to `& 0xFFFF` to match the actual field width.