[X2Go-Commits] [x2gokdrive] 01/01: fix crashing if client is sending unrequested selection.
git-admin at x2go.org
git-admin at x2go.org
Thu Feb 18 17:13:59 CET 2021
This is an automated email from the git hooks/post-receive script.
x2go pushed a commit to branch master
in repository x2gokdrive.
commit 6a1569f1c47613b5dcabaf3eee4056b27ee307cb
Author: Oleksandr <oleksandr.shneyder at external.eumetsat.int>
Date: Thu Feb 18 10:13:43 2021 -0600
fix crashing if client is sending unrequested selection.
---
debian/changelog | 1 +
x2gokdriveremote.c | 20 ++++++++++++++------
x2gokdriveremote.h | 1 +
3 files changed, 16 insertions(+), 6 deletions(-)
diff --git a/debian/changelog b/debian/changelog
index c65b49d..b652c50 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -17,6 +17,7 @@ x2gokdrive (0.0.0.1-0x2go1) UNRELEASED; urgency=medium
- support sending and recieving selections on demand. Support reading and writing INCR properties.
- move declaration of RemoteHostVars from x2gokdriveremote.h to x2gokdriveremote.c.
- add some support for HTML5 client (like converting pointer cursors to PNG format).
+ - fix crashing if client is sending unrequested selection.
[ Mihai Moldovan ]
* Initial release:
diff --git a/x2gokdriveremote.c b/x2gokdriveremote.c
index a41cfb4..620332f 100644
--- a/x2gokdriveremote.c
+++ b/x2gokdriveremote.c
@@ -48,6 +48,7 @@ static BOOL remoteInitialized=FALSE;
void remote_selection_init(void)
{
remoteVars.selstruct.readingInputBuffer=-1;
+ remoteVars.selstruct.currentInputBuffer=CLIPBOARD;
selection_init(&remoteVars);
}
@@ -1989,7 +1990,7 @@ void readInputSelectionBuffer(char* buff)
pthread_mutex_lock(&remoteVars.selstruct.inMutex);
- selbuff = &remoteVars.selstruct.inSelection[remoteVars.selstruct.readingInputBuffer];
+ selbuff = &remoteVars.selstruct.inSelection[remoteVars.selstruct.currentInputBuffer];
//if the data is not compressed read it directly to the buffer
if(!selbuff->currentChunkCompressedSize)
@@ -2030,14 +2031,14 @@ void readInputSelectionBuffer(char* buff)
if(selbuff->bytesReady==selbuff->size)
{
//selection buffer received completely
-// EPHYR_DBG("READY Selection %d, MIME %d, Read %d from %d", remoteVars.selstruct.readingInputBuffer, selbuff->mimeData, selbuff->bytesReady, selbuff->size);
+// EPHYR_DBG("READY Selection %d, MIME %d, Read %d from %d", remoteVars.selstruct.currentInputBuffer, selbuff->mimeData, selbuff->bytesReady, selbuff->size);
//send notify to system that we are using selection
//if state is requested we already own this selection after notify
if(selbuff->state != REQUESTED)
- own_selection(remoteVars.selstruct.readingInputBuffer);
+ own_selection(remoteVars.selstruct.currentInputBuffer);
selbuff->state=COMPLETED;
//send notification event to interrupt sleeping selection thread
- client_sel_data_notify(remoteVars.selstruct.readingInputBuffer);
+ client_sel_data_notify(remoteVars.selstruct.currentInputBuffer);
}
//unlock selection
@@ -2080,6 +2081,13 @@ void readInputSelectionHeader(char* buff)
totalSize=size;
}
+ //sanity check
+ if((destination != PRIMARY)&& (destination!= CLIPBOARD))
+ {
+ EPHYR_DBG("WARNING: unsupported destination %d, setting to CLIPBOARD",destination);
+ destination=CLIPBOARD;
+ }
+
EPHYR_DBG("HAVE NEW INCOMING SELECTION Chunk: sel %d size %d mime %d compressed size %d, total %d",destination, size, mime, compressedSize, totalSize);
@@ -2157,7 +2165,7 @@ void readInputSelectionHeader(char* buff)
if(selbuff->currentChunkBytesReady != selbuff->currentChunkSize)
{
// we didn't recieve complete chunk yet, next event will have data
- remoteVars.selstruct.readingInputBuffer=destination;
+ remoteVars.selstruct.currentInputBuffer=remoteVars.selstruct.readingInputBuffer=destination;
}
}
else
@@ -2165,7 +2173,7 @@ void readInputSelectionHeader(char* buff)
if(selbuff->currentChunkBytesReady != selbuff->currentChunkCompressedSize)
{
// we didn't recieve complete chunk yet, next event will have data
- remoteVars.selstruct.readingInputBuffer=destination;
+ remoteVars.selstruct.currentInputBuffer=remoteVars.selstruct.readingInputBuffer=destination;
}
else
{
diff --git a/x2gokdriveremote.h b/x2gokdriveremote.h
index 0b03917..df50d05 100644
--- a/x2gokdriveremote.h
+++ b/x2gokdriveremote.h
@@ -345,6 +345,7 @@ struct SelectionStructure
//Input selection members
int readingInputBuffer; //which selection are reading input buffer at the moments: PRIMARY, CLIPBOARD or -1 if none
+ int currentInputBuffer; //which selection represents input buffer at the moments: PRIMARY or CLIPBOARD
struct InputBuffer inSelection[2]; //PRIMARY an CLIPBOARD selection buffers
//list of delayed requests
--
Alioth's /home/x2go-admin/maintenancescripts/git/hooks/post-receive-email on /srv/git/code.x2go.org/x2gokdrive.git
More information about the x2go-commits
mailing list