From 2135f7d7f92e43f47bc9895b68837b60bcf9fda9 Mon Sep 17 00:00:00 2001 From: Roman Ettlinger Date: Mon, 19 Oct 2026 14:19:46 +0200 Subject: [PATCH] Secure channel: seal symmetric chunks in place SealSymmetricMessage copied the encoded chunks into a second BufferCollection. The chunks are now replaced in place by the segments to send, which are over the same buffers, so the encoded collection is the one sent. Co-Authored-By: Claude Opus 5.5 --- src/Opc.Ua.Core/Stack/Tcp/UaSCBinaryChannel.Symmetric.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Opc.Ua.Core/Stack/Tcp/UaSCBinaryChannel.Symmetric.cs b/src/Opc.Ua.Core/Stack/Tcp/UaSCBinaryChannel.Symmetric.cs index ac399fe660..88620c0740 100644 --- a/src/Opc.Ua.Core/Stack/Tcp/UaSCBinaryChannel.Symmetric.cs +++ b/src/Opc.Ua.Core/Stack/Tcp/UaSCBinaryChannel.Symmetric.cs @@ -939,7 +939,8 @@ namespace Opc.Ua.Bindings const int headerSize = TcpMessageLimits.SymmetricHeaderSize + TcpMessageLimits.SequenceHeaderSize; - var chunksToSend = new BufferCollection(chunksToProcess.Count); + // the chunks are secured in place: each body segment is replaced by the + // segment to send, which covers the headers in the same buffer. int lastChunk = chunksToProcess.Count - 1; for (int ii = 0; ii < chunksToProcess.Count; ii++) @@ -1028,13 +1029,12 @@ namespace Opc.Ua.Bindings position); } - // add the header into chunk. - chunksToSend.Add(dataToSend); + chunksToProcess[ii] = dataToSend; } // ensure the buffers don't get cleaned up on exit. success = true; - return chunksToSend; + return chunksToProcess; } finally {