Skip to content

Fix ICMP reply decoding robustness#53

Merged
aisk merged 1 commit into
masterfrom
fix-icmp-reply-decoding
Jun 24, 2026
Merged

Fix ICMP reply decoding robustness#53
aisk merged 1 commit into
masterfrom
fix-icmp-reply-decoding

Conversation

@aisk

@aisk aisk commented Jun 24, 2026

Copy link
Copy Markdown
Owner

This fixes two robustness issues in the reply-receiving loop. First, when an incoming IPv4 packet fails to decode (malformed, truncated, or unrelated ICMP traffic delivered on a RAW socket), the loop now skips it and keeps waiting for our own reply instead of aborting the entire ping with an error. This previously caused spurious failures, particularly on Windows where RAW sockets are the default and receive all ICMP traffic on the host.

Second, EchoReply::decode only checked that the buffer was at least HEADER_SIZE (8) bytes before slicing out the 24-byte payload at [8..32], so any buffer between 8 and 31 bytes would panic on an out-of-bounds index. The length check now requires the full header plus payload, and the magic number is replaced with a new PAYLOAD_SIZE constant. The now-unused Error::DecodeV4Error variant is removed as well; note this is a breaking change to the public Error enum.

@aisk aisk merged commit 3ac6ae2 into master Jun 24, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant