Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed fragment data size in IPv6 defragmentation #4228

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion scapy/layers/inet6.py
Original file line number Diff line number Diff line change
Expand Up @@ -1133,13 +1133,17 @@ def defragment6(packets):

# regenerate the fragmentable part
fragmentable = b""
frag_hdr_len = len(IPv6ExtHdrFragment)
for p in res:
q = p[IPv6ExtHdrFragment]
offset = 8 * q.offset
if offset != len(fragmentable):
warning("Expected an offset of %d. Found %d. Padding with XXXX" % (len(fragmentable), offset)) # noqa: E501
frag_data_len = p[IPv6].plen
if frag_data_len is not None:
frag_data_len -= frag_hdr_len
fragmentable += b"X" * (offset - len(fragmentable))
fragmentable += raw(q.payload)
fragmentable += raw(q.payload)[:frag_data_len]

# Regenerate the unfragmentable part.
q = res[0].copy()
Expand Down
Loading