Skip to content

Fix IP defragmentation regression introduced in commit 219f2febd - #5256

Open
ParksProjets wants to merge 1 commit into
secdev:masterfrom
ParksProjets:fix-ip-degramentation
Open

ParksProjets wants to merge 1 commit into
secdev:masterfrom
ParksProjets:fix-ip-degramentation

Conversation

@ParksProjets

Copy link
Copy Markdown

This PR fixes regressions introduced by cleanup commit 219f2fe (PR #4082). It broke IP defragmentation functions (defrag() and defragment()) in the following ways:

  • Disordered fragments cause the functions to fail when the last fragment was not the last packet in the list. Before the cleanup, fragments handled in two passes: they were first sorted by ID, then defragmented. Now they are defragmentated 'on-the-flow', when the last fragment is found. However, if there were disordered fragments after the LF one, they were not considered and defragmentation failed.

  • Packets with missing framgments, where the LF fragment was also missing, were not returned by defrag() as bad fragments.

  • The bad fragments list returned by defrag() function was a list of tuple instead ofa list of packets.

These issues were not present in scapy 2.5.0.

Final note: I wrote this commit in a "quick-and-dirty" way; you can rewrite it if you don't like the code, as long as these issues are fixed.

The cleanup commit 219f2fe broke IP defragmentation functions in the
following ways:
  - Disordered fragments cause failure when last fragment was not the
    last packet in the list.
  - Bad fragmented packets were not returned when last fragment packet
    was not present.
  - "badfrag" was a list of tuple, instead of a list of packets

AI-Assisted: no
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