diff options
author | Pierre Ossman <ossman@cendio.se> | 2023-06-30 22:33:47 +0200 |
---|---|---|
committer | Pierre Ossman <ossman@cendio.se> | 2023-06-30 22:33:47 +0200 |
commit | 9ca100d4636733a84c92b0ee81c9d3bef11fdf91 (patch) | |
tree | b1d08053864582e5b2bad81e4cd5b1d5b795bf6c /unix | |
parent | 7b3fe6d283f917bff99a60e2bdc59c98c82b1dfa (diff) | |
parent | 94d6a693eac3401c50723ccc75aa11fc7017782d (diff) | |
download | tigervnc-9ca100d4636733a84c92b0ee81c9d3bef11fdf91.tar.gz tigervnc-9ca100d4636733a84c92b0ee81c9d3bef11fdf91.zip |
Merge branch 'types2' of https://github.com/CendioOssman/tigervnc
Diffstat (limited to 'unix')
-rw-r--r-- | unix/xserver/hw/vnc/RFBGlue.cc | 9 | ||||
-rw-r--r-- | unix/xserver/hw/vnc/RFBGlue.h | 2 | ||||
-rw-r--r-- | unix/xserver/hw/vnc/vncSelection.c | 5 |
3 files changed, 16 insertions, 0 deletions
diff --git a/unix/xserver/hw/vnc/RFBGlue.cc b/unix/xserver/hw/vnc/RFBGlue.cc index 2fbc27ee..25431b65 100644 --- a/unix/xserver/hw/vnc/RFBGlue.cc +++ b/unix/xserver/hw/vnc/RFBGlue.cc @@ -248,3 +248,12 @@ char* vncUTF8ToLatin1(const char* src, size_t bytes) return NULL; } } + +int vncIsValidUTF8(const char* str, size_t bytes) +{ + try { + return isValidUTF8(str, bytes); + } catch (...) { + return 0; + } +} diff --git a/unix/xserver/hw/vnc/RFBGlue.h b/unix/xserver/hw/vnc/RFBGlue.h index d2b2e8aa..30c13bd2 100644 --- a/unix/xserver/hw/vnc/RFBGlue.h +++ b/unix/xserver/hw/vnc/RFBGlue.h @@ -53,6 +53,8 @@ char* vncConvertLF(const char* src, size_t bytes); char* vncLatin1ToUTF8(const char* src, size_t bytes); char* vncUTF8ToLatin1(const char* src, size_t bytes); +int vncIsValidUTF8(const char* str, size_t bytes); + #ifdef __cplusplus } #endif diff --git a/unix/xserver/hw/vnc/vncSelection.c b/unix/xserver/hw/vnc/vncSelection.c index 1ed35149..f7f3c51d 100644 --- a/unix/xserver/hw/vnc/vncSelection.c +++ b/unix/xserver/hw/vnc/vncSelection.c @@ -611,6 +611,11 @@ static void vncHandleSelection(Atom selection, Atom target, if (prop->type != xaUTF8_STRING) return; + if (!vncIsValidUTF8(prop->data, prop->size)) { + LOG_ERROR("Invalid UTF-8 sequence in clipboard"); + return; + } + filtered = vncConvertLF(prop->data, prop->size); if (filtered == NULL) return; |