Fix server-to-client clipboard (CLIPRDR) for RDP clients
Summary
The server-to-client clipboard direction was non-functional — when copying text on the server, RDP clients never received the clipboard update. This fixes multiple issues in the CLIPRDR channel implementation:
-
Send
ServerFormatListResponseto acknowledge the client's initial format list. Without this, clients (e.g. Microsoft Remote Desktop) consider the clipboard channel incomplete and ignore all subsequentServerFormatListmessages from the server. This was the primary cause of the breakage. -
Set
useLongFormatNames = TRUEto enable proper format name negotiation with modern RDP clients. -
Zero-initialize
CLIPRDR_FORMATstruct insendServerData()— previously allocated withmalloc(), leavingformatNameas a garbage pointer instead ofnullptr. -
Send
CB_RESPONSE_FAILinonClientFormatDataRequest()when the requested format is unsupported, instead of silently returning (CLIPRDR protocol requires a response). - Include null terminator in CF_UNICODETEXT response data.
- Remove outdated TODO comment in
Clipboard.h.
Test plan
- Connect from an RDP client (e.g. Microsoft Remote Desktop on macOS)
- Copy text in a KDE application on the server
- Verify the text can be pasted on the client side
- Copy text on the client side
- Verify the text can be pasted in a KDE application on the server
- Verify bidirectional clipboard works across multiple copy/paste cycles
Edited by realies