libvncserver sockets: check cl->screen before accessing it

In commit 079394ca5b 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: Tobias Doerffel <tobias.doerffel@gmail.com>
pull/1/head
Tobias Doerffel 14 years ago committed by Christian Beier
parent d5e256bd50
commit d4fabc217e

@ -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,
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

Loading…
Cancel
Save