Skip to content

Commit

Permalink
Server: truncate, don't ignore CB updates > max
Browse files Browse the repository at this point in the history
  • Loading branch information
dcommander committed Oct 22, 2015
1 parent 3d2f494 commit 702648e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
4 changes: 4 additions & 0 deletions ChangeLog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ The TurboVNC Server and Java TurboVNC Viewer now allow the maximum clipboard
transfer size to be specified, by way of a new Xvnc argument (-maxclipboard)
and a new viewer parameter (MaxClipboard).
-------------------------------------------------------------------------------
[14]
The TurboVNC Server now truncates clipboard updates larger than the max.
clipboard size instead of ignoring them.
-------------------------------------------------------------------------------


===============================================================================
Expand Down
24 changes: 16 additions & 8 deletions unix/Xvnc/programs/Xserver/hw/vnc/rfbserver.c
Original file line number Diff line number Diff line change
Expand Up @@ -1218,6 +1218,8 @@ rfbProcessClientNormalMessage(rfbClientPtr cl)


case rfbClientCutText:
{
int ignoredBytes = 0;

if ((n = ReadExact(cl, ((char *)&msg) + 1,
sz_rfbClientCutTextMsg - 1)) <= 0) {
Expand All @@ -1229,15 +1231,10 @@ rfbProcessClientNormalMessage(rfbClientPtr cl)

msg.cct.length = Swap32IfLE(msg.cct.length);
if (msg.cct.length > rfbMaxClipboard) {
rfbLog("Ignoring %d-byte clipboard update from client. Max is %d bytes.\n",
rfbLog("Truncating %d-byte clipboard update to %d bytes.\n",
msg.cct.length, rfbMaxClipboard);
if ((n = SkipExact(cl, msg.cct.length)) <= 0) {
if (n != 0)
rfbLogPerror("rfbProcessClientNormalMessage: read");
rfbCloseClient(cl);
return;
}
return;
ignoredBytes = msg.cct.length - rfbMaxClipboard;
msg.cct.length = rfbMaxClipboard;
}

if (msg.cct.length <= 0) return;
Expand All @@ -1256,6 +1253,16 @@ rfbProcessClientNormalMessage(rfbClientPtr cl)
return;
}

if (ignoredBytes > 0) {
if ((n = SkipExact(cl, ignoredBytes)) <= 0) {
if (n != 0)
rfbLogPerror("rfbProcessClientNormalMessage: read");
free(str);
rfbCloseClient(cl);
return;
}
}

/* NOTE: We do not accept cut text from a view-only client */
if (!rfbViewOnly && !cl->viewOnly && !rfbAuthDisableCBRecv) {
vncClientCutText(str, msg.cct.length);
Expand All @@ -1264,6 +1271,7 @@ rfbProcessClientNormalMessage(rfbClientPtr cl)

free(str);
return;
}

case rfbEnableContinuousUpdates:
{
Expand Down

0 comments on commit 702648e

Please sign in to comment.