pub fn bytestring_from_reader<R: Read>(
r: &mut R,
max_bytes_to_read: u64,
) -> Result<Vec<u8>>Expand description
Reads a length-prefixed byte string from a reader, rejecting lengths
above max_bytes_to_read. Every caller must pass an explicit cap
sized to the protocol context (typically MAX_L2_MESSAGE_SIZE) so
an attacker-controlled length prefix can’t trigger a huge pre-allocation.