Commit d4fabc21 authored by Tobias Doerffel's avatar Tobias Doerffel Committed by Christian Beier

libvncserver sockets: check cl->screen before accessing it

In commit 079394ca new code with
insufficient checks was introduced causing a segfault when doing a
HTTP server connection. Such connections have no screen set in the
client data structure.
Signed-off-by: 's avatarTobias Doerffel <tobias.doerffel@gmail.com>
parent d5e256bd
...@@ -499,7 +499,7 @@ rfbReadExactTimeout(rfbClientPtr cl, char* buf, int len, int timeout) ...@@ -499,7 +499,7 @@ rfbReadExactTimeout(rfbClientPtr cl, char* buf, int len, int timeout)
int rfbReadExact(rfbClientPtr cl,char* buf,int len) int rfbReadExact(rfbClientPtr cl,char* buf,int len)
{ {
/* favor the per-screen value if set */ /* favor the per-screen value if set */
if(cl->screen->maxClientWait) if(cl->screen && cl->screen->maxClientWait)
return(rfbReadExactTimeout(cl,buf,len,cl->screen->maxClientWait)); return(rfbReadExactTimeout(cl,buf,len,cl->screen->maxClientWait));
else else
return(rfbReadExactTimeout(cl,buf,len,rfbMaxClientWait)); return(rfbReadExactTimeout(cl,buf,len,rfbMaxClientWait));
...@@ -521,7 +521,7 @@ rfbWriteExact(rfbClientPtr cl, ...@@ -521,7 +521,7 @@ rfbWriteExact(rfbClientPtr cl,
fd_set fds; fd_set fds;
struct timeval tv; struct timeval tv;
int totalTimeWaited = 0; int totalTimeWaited = 0;
const int timeout = cl->screen->maxClientWait ? cl->screen->maxClientWait : rfbMaxClientWait; const int timeout = (cl->screen && cl->screen->maxClientWait) ? cl->screen->maxClientWait : rfbMaxClientWait;
#undef DEBUG_WRITE_EXACT #undef DEBUG_WRITE_EXACT
#ifdef DEBUG_WRITE_EXACT #ifdef DEBUG_WRITE_EXACT
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment