From d7010cd93a381f1fc0cc681ddb70df9371370644 Mon Sep 17 00:00:00 2001 From: Jon Turney Date: Thu, 19 Nov 2015 18:06:28 +0000 Subject: [PATCH] hw/xwin: Warn about too large Windows -> X clipboard pastes XChangeProperty() requests larger than the ~16MB permitted even with BigReq will fail BadLength --- hw/xwin/winclipboard/xevents.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/hw/xwin/winclipboard/xevents.c b/hw/xwin/winclipboard/xevents.c index 61d805011..7d55f3d92 100644 --- a/hw/xwin/winclipboard/xevents.c +++ b/hw/xwin/winclipboard/xevents.c @@ -690,6 +690,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,