Skip to content

Commit b8d99af

Browse files
committed
Merge branch 'master' into multicastvnc
Conflicts: libvncserver/sockets.c
2 parents 15d8f8f + 7488684 commit b8d99af

16 files changed

Lines changed: 166 additions & 76 deletions

File tree

.travis.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,15 @@
11
language: c
22

3+
os:
4+
- linux
5+
- osx
6+
7+
compiler:
8+
- gcc
9+
- clang
10+
11+
before_install:
12+
- 'if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then export CFLAGS="-I/usr/local/opt/openssl/include $CFLAGS" LDFLAGS="-L/usr/local/opt/openssl/lib $LDFLAGS"; fi'
13+
314
# before build script, run autoreconf
415
before_script: autoreconf -fiv

CMakeLists.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ find_package(GnuTLS)
3636
find_package(Threads)
3737
find_package(X11)
3838
find_package(OpenSSL)
39+
find_package(PkgConfig)
3940
find_library(LIBGCRYPT_LIBRARIES gcrypt)
4041

4142
# Check whether the version of libjpeg we found was libjpeg-turbo and print a
@@ -102,6 +103,17 @@ if(PNG_FOUND)
102103
endif(PNG_FOUND)
103104
option(LIBVNCSERVER_ALLOW24BPP "Allow 24 bpp" ON)
104105

106+
pkg_check_modules(SYSTEMD "libsystemd")
107+
if(SYSTEMD_FOUND)
108+
option(LIBVNCSERVER_WITH_SYSTEMD "Build with systemd socket activation support" ON)
109+
endif(SYSTEMD_FOUND)
110+
111+
if(LIBVNCSERVER_WITH_SYSTEMD)
112+
add_definitions(-DLIBVNCSERVER_WITH_SYSTEMD)
113+
include_directories(${SYSTEMD_INCLUDE_DIRS})
114+
set(ADDITIONAL_LIBS ${ADDITIONAL_LIBS} ${SYSTEMD_LIBRARIES})
115+
endif(LIBVNCSERVER_WITH_SYSTEMD)
116+
105117
if(GNUTLS_FOUND)
106118
set(LIBVNCSERVER_WITH_CLIENT_TLS 1)
107119
option(LIBVNCSERVER_WITH_WEBSOCKETS "Build with websockets support (gnutls)" ON)

README

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ drawn the cursor every time an update is sent. LibVNCServer handles
118118
all the details. Just set the cursor and don't bother any more.
119119

120120
To set the mouse coordinates (or emulate mouse clicks), call
121-
defaultPtrAddEvent(buttonMask,x,y,cl);
121+
rfbDefaultPtrAddEvent(buttonMask,x,y,cl);
122122
IMPORTANT: do this at the end of your function, because this actually draws
123123
the cursor if no cursor encoding is active.
124124

@@ -184,7 +184,7 @@ kbdReleaseAllKeys(rfbClientPtr cl)
184184
ptrAddEvent(int buttonMask,int x,int y,rfbClientPtr cl)
185185
is called when the mouse moves or a button is pressed.
186186
WARNING: if you want to have proper cursor handling, call
187-
defaultPtrAddEvent(buttonMask,x,y,cl)
187+
rfbDefaultPtrAddEvent(buttonMask,x,y,cl)
188188
in your own function. This sets the coordinates of the cursor.
189189
setXCutText(char* str,int len,rfbClientPtr cl)
190190
is called when the selection changes.
@@ -248,7 +248,7 @@ the original code from ORL/AT&T.
248248

249249
When I began hacking with computers, my first interest was speed. So, when I
250250
got around assembler, I programmed the floppy to do much of the work, because
251-
it's clock rate was higher than that of my C64. This was my first experience
251+
its clock rate was higher than that of my C64. This was my first experience
252252
with client/server techniques.
253253

