Skip to content

Commit

Permalink
clipboard: Allow a file read to return 0 for EOF
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
matt335672 committed Aug 2, 2024
1 parent 34b5582 commit 0f6e731
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions sesman/chansrv/clipboard_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 0f6e731

Please sign in to comment.