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.
This commit is contained in:
matt335672 2024-08-02 11:57:50 +01:00
parent 34b5582460
commit 0f6e731524
1 changed files with 5 additions and 3 deletions

View File

@ -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);