diff options
| -rw-r--r-- | .travis.yml | 4 | ||||
| -rw-r--r-- | README | 2 | ||||
| l--------- | README.md | 1 | ||||
| -rw-r--r-- | examples/camera.c | 2 | ||||
| -rw-r--r-- | libvncclient/rfbproto.c | 6 | ||||
| -rw-r--r-- | libvncclient/tls_gnutls.c | 21 | ||||
| -rw-r--r-- | libvncclient/vncviewer.c | 2 | ||||
| -rw-r--r-- | libvncserver/rfbserver.c | 4 | ||||
| -rw-r--r-- | libvncserver/sockets.c | 11 | ||||
| -rw-r--r-- | rfb/rfbclient.h | 6 | ||||
| -rw-r--r-- | rfb/rfbproto.h | 2 |
11 files changed, 46 insertions, 15 deletions
diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..13db7db --- /dev/null +++ b/.travis.yml @@ -0,0 +1,4 @@ +language: c + +# before build script, run autoreconf +before_script: autoreconf -fiv
\ No newline at end of file @@ -1,3 +1,5 @@ +[](https://travis-ci.org/LibVNC/libvncserver) + LibVNCServer: A library for easy implementation of a VNC server. Copyright (C) 2001-2003 Johannes E. Schindelin diff --git a/README.md b/README.md new file mode 120000 index 0000000..100b938 --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +README
\ No newline at end of file diff --git a/examples/camera.c b/examples/camera.c index 2e54da7..51b122d 100644 --- a/examples/camera.c +++ b/examples/camera.c @@ -104,7 +104,7 @@ int TakePicture(unsigned char *buffer) */ gettimeofday(&now,NULL); line = now.tv_usec / (1000000/HEIGHT); - if (line>HEIGHT) line=HEIGHT-1; + if (line>=HEIGHT) line=HEIGHT-1; memset(&buffer[(WIDTH * BPP) * line], 0, (WIDTH * BPP)); /* frames per second (informational only) */ diff --git a/libvncclient/rfbproto.c b/libvncclient/rfbproto.c index 187a56a..94b9bdb 100644 --- a/libvncclient/rfbproto.c +++ b/libvncclient/rfbproto.c @@ -1492,7 +1492,8 @@ SetFormatAndEncodings(rfbClient* client) if(e->encodings) { int* enc; for(enc = e->encodings; *enc; enc++) - encs[se->nEncodings++] = rfbClientSwap32IfLE(*enc); + if(se->nEncodings < MAX_ENCODINGS) + encs[se->nEncodings++] = rfbClientSwap32IfLE(*enc); } len = sz_rfbSetEncodingsMsg + se->nEncodings * 4; @@ -1962,7 +1963,8 @@ HandleRFBServerMessage(rfbClient* client) y += linesToRead; } - } break; + break; + } case rfbEncodingCopyRect: { diff --git a/libvncclient/tls_gnutls.c b/libvncclient/tls_gnutls.c index 3daa416..91cea67 100644 --- a/libvncclient/tls_gnutls.c +++ b/libvncclient/tls_gnutls.c @@ -480,6 +480,14 @@ WriteToTLS(rfbClient* client, char *buf, unsigned int n) unsigned int offset = 0; ssize_t ret; + if (client->LockWriteToTLS) + { + if (!client->LockWriteToTLS(client)) + { + rfbClientLog("Callback to get lock in WriteToTLS() failed\n"); + return -1; + } + } while (offset < n) { ret = gnutls_record_send((gnutls_session_t)client->tlsSession, buf+offset, (size_t)(n-offset)); @@ -488,10 +496,23 @@ WriteToTLS(rfbClient* client, char *buf, unsigned int n) { if (ret == GNUTLS_E_AGAIN || ret == GNUTLS_E_INTERRUPTED) continue; rfbClientLog("Error writing to TLS: %s.\n", gnutls_strerror(ret)); + if (client->UnlockWriteToTLS) + { + if (!client->UnlockWriteToTLS(client)) + rfbClientLog("Callback to unlock WriteToTLS() failed\n"); + } return -1; } offset += (unsigned int)ret; } + if (client->UnlockWriteToTLS) + { + if (!client->UnlockWriteToTLS(client)) + { + rfbClientLog("Callback to unlock WriteToTLS() failed\n"); + return -1; + } + } return offset; } diff --git a/libvncclient/vncviewer.c b/libvncclient/vncviewer.c index af0a50b..d81e298 100644 --- a/libvncclient/vncviewer.c +++ b/libvncclient/vncviewer.c @@ -220,6 +220,8 @@ rfbClient* rfbGetClient(int bitsPerSample,int samplesPerPixel, client->subAuthScheme = 0; client->GetCredential = NULL; client->tlsSession = NULL; + client->LockWriteToTLS = NULL; + client->UnlockWriteToTLS = NULL; client->sock = -1; client->listenSock = -1; client->listenAddress = NULL; diff --git a/libvncserver/rfbserver.c b/libvncserver/rfbserver.c index 68c2de5..bc9cc11 100644 --- a/libvncserver/rfbserver.c +++ b/libvncserver/rfbserver.c @@ -363,9 +363,7 @@ rfbNewTCPOrUDPClient(rfbScreenInfoPtr rfbScreen, if (setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, (char *)&one, sizeof(one)) < 0) { - rfbLogPerror("setsockopt failed"); - close(sock); - return NULL; + rfbLogPerror("setsockopt failed: can't set TCP_NODELAY flag, non TCP socket?"); } FD_SET(sock,&(rfbScreen->allFds)); diff --git a/libvncserver/sockets.c b/libvncserver/sockets.c index aaef14b..e960936 100644 --- a/libvncserver/sockets.c +++ b/libvncserver/sockets.c @@ -146,8 +146,7 @@ rfbInitSockets(rfbScreenInfoPtr rfbScreen) if (setsockopt(rfbScreen->inetdSock, IPPROTO_TCP, TCP_NODELAY, (char *)&one, sizeof(one)) < 0) { - rfbLogPerror("setsockopt"); - return; + rfbLogPerror("setsockopt failed: can't set TCP_NODELAY flag, non TCP socket?"); } FD_ZERO(&(rfbScreen->allFds)); @@ -453,9 +452,7 @@ rfbProcessNewConnection(rfbScreenInfoPtr rfbScreen) if (setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, (char *)&one, sizeof(one)) < 0) { - rfbLogPerror("rfbCheckFds: setsockopt"); - closesocket(sock); - return FALSE; + rfbLogPerror("rfbCheckFds: setsockopt failed: can't set TCP_NODELAY flag, non TCP socket?"); } #ifdef USE_LIBWRAP @@ -556,9 +553,7 @@ rfbConnect(rfbScreenInfoPtr rfbScreen, if (setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, (char *)&one, sizeof(one)) < 0) { - rfbLogPerror("setsockopt failed"); - closesocket(sock); - return -1; + rfbLogPerror("setsockopt failed: can't set TCP_NODELAY flag, non TCP socket?"); } /* AddEnabledDevice(sock); */ diff --git a/rfb/rfbclient.h b/rfb/rfbclient.h index 157461e..c18eaf9 100644 --- a/rfb/rfbclient.h +++ b/rfb/rfbclient.h @@ -182,6 +182,8 @@ typedef void (*BellProc)(struct _rfbClient* client); */ typedef void (*GotCursorShapeProc)(struct _rfbClient* client, int xhot, int yhot, int width, int height, int bytesPerPixel); typedef void (*GotCopyRectProc)(struct _rfbClient* client, int src_x, int src_y, int w, int h, int dest_x, int dest_y); +typedef rfbBool (*LockWriteToTLSProc)(struct _rfbClient* client); +typedef rfbBool (*UnlockWriteToTLSProc)(struct _rfbClient* client); typedef struct _rfbClient { uint8_t* frameBuffer; @@ -361,6 +363,10 @@ typedef struct _rfbClient { /* Output Window ID. When set, client application enables libvncclient to perform direct rendering in its window */ unsigned long outputWindow; + /** Hooks for optional protection WriteToTLS() by mutex */ + LockWriteToTLSProc LockWriteToTLS; + UnlockWriteToTLSProc UnlockWriteToTLS; + } rfbClient; /* cursor.c */ diff --git a/rfb/rfbproto.h b/rfb/rfbproto.h index bb6bfa5..9eca868 100644 --- a/rfb/rfbproto.h +++ b/rfb/rfbproto.h @@ -120,7 +120,7 @@ typedef uint32_t in_addr_t; #define INADDR_NONE ((in_addr_t) 0xffffffff) #endif -#define MAX_ENCODINGS 21 +#define MAX_ENCODINGS 64 /***************************************************************************** * |
