fix(proto): reject packet lengths usize cannot represent

This commit is contained in:
Nils Andreas Svee committed 2026-08-12 20:05:01 +07:00
1 parent c833b0663d
commit 3845142d30
11 files changed
+102 -42

No files matched your search

@@ -1,8 +1,8 @@
use super::*;
pub(crate) use irtt_proto::echo_packet_len;
use irtt_proto::{
encode_echo_reply, encode_open_reply, flags::FLAG_OPEN, flags::FLAG_REPLY,
layout::PacketLayout, Clock, EchoReply, OpenReply, ReceivedStats, StampAt,
echo_packet_len as checked_echo_packet_len, encode_echo_reply, encode_open_reply,
flags::FLAG_OPEN, flags::FLAG_REPLY, layout::PacketLayout, Clock, EchoReply, OpenReply,
ReceivedStats, StampAt,
};
use std::{
net::UdpSocket,
@@ -72,6 +72,12 @@ pub(super) fn open_reply(
.unwrap()
}
/// Test params always name a representable length, so the platform
/// representability check cannot fire here.
pub(crate) fn echo_packet_len(hmac: bool, params: &Params) -> usize {
checked_echo_packet_len(hmac, params).expect("test params must have a representable length")
}
pub(super) fn echo_reply_packet(
token: u64,
seq: u32,