diff options
author | Pierre Ossman <ossman@cendio.se> | 2011-05-26 15:39:41 +0000 |
---|---|---|
committer | Pierre Ossman <ossman@cendio.se> | 2011-05-26 15:39:41 +0000 |
commit | 689c45814dc9f954f8d8d36444203231d0803739 (patch) | |
tree | 185c513ed66f7df4ba65d6c647289a676d939c64 /vncviewer | |
parent | 63ca58e007e6f93f9f7e67d3a25716f6f1483d7f (diff) | |
download | tigervnc-689c45814dc9f954f8d8d36444203231d0803739.tar.gz tigervnc-689c45814dc9f954f8d8d36444203231d0803739.zip |
Make sure we can handle clipboard data of any size.
git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@4454 3789f03b-4d11-0410-bbf8-ca57d06f2519
Diffstat (limited to 'vncviewer')
-rw-r--r-- | vncviewer/CConn.cxx | 19 | ||||
-rw-r--r-- | vncviewer/Viewport.cxx | 17 |
2 files changed, 24 insertions, 12 deletions
diff --git a/vncviewer/CConn.cxx b/vncviewer/CConn.cxx index 28c8abbc..bc7b9489 100644 --- a/vncviewer/CConn.cxx +++ b/vncviewer/CConn.cxx @@ -339,18 +339,25 @@ void CConn::bell() void CConn::serverCutText(const char* str, rdr::U32 len) { - char buffer[1024]; - int ret; + char *buffer; + int size, ret; - ret = fl_utf8froma(buffer, sizeof(buffer), str, len); - if (ret >= sizeof(buffer)) { - vlog.error(_("Clipboard buffer overflow!")); + size = fl_utf8froma(NULL, 0, str, len); + if (size <= 0) return; - } + + size++; + + buffer = new char[size]; + + ret = fl_utf8froma(buffer, size, str, len); + assert(ret < size); vlog.debug("Got clipboard data: '%s'", buffer); Fl::copy(buffer, ret, 1); + + delete [] buffer; } // We start timing on beginRect and stop timing on endRect, to diff --git a/vncviewer/Viewport.cxx b/vncviewer/Viewport.cxx index f522ca0d..91daf9ea 100644 --- a/vncviewer/Viewport.cxx +++ b/vncviewer/Viewport.cxx @@ -192,22 +192,27 @@ void Viewport::draw() int Viewport::handle(int event) { - char buffer[1024]; + char *buffer; int ret; int buttonMask, wheelMask; DownMap::const_iterator iter; switch (event) { case FL_PASTE: + buffer = new char[Fl::event_length() + 1]; + // This is documented as to ASCII, but actually does to 8859-1 - ret = fl_utf8toa(Fl::event_text(), Fl::event_length(), buffer, sizeof(buffer)); - if (ret >= sizeof(buffer)) { - vlog.error(_("Clipboard buffer overflow!")); - return 1; - } + ret = fl_utf8toa(Fl::event_text(), Fl::event_length(), buffer, + Fl::event_length() + 1); + assert(ret < (Fl::event_length() + 1)); + vlog.debug("Sending clipboard data: '%s'", buffer); cc->writer()->clientCutText(buffer, ret); + + delete [] buffer; + return 1; + case FL_ENTER: // Yes, we would like some pointer events please! return 1; |