Repository navigation
Reject IPv4 fragments and invalid packet lengths - #39
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fragmented captures currently corrupt UDP payloads: the first fragment's UDP length describes the entire datagram, so
sendtoreads beyond the captured fragment. Later fragments are incorrectly interpreted as containing new UDP headers. A 3,000-byte ASCII payload reproduces corruption at byte 1,472 and an ASan heap-buffer-overflow.This stops replay with a clear error on UDP IPv4 fragments (MF or nonzero offset) before reading a UDP header. It validates captured/original lengths, Ethernet/VLAN headers, IPv4 IHL/total length, and UDP header/length before sending. Packet headers are copied into aligned locals, and libpcap read errors are reported rather than treated as EOF. Valid large datagrams, IP options, VLAN tags, and Ethernet padding remain supported.
Added generated-capture regression tests for fragment variants, the original MTU reproducer, malformed/truncated lengths, valid large/maximum UDP payloads, empty UDP, IP options, and VLANs. Packet tests run in Linux and macOS CI; Linux timing tests remain enabled. The README documents fragment rejection and external reassembly with IPDefragUtil.
Validation: GCC Release and Clang Debug builds with warnings as errors passed all six CTest tests. Clang ASan/UBSan packet checks passed with leak detection enabled; the original reproducer now fails safely with the fragment diagnostic. The regression suite fails on the original code. Actionlint, installation, and
git diff --checkpassed. Native macOS validation awaits CI; its smaller OS UDP limit is allowed only for the valid maximum-size send test.Closes #36.