From 9f2861fdbd61da5a24dba77dd0a15b8365ea9681 Mon Sep 17 00:00:00 2001
From: Pierre LALET <pierre.lalet@cea.fr>
Date: Fri, 23 Dec 2016 01:14:12 +0100
Subject: [PATCH] Preserve .overloaded_fields in .clone_with()

This fixes at least an issue fragmentation (for which a new test
has been added)
---
 scapy/packet.py     | 1 +
 test/regression.uts | 6 ++++++
 2 files changed, 7 insertions(+)

diff --git a/scapy/packet.py b/scapy/packet.py
index fba95693..6453f04a 100644
--- a/scapy/packet.py
+++ b/scapy/packet.py
@@ -656,6 +656,7 @@ Creates an EPS file describing a packet. If filename is not provided a temporary
         pkt.explicit = 1
         pkt.fields = kargs
         pkt.default_fields = self.copy_fields_dict(self.default_fields)
+        pkt.overloaded_fields = self.overloaded_fields.copy()
         pkt.time = self.time
         pkt.underlayer = self.underlayer
         pkt.post_transforms = self.post_transforms
diff --git a/test/regression.uts b/test/regression.uts
index fe8461df..f4f410ff 100644
--- a/test/regression.uts
+++ b/test/regression.uts
@@ -4781,6 +4781,12 @@ assert frags[-1].flags == 0
 assert all(len(p.payload) == 8 for p in frags[:-1])
 assert len(frags[-1].payload) == ((payloadlen % fragsize) or fragsize)
 
+= fragment() and overloaded_fields
+pkt1 = Ether() / IP() / UDP()
+pkt2 = fragment(pkt1)[0]
+pkt3 = pkt2.__class__(str(pkt2))
+assert pkt1[IP].proto == pkt2[IP].proto == pkt3[IP].proto
+
 = defragment()
 defrags = defragment(frags)
 * we should have one single packet
-- 
GitLab