mirror of https://github.com/FreeRDP/FreeRDP
wClipboard: track sequence numbers of file lists
One important point in the cliprdr protocol is that the peers are not allowed to request file sizes and ranges if the clipboard content changes. File locking should be used to gain this ability. However, our file list is still accessible after new data is set into wClipboard. Catch this error by storing the sequence number of the file list when it is set and checking that it is still in effect at the time when the client requests file sizes or ranges. There is a small chance of false positives when the sequence number overflows, but I guess we can safely ignore it.
This commit is contained in:
parent
092e870d2a
commit
458c042b53
|
@ -63,6 +63,7 @@ struct _wClipboard
|
|||
/* clipboard file handling */
|
||||
|
||||
wArrayList* localFiles;
|
||||
UINT32 fileListSequenceNumber;
|
||||
|
||||
wClipboardDelegate delegate;
|
||||
|
||||
|
|
|
@ -573,6 +573,8 @@ static void* convert_uri_list_to_filedescriptors(wClipboard* clipboard, UINT32 f
|
|||
|
||||
*pSize = ArrayList_Count(clipboard->localFiles) * sizeof(FILEDESCRIPTOR);
|
||||
|
||||
clipboard->fileListSequenceNumber = clipboard->sequenceNumber;
|
||||
|
||||
return descriptors;
|
||||
}
|
||||
|
||||
|
@ -632,6 +634,9 @@ static UINT posix_file_request_size(wClipboardDelegate* delegate,
|
|||
if (!delegate || !delegate->clipboard || !request)
|
||||
return ERROR_BAD_ARGUMENTS;
|
||||
|
||||
if (delegate->clipboard->sequenceNumber != delegate->clipboard->fileListSequenceNumber)
|
||||
return ERROR_INVALID_STATE;
|
||||
|
||||
file = ArrayList_GetItem(delegate->clipboard->localFiles, request->listIndex);
|
||||
if (!file)
|
||||
return ERROR_INDEX_ABSENT;
|
||||
|
@ -807,6 +812,9 @@ static UINT posix_file_request_range(wClipboardDelegate* delegate,
|
|||
if (!delegate || !delegate->clipboard || !request)
|
||||
return ERROR_BAD_ARGUMENTS;
|
||||
|
||||
if (delegate->clipboard->sequenceNumber != delegate->clipboard->fileListSequenceNumber)
|
||||
return ERROR_INVALID_STATE;
|
||||
|
||||
file = ArrayList_GetItem(delegate->clipboard->localFiles, request->listIndex);
|
||||
if (!file)
|
||||
return ERROR_INDEX_ABSENT;
|
||||
|
|
Loading…
Reference in New Issue