From c554bc7aa1de2fc697a96ad94fd9cdf444b0dd92 Mon Sep 17 00:00:00 2001 From: agnosticdev Date: Mon, 13 Jul 2026 17:35:59 -0700 Subject: [PATCH 1/2] Fixing a leak in IPv4 Reassembly --- Sources/SwiftNetwork/Protocols/IPProtocol.swift | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Sources/SwiftNetwork/Protocols/IPProtocol.swift b/Sources/SwiftNetwork/Protocols/IPProtocol.swift index 00d0633..adea77a 100644 --- a/Sources/SwiftNetwork/Protocols/IPProtocol.swift +++ b/Sources/SwiftNetwork/Protocols/IPProtocol.swift @@ -656,6 +656,9 @@ public struct IPProtocol: NetworkProtocol { "Dropping \(dropped) incomplete fragments for IP ID \(reassemblyState?.reassemblyID ?? 0)" ) } + } else if forceFlush && reassemblyState?.inputReassemblyFrames.count == 0 { + // If all of our fragments have been process wipe out the reassemblyState + reassemblyState = nil } } // Only update the stored reassembly ID when processing a real fragment and not on force flush @@ -890,13 +893,13 @@ public struct IPProtocol: NetworkProtocol { sorted.add(frame: remaining) } } - reassemblyState?.inputReassemblyFrames = sorted + reassemblyState?.inputReassemblyFrames.add(frames: sorted) } self.counters.rxPackets += 1 } processReassembly(log, ipID: 0, reassembled: &reassembledFragments, forceFlush: true) processedFrames.add(frames: reassembledFragments) - inboundFrames = processedFrames + inboundFrames.add(frames: processedFrames) } func prepareOutboundFrames(_ outboundFrames: inout FrameArray) { From ecc0aca59fd1e6d5232219ad8b65bd336c249277 Mon Sep 17 00:00:00 2001 From: agnosticdev Date: Tue, 14 Jul 2026 06:21:02 -0700 Subject: [PATCH 2/2] Fix wording --- Sources/SwiftNetwork/Protocols/IPProtocol.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/SwiftNetwork/Protocols/IPProtocol.swift b/Sources/SwiftNetwork/Protocols/IPProtocol.swift index adea77a..c7c4464 100644 --- a/Sources/SwiftNetwork/Protocols/IPProtocol.swift +++ b/Sources/SwiftNetwork/Protocols/IPProtocol.swift @@ -657,7 +657,7 @@ public struct IPProtocol: NetworkProtocol { ) } } else if forceFlush && reassemblyState?.inputReassemblyFrames.count == 0 { - // If all of our fragments have been process wipe out the reassemblyState + // If all of our fragments have been processed wipe out the reassemblyState reassemblyState = nil } }