diff options
Diffstat (limited to 'unix/xserver/hw')
-rw-r--r-- | unix/xserver/hw/vnc/RFBGlue.cc | 16 | ||||
-rw-r--r-- | unix/xserver/hw/vnc/RFBGlue.h | 5 | ||||
-rw-r--r-- | unix/xserver/hw/vnc/vncSelection.c | 22 |
3 files changed, 37 insertions, 6 deletions
diff --git a/unix/xserver/hw/vnc/RFBGlue.cc b/unix/xserver/hw/vnc/RFBGlue.cc index 160177bd..d9c456e8 100644 --- a/unix/xserver/hw/vnc/RFBGlue.cc +++ b/unix/xserver/hw/vnc/RFBGlue.cc @@ -1,5 +1,5 @@ /* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved. - * Copyright 2011-2015 Pierre Ossman for Cendio AB + * Copyright 2011-2019 Pierre Ossman for Cendio AB * * This is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -210,3 +210,17 @@ int vncIsTCPPortUsed(int port) } return 0; } + +char* vncConvertLF(const char* src, size_t bytes) +{ + try { + return convertLF(src, bytes); + } catch (...) { + return NULL; + } +} + +void vncStrFree(char* str) +{ + strFree(str); +} diff --git a/unix/xserver/hw/vnc/RFBGlue.h b/unix/xserver/hw/vnc/RFBGlue.h index a63afd07..8e70c680 100644 --- a/unix/xserver/hw/vnc/RFBGlue.h +++ b/unix/xserver/hw/vnc/RFBGlue.h @@ -1,5 +1,5 @@ /* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved. - * Copyright 2011-2015 Pierre Ossman for Cendio AB + * Copyright 2011-2019 Pierre Ossman for Cendio AB * * This is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -49,6 +49,9 @@ void vncListParams(int width, int nameWidth); int vncGetSocketPort(int fd); int vncIsTCPPortUsed(int port); +char* vncConvertLF(const char* src, size_t bytes); +void vncStrFree(char* str); + #ifdef __cplusplus } #endif diff --git a/unix/xserver/hw/vnc/vncSelection.c b/unix/xserver/hw/vnc/vncSelection.c index 4f3538d4..5ddcaf00 100644 --- a/unix/xserver/hw/vnc/vncSelection.c +++ b/unix/xserver/hw/vnc/vncSelection.c @@ -1,4 +1,4 @@ -/* Copyright 2016 Pierre Ossman for Cendio AB +/* Copyright 2016-2019 Pierre Ossman for Cendio AB * * This is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -415,13 +415,22 @@ static void vncHandleSelection(Atom selection, Atom target, else if (vncHasAtom(xaUTF8_STRING, (const Atom*)prop->data, prop->size)) vncSelectionRequest(selection, xaUTF8_STRING); } else if (target == xaSTRING) { + char* filtered; + if (prop->format != 8) return; if (prop->type != xaSTRING) return; - vncServerCutText(prop->data, prop->size); + filtered = vncConvertLF(prop->data, prop->size); + if (filtered == NULL) + return; + + vncServerCutText(filtered, strlen(filtered)); + + vncStrFree(filtered); } else if (target == xaUTF8_STRING) { + char *filtered; unsigned char* buffer; unsigned char* out; size_t len; @@ -470,9 +479,14 @@ static void vncHandleSelection(Atom selection, Atom target, } } - vncServerCutText((const char*)buffer, len); - + filtered = vncConvertLF(buffer, len); free(buffer); + if (filtered == NULL) + return; + + vncServerCutText(filtered, strlen(filtered)); + + vncStrFree(filtered); } } |