From ba5a535891d8e13f71efbb8c14307c59bb80a5e3 Mon Sep 17 00:00:00 2001 From: rustdesk Date: Sat, 4 Jul 2026 18:08:55 +0800 Subject: [PATCH] key the responder stream cache on connID as well as streamId Per-stream ids restart from 1 in each peer process, so two connections can emit the same streamId. The process-static pStreamStc cache keyed only on streamId could then serve one peer the IStream cached for another peer (a different file), silently returning wrong-file bytes. Add connID to the key. Co-Authored-By: Claude Fable 5 --- libs/clipboard/src/windows/wf_cliprdr.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/libs/clipboard/src/windows/wf_cliprdr.c b/libs/clipboard/src/windows/wf_cliprdr.c index eab22e614..b731f8899 100644 --- a/libs/clipboard/src/windows/wf_cliprdr.c +++ b/libs/clipboard/src/windows/wf_cliprdr.c @@ -3152,6 +3152,10 @@ wf_cliprdr_server_file_contents_request(CliprdrClientContext *context, BOOL bIsStreamFile = TRUE; static LPSTREAM pStreamStc = NULL; static UINT32 uStreamIdStc = 0; + // streamId is only unique within one connection; different peers restart their + // stream-id counter, so the cache must also key on connID or a request from one + // peer could be served another peer's cached stream. + static UINT32 uConnIdStc = 0; wfClipboard *clipboard; UINT rc = ERROR_INTERNAL_ERROR; UINT sRc; @@ -3225,7 +3229,8 @@ wf_cliprdr_server_file_contents_request(CliprdrClientContext *context, vFormatEtc.lindex = fileContentsRequest->listIndex; vFormatEtc.ptd = NULL; - if ((uStreamIdStc != fileContentsRequest->streamId) || !pStreamStc) + if ((uStreamIdStc != fileContentsRequest->streamId) || + (uConnIdStc != fileContentsRequest->connID) || !pStreamStc) { LPENUMFORMATETC pEnumFormatEtc; ULONG CeltFetched; @@ -3256,6 +3261,7 @@ wf_cliprdr_server_file_contents_request(CliprdrClientContext *context, { pStreamStc = vStgMedium.pstm; uStreamIdStc = fileContentsRequest->streamId; + uConnIdStc = fileContentsRequest->connID; bIsStreamFile = TRUE; }