254254
When I came around Xwindows (much later), I was at once intrigued by the
@@ -259,7 +259,7 @@ modem from home, it was no longer that much fun.
259259
When I started working with ASP (Application Service Provider) programs, I
260260
tumbled across Tarantella and Citrix. Being a security fanatic, the idea of
261261
running a server on windows didn't appeal to me, so Citrix went down the
262-
basket. However, Tarantella has it's own problems (security as well as the
262+
basket. However, Tarantella has its own problems (security as well as the
263263
high price). But at the same time somebody told me about this "great little
264264
administrator's tool" named VNC. Being used to windows programs' sizes, the
265265
surprise was reciprocal inverse to the size of VNC!
@@ -326,7 +326,7 @@ I am always amazed how people react whenever Microsoft(tm) puts in some
326326
features into their products which were around for a long time. Especially
327327
reporters seem to not know dick about what they are reporting about! But
328328
what is every time annoying again, is that they don't do it right. Every
329-
concept has it's new name (remember what enumerators used to be until
329+
concept has its new name (remember what enumerators used to be until
330330
Mickeysoft(tm) claimed that enumerators are what we thought were iterators.
331331
Yeah right, enumerators are also containers. They are not separated. Muddy.)
332332

@@ -393,7 +393,7 @@ The people at AT&T worked really well to produce something as clean and lean
393393
as VNC. The managers decided that for their fame, they would release the
394394
program for free. But not only that! They realized that by releasing also
395395
the code for free, VNC would become an evolving little child, conquering
396-
new worlds, making it's parents very proud. As well they can be! To protect
396+
new worlds, making its parents very proud. As well they can be! To protect
397397
this innovation, they decided to make it GPL, not BSD. The principal
398398
difference is: You can make closed source programs deriving from BSD, not
399399
from GPL. You have to give proper credit with both.

common/zywrletemplate.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ static InlineX void Harr(signed char* pX0, signed char* pX1)
352352
In this method, H/L and X0/X1 is always same position.
353353
This lead us to more speed and less memory.
354354
Of cause, the result of both method is quite same
355-
because it's only difference that coefficient position.
355+
because its only difference is that coefficient position.
356356
*/
357357
static InlineX void WaveletLevel(int* data, int size, int l, int SkipPixel)
358358
{

configure.ac

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,9 @@ if test ! -z "$with_ffmpeg"; then
6868
fi
6969
AM_CONDITIONAL(HAVE_MP3LAME, test "$HAVE_MP3LAME" = "true")
7070

71+
PKG_CHECK_MODULES([LIBSYSTEMD], [libsystemd], [with_systemd=1], [with_systemd=0])
72+
AM_CONDITIONAL([WITH_SYSTEMD], [test $with_systemd -eq 1])
73+
7174
# Seem to need this dummy here to induce the 'checking for egrep... grep -E', etc.
7275
# before it seemed to be inside the with_jpeg conditional.
7376
AC_CHECK_HEADER(thenonexistentheader.h, HAVE_THENONEXISTENTHEADER_H="true")

examples/example.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ static void initBuffer(unsigned char* buffer)
5656
}
5757
}
5858

59-
/* Here we create a structure so that every client has it's own pointer */
59+
/* Here we create a structure so that every client has its own pointer */
6060

