From 0f6e731524262cba375d03db312858a2d2bcebdc Mon Sep 17 00:00:00 2001 From: matt335672 <30179339+matt335672@users.noreply.github.com> Date: Fri, 2 Aug 2024 11:57:50 +0100 Subject: [PATCH] clipboard: Allow a file read to return 0 for EOF When used with a FreeRDP client on Linux, a file copy operation from the clipboard detects end-of-file by a read returning 0 bytes. This is currently marked as an error. It is assumed that mstsc.exe detects end-of-file in another way, which is why this has not been found before. --- sesman/chansrv/clipboard_file.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/sesman/chansrv/clipboard_file.c b/sesman/chansrv/clipboard_file.c index 2d515a77..90fed048 100644 --- a/sesman/chansrv/clipboard_file.c +++ b/sesman/chansrv/clipboard_file.c @@ -538,10 +538,12 @@ clipboard_send_file_data(int streamId, int lindex, make_stream(s); init_stream(s, cbRequested + 64); size = g_file_read(fd, s->data + 12, cbRequested); - if (size < 1) + // If we're at end-of-file, 0 is a valid response + if (size < 0) { - LOG_DEVEL(LOG_LEVEL_ERROR, "clipboard_send_file_data: read error, want %d got %d", - cbRequested, size); + LOG_DEVEL(LOG_LEVEL_ERROR, + "clipboard_send_file_data: read error, want %d got [%s]", + cbRequested, g_get_strerror()); free_stream(s); g_file_close(fd); clipboard_send_filecontents_response_fail(streamId);