Skip to content

Commit 46600c3

Browse files
committed
fix(netwatch): guard divide-by-zero in poll_recv_noq trace
`UdpSocket::poll_recv_noq` evaluated `meta.len / meta.stride` directly inside `trace!()` macro arguments. `noq_udp::RecvMeta.stride` is allowed to be `0` in practice on the GRO path (empty datagrams, kernel falling back to a non-segmented receive), which crashes the host process with `attempt to divide by zero` — observed on Windows 11 24H2 and macOS 15.4/26.x against netwatch 0.16.0/0.17.0. Replace the bare division with `checked_div(...).unwrap_or(0)` so the trace field reports `0` when `stride == 0` and stays identical otherwise. Closes #148.
1 parent 7c952d5 commit 46600c3

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

netwatch/src/udp.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@ impl UdpSocket {
433433
trace!(
434434
src = %meta.addr,
435435
len = meta.len,
436-
count = meta.len / meta.stride,
436+
count = meta.len.checked_div(meta.stride).unwrap_or(0),
437437
dst = %meta.dst_ip.map(|x| x.to_string()).unwrap_or_default(),
438438
"UDP recv"
439439
);

0 commit comments

Comments
 (0)