6161
typedef struct ClientData {
6262
rfbBool oldButton;

examples/zippy.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
static int maxx=400, maxy=400, bpp=4;
88
/* odd maxx doesn't work (vncviewer bug) */
99

10-
/* Here we create a structure so that every client has it's own pointer */
10+
/* Here we create a structure so that every client has its own pointer */
1111

1212
/* turns the framebuffer black */
1313
void blank_framebuffer(char* frame_buffer, int x1, int y1, int x2, int y2);

libvncclient/rfbproto.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,13 +151,22 @@ void* rfbClientGetClientData(rfbClient* client, void* tag)
151151

152152
/* messages */
153153

154+
static rfbBool CheckRect(rfbClient* client, int x, int y, int w, int h) {
155+
return x + w <= client->width && y + h <= client->height;
156+
}
157+
154158
static void FillRectangle(rfbClient* client, int x, int y, int w, int h, uint32_t colour) {
155159
int i,j;
156160

157161
if (client->frameBuffer == NULL) {
158162
return;
159163
}
160164

165+
if (!CheckRect(client, x, y, w, h)) {
166+
rfbClientLog("Rect out of bounds: %dx%d at (%d, %d)\n", x, y, w, h);
167+
return;
168+
}
169+
161170
#define FILL_RECT(BPP) \
162171
for(j=y*client->width;j<(y+h)*client->width;j+=client->width) \
163172
for(i=x;i<x+w;i++) \
@@ -179,6 +188,11 @@ static void CopyRectangle(rfbClient* client, uint8_t* buffer, int x, int y, int
179188
return;
180189
}
181190

191+
if (!CheckRect(client, x, y, w, h)) {
192+
rfbClientLog("Rect out of bounds: %dx%d at (%d, %d)\n", x, y, w, h);
193+
return;
194+
}
195+
182196
#define COPY_RECT(BPP) \
183197
{ \
184198
int rs = w * BPP / 8, rs2 = client->width * BPP / 8; \
@@ -205,6 +219,16 @@ static void CopyRectangleFromRectangle(rfbClient* client, int src_x, int src_y,
205219
return;
206220
}
207221

222+
if (!CheckRect(client, src_x, src_y, w, h)) {
223+
rfbClientLog("Source rect out of bounds: %dx%d at (%d, %d)\n", src_x, src_y, w, h);
224+
return;
225+
}
226+
227+
if (!CheckRect(client, dest_x, dest_y, w, h)) {
228+
rfbClientLog("Dest rect out of bounds: %dx%d at (%d, %d)\n", dest_x, dest_y, w, h);
229+
return;
230+
}
231+
208232
#define COPY_RECT_FROM_RECT(BPP) \
209233
{ \
210234
uint##BPP##_t* _buffer=((uint##BPP##_t*)client->frameBuffer)+(src_y-dest_y)*client->width+src_x-dest_x; \

libvncclient/ultra.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,14 +98,14 @@ HandleUltraBPP (rfbClient* client, rfbBool multicast, int rx, int ry, int rw, in
9898

9999
/* uncompress the data */
100100
uncompressedBytes = client->raw_buffer_size;
101-
inflateResult = lzo1x_decompress(
101+
inflateResult = lzo1x_decompress_safe(
102102
(lzo_byte *)client->ultra_buffer, toRead,
103103
(lzo_byte *)client->raw_buffer, (lzo_uintp) &uncompressedBytes,
104104
NULL);
105105

106-
106+
/* Note that uncompressedBytes will be 0 on output overrun */
107107
if ((rw * rh * (BPP / 8)) != uncompressedBytes)
108-
rfbClientLog("Ultra decompressed too little (%d < %d)", (rw * rh * (BPP / 8)), uncompressedBytes);
108+
rfbClientLog("Ultra decompressed unexpected amount of data (%d != %d)\n", (rw * rh * (BPP / 8)), uncompressedBytes);
109109

110110
/* Put the uncompressed contents of the update on the screen. */
111111
if ( inflateResult == LZO_E_OK )
@@ -180,7 +180,7 @@ HandleUltraZipBPP (rfbClient* client, int rx, int ry, int rw, int rh)
180180

181181
/* uncompress the data */
182182
uncompressedBytes = client->raw_buffer_size;
183-
inflateResult = lzo1x_decompress(
183+
inflateResult = lzo1x_decompress_safe(
184184
(lzo_byte *)client->ultra_buffer, toRead,
185185
(lzo_byte *)client->raw_buffer, &uncompressedBytes, NULL);
186186
if ( inflateResult != LZO_E_OK )

libvncserver/Makefile.am

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,12 @@ LIB_SRCS = main.c rfbserver.c rfbregion.c auth.c sockets.c $(WEBSOCKETSSRCS) \
6262
libvncserver_la_SOURCES=$(LIB_SRCS)
6363
libvncserver_la_LIBADD=$(WEBSOCKETSSSLLIBS)
6464

65+
if WITH_SYSTEMD
66+
AM_CPPFLAGS += -DLIBVNCSERVER_WITH_SYSTEMD
67+
libvncserver_la_CFLAGS = $(LIBSYSTEMD_CFLAGS)
68+
libvncserver_la_LIBADD += $(LIBSYSTEMD_LIBS)
69+
endif
70+
6571
lib_LTLIBRARIES=libvncserver.la
6672
libvncserver_la_LDFLAGS = -version-info 1:0:0
6773

0 commit comments

Comments
 (0)