channels/cliprdr: fix CLIPRDR_FILECONTENTS_REQUEST

clipDataId is an optional field of CLIPRDR_FILECONTENTS_REQUEST.
The client should not send it to the server without sending a prior
CLIPRDR_LOCK_CLIPDATA request. The reverse is true as well: the
server should not include these additional 4 bytes without locking
the file in question.

The value zero is a valid ID, it cannot be used as a sentinel value.
Introduce a separate flag to tell whether the clipDataId has been set
and can be relied upon.

Also fix formatting. These stupid line breaks have negative impact on
readability, and the lines do fit into the 100 column limit either way.
This commit is contained in:
ilammy 2017-04-09 02:29:51 +03:00
parent b9ab82214a
commit ef4421fc77
2 changed files with 15 additions and 12 deletions

View File

@ -321,6 +321,8 @@ static UINT cliprdr_process_filecontents_request(cliprdrPlugin* cliprdr,
request.msgType = CB_FILECONTENTS_REQUEST;
request.msgFlags = flags;
request.dataLen = length;
request.haveClipDataId = FALSE;
Stream_Read_UINT32(s, request.streamId); /* streamId (4 bytes) */
Stream_Read_UINT32(s, request.listIndex); /* listIndex (4 bytes) */
Stream_Read_UINT32(s, request.dwFlags); /* dwFlags (4 bytes) */
@ -329,9 +331,10 @@ static UINT cliprdr_process_filecontents_request(cliprdrPlugin* cliprdr,
Stream_Read_UINT32(s, request.cbRequested); /* cbRequested (4 bytes) */
if (Stream_GetRemainingLength(s) >= 4)
{
Stream_Read_UINT32(s, request.clipDataId); /* clipDataId (4 bytes) */
else
request.clipDataId = 0;
request.haveClipDataId = TRUE;
}
IFCALLRET(context->ServerFileContentsRequest, error, context, &request);
@ -900,20 +903,19 @@ static UINT cliprdr_client_file_contents_request(CliprdrClientContext* context,
}
Stream_Write_UINT32(s, fileContentsRequest->streamId); /* streamId (4 bytes) */
Stream_Write_UINT32(s,
fileContentsRequest->listIndex); /* listIndex (4 bytes) */
Stream_Write_UINT32(s, fileContentsRequest->listIndex); /* listIndex (4 bytes) */
Stream_Write_UINT32(s, fileContentsRequest->dwFlags); /* dwFlags (4 bytes) */
Stream_Write_UINT32(s,
fileContentsRequest->nPositionLow); /* nPositionLow (4 bytes) */
Stream_Write_UINT32(s,
fileContentsRequest->nPositionHigh); /* nPositionHigh (4 bytes) */
Stream_Write_UINT32(s,
fileContentsRequest->cbRequested); /* cbRequested (4 bytes) */
Stream_Write_UINT32(s,
fileContentsRequest->clipDataId); /* clipDataId (4 bytes) */
Stream_Write_UINT32(s, fileContentsRequest->nPositionLow); /* nPositionLow (4 bytes) */
Stream_Write_UINT32(s, fileContentsRequest->nPositionHigh); /* nPositionHigh (4 bytes) */
Stream_Write_UINT32(s, fileContentsRequest->cbRequested); /* cbRequested (4 bytes) */
if (fileContentsRequest->haveClipDataId)
Stream_Write_UINT32(s, fileContentsRequest->clipDataId); /* clipDataId (4 bytes) */
WLog_Print(cliprdr->log, WLOG_DEBUG,
"ClientFileContentsRequest: streamId: 0x%08"PRIX32"",
fileContentsRequest->streamId);
return cliprdr_packet_send(cliprdr, s);
}

View File

@ -217,6 +217,7 @@ struct _CLIPRDR_FILE_CONTENTS_REQUEST
UINT32 nPositionLow;
UINT32 nPositionHigh;
UINT32 cbRequested;
BOOL haveClipDataId;
UINT32 clipDataId;
};
typedef struct _CLIPRDR_FILE_CONTENTS_REQUEST CLIPRDR_FILE_CONTENTS_REQUEST;