summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJon Turney <jon.turney@dronecode.org.uk>2015-11-19 18:06:28 +0000
committerJon Turney <jon.turney@dronecode.org.uk>2016-11-17 13:15:44 +0000
commit694371a8220d9ce6bd94ff4fb9cd341f4ae61576 (patch)
tree6790bd2c5ca4d89352c28041161cfa508d72fc13
parent87bb128632f8a0aed43e540667967d1ab5ce192f (diff)
Warn about too large Windows -> X clipboard pastes
XChangeProperty() requests larger than the ~16MB permitted even with BigReq will fail BadLength
-rw-r--r--hw/xwin/winclipboard/xevents.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/hw/xwin/winclipboard/xevents.c b/hw/xwin/winclipboard/xevents.c
index 4f7708762..a7c21b481 100644
--- a/hw/xwin/winclipboard/xevents.c
+++ b/hw/xwin/winclipboard/xevents.c
@@ -691,6 +691,24 @@ winClipboardFlushXEvents(HWND hwnd,
free(pszConvertData);
pszConvertData = NULL;
+ /* data will fit into a single X request (INCR not yet supported) */
+ {
+ long unsigned int maxreqsize = XExtendedMaxRequestSize(pDisplay);
+ if (maxreqsize == 0)
+ maxreqsize = XMaxRequestSize(pDisplay);
+
+ /* covert to bytes and allow for allow for X_ChangeProperty request */
+ maxreqsize = maxreqsize*4 - 24;
+
+ if (xtpText.nitems > maxreqsize) {
+ ErrorF("winClipboardFlushXEvents - clipboard data size %lu greater than maximum %lu\n", xtpText.nitems, maxreqsize);
+
+ /* Abort */
+ fAbort = TRUE;
+ goto winClipboardFlushXEvents_SelectionRequest_Done;
+ }
+ }
+
/* Copy the clipboard text to the requesting window */
iReturn = XChangeProperty(pDisplay,
event.xselectionrequest.requestor,