Skip to content

Commit 2771ce3

Browse files
committed
Merge branch 'master' into multicastvnc
2 parents d915550 + 0e72da1 commit 2771ce3

119 files changed

Lines changed: 476 additions & 231 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci.yml

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,17 @@ jobs:
1818
include:
1919
- os: macos-latest
2020
macos_cmake_options: "-DOPENSSL_ROOT_DIR=/usr/local/opt/openssl" # set this extra var for OSX
21+
- os: windows-latest
22+
windows_cmake_options: "-DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake" # set this extra var for Windows
2123
exclude:
2224
- os: macos-latest
2325
cmake_options: "-DCMAKE_TOOLCHAIN_FILE=../cmake/Toolchain-cross-mingw32-linux.cmake" # don't test MinGW from OSX
2426
- os: windows-latest
25-
cmake_options: "-DCMAKE_TOOLCHAIN_FILE=../cmake/Toolchain-cross-mingw32-linux.cmake" # don't test MinGW from OSX
27+
cmake_options: "-DCMAKE_TOOLCHAIN_FILE=../cmake/Toolchain-cross-mingw32-linux.cmake" # don't test MinGW from Windows
28+
- os: windows-latest
29+
cmake_options: "-DWITH_OPENSSL=ON -DWITH_GNUTLS=OFF -DWITH_GCRYPT=OFF" # don't have OpenSSL on Windows (yet)
30+
- os: windows-latest
31+
cmake_options: "-DWITH_OPENSSL=OFF -DWITH_GNUTLS=ON -DWITH_GCRYPT=ON" # don't have GnuTLS and libgcrypt on Windows (yet)
2632
runs-on: ${{ matrix.os }}
2733
steps:
2834
- uses: actions/checkout@v3
@@ -34,13 +40,19 @@ jobs:
3440
- name: Install MacOS Build Dependencies
3541
if: ${{ matrix.os == 'macos-latest' }}
3642
run: |
43+
unset HOMEBREW_NO_INSTALL_FROM_API
44+
brew untap homebrew/core homebrew/cask
3745
brew update
3846
brew install sdl2 lzo
47+
- name: Install Windows Build Dependencies
48+
if: ${{ matrix.os == 'windows-latest' }}
49+
run: |
50+
vcpkg install zlib libjpeg-turbo libpng --triplet=x64-windows # could install more but should use run-vcpkg with caching for this
3951
- name: Build
4052
run: |
4153
mkdir build
4254
cd build
43-
cmake ${{ matrix.cmake_options }} ${{ matrix.macos_cmake_options }} ..
55+
cmake ${{ matrix.cmake_options }} ${{ matrix.macos_cmake_options }} ${{ matrix.windows_cmake_options }} ..
4456
cmake --build .
4557
- name: Prepare Test
4658
if: ${{ matrix.os == 'ubuntu-latest' }} # only ubuntu does crosscompile with MinGW toolchain
@@ -50,21 +62,3 @@ jobs:
5062
run: |
5163
cd build
5264
ctest -C Debug --output-on-failure
53-
fuzzing_build:
54-
runs-on: ubuntu-latest
55-
steps:
56-
- uses: actions/checkout@v3
57-
- name: Install Ubuntu Build Dependencies
58-
run: |
59-
sudo apt update
60-
sudo apt install libsdl2-dev liblzo2-dev libssl-dev gnutls-dev libgcrypt-dev mingw-w64-x86-64-dev binutils-mingw-w64-x86-64 gcc-mingw-w64-x86-64 wine clang
61-
- name: Build
62-
env:
63-
CC: "clang"
64-
LIB_FUZZING_ENGINE: "-fsanitize=fuzzer"
65-
CFLAGS: "-fsanitize=address,fuzzer-no-link -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION=1"
66-
run: |
67-
mkdir build
68-
cd build
69-
cmake ..
70-
cmake --build .

.github/workflows/cifuzz.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: CIFuzz
2+
on: [pull_request]
3+
jobs:
4+
Fuzzing:
5+
runs-on: ubuntu-latest
6+
steps:
7+
- name: Build Fuzzers
8+
id: build
9+
uses: google/oss-fuzz/infra/cifuzz/actions/build_fuzzers@master
10+
with:
11+
oss-fuzz-project-name: 'libvnc'
12+
dry-run: false
13+
language: c++
14+
- name: Run Fuzzers
15+
uses: google/oss-fuzz/infra/cifuzz/actions/run_fuzzers@master
16+
with:
17+
oss-fuzz-project-name: 'libvnc'
18+
fuzz-seconds: 30
19+
dry-run: false
20+
language: c++
21+
- name: Upload Crash
22+
uses: actions/upload-artifact@v3
23+
if: failure() && steps.build.outcome == 'success'
24+
with:
25+
name: artifacts
26+
path: ./out/artifacts

CMakeLists.txt

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ set(PACKAGE_NAME "LibVNCServer")
1616
set(FULL_PACKAGE_NAME "LibVNCServer")
1717
set(VERSION_SO "1")
1818
set(PROJECT_BUGREPORT_PATH "https://github.com/LibVNC/libvncserver/issues")
19-
set(LIBVNCSERVER_DIR ${CMAKE_CURRENT_SOURCE_DIR}/libvncserver)
20-
set(COMMON_DIR ${CMAKE_CURRENT_SOURCE_DIR}/common)
21-
set(LIBVNCCLIENT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/libvncclient)
19+
set(LIBVNCSERVER_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src/libvncserver)
20+
set(COMMON_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src/common)
21+
set(LIBVNCCLIENT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src/libvncclient)
2222
set(LIBVNCSRVEXAMPLE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/examples/server)
2323
set(LIBVNCCLIEXAMPLE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/examples/client)
2424
set(TESTS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/test)
@@ -35,7 +35,12 @@ add_custom_target(
3535
)
3636
endif(CMAKE_GENERATOR MATCHES "Unix Makefiles|Ninja")
3737

38-
include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/libvncserver ${CMAKE_CURRENT_SOURCE_DIR}/common)
38+
include_directories(
39+
${CMAKE_CURRENT_SOURCE_DIR}/include
40+
${CMAKE_CURRENT_BINARY_DIR}/include
41+
${LIBVNCSERVER_DIR}
42+
${LIBVNCCLIENT_DIR}
43+
${COMMON_DIR})
3944

4045
# all the build configuration switches
4146
option(LIBVNCSERVER_INSTALL "Generate installation target" ON)
@@ -357,7 +362,7 @@ endif(WITH_SASL AND LIBSASL2_LIBRARIES AND SASL2_INCLUDE_DIR)
357362
# LIBVNCSERVER_ENOENT_WORKAROUND
358363
# inline
359364

360-
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/rfb/rfbconfig.h.cmakein ${CMAKE_CURRENT_BINARY_DIR}/rfb/rfbconfig.h)
365+
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/include/rfb/rfbconfig.h.cmakein ${CMAKE_CURRENT_BINARY_DIR}/include/rfb/rfbconfig.h)
361366

362367
set(LIBVNCSERVER_SOURCES
363368
${LIBVNCSERVER_DIR}/main.c
@@ -388,7 +393,7 @@ set(LIBVNCSERVER_SOURCES
388393
set(LIBVNCCLIENT_SOURCES
389394
${LIBVNCCLIENT_DIR}/cursor.c
390395
${LIBVNCCLIENT_DIR}/listen.c
391-
${LIBVNCCLIENT_DIR}/rfbproto.c
396+
${LIBVNCCLIENT_DIR}/rfbclient.c
392397
${LIBVNCCLIENT_DIR}/sockets.c
393398
${LIBVNCCLIENT_DIR}/vncviewer.c
394399
${COMMON_DIR}/ghpringbuf.c
@@ -769,19 +774,19 @@ function(get_link_libraries OUT TARGET)
769774
endfunction()
770775

771776
get_link_libraries(PRIVATE_LIBS vncserver)
772-
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libvncserver/libvncserver.pc.cmakein ${CMAKE_CURRENT_BINARY_DIR}/libvncserver.pc @ONLY)
777+
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/libvncserver/libvncserver.pc.cmakein ${CMAKE_CURRENT_BINARY_DIR}/libvncserver.pc @ONLY)
773778
get_link_libraries(PRIVATE_LIBS vncclient)
774-
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libvncclient/libvncclient.pc.cmakein ${CMAKE_CURRENT_BINARY_DIR}/libvncclient.pc @ONLY)
779+
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/libvncclient/libvncclient.pc.cmakein ${CMAKE_CURRENT_BINARY_DIR}/libvncclient.pc @ONLY)
775780

776781
if(LIBVNCSERVER_INSTALL)
777782
set(INSTALL_HEADER_FILES
778-
rfb/keysym.h
779-
rfb/threading.h
780-
rfb/rfb.h
781-
rfb/rfbclient.h
782-
${CMAKE_CURRENT_BINARY_DIR}/rfb/rfbconfig.h
783-
rfb/rfbproto.h
784-
rfb/rfbregion.h
783+
include/rfb/keysym.h
784+
include/rfb/threading.h
785+
include/rfb/rfb.h
786+
include/rfb/rfbclient.h
787+
${CMAKE_CURRENT_BINARY_DIR}/include/rfb/rfbconfig.h
788+
include/rfb/rfbproto.h
789+
include/rfb/rfbregion.h
785790
)
786791

787792
set_property(TARGET vncclient PROPERTY PUBLIC_HEADER ${INSTALL_HEADER_FILES})

NEWS.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,23 @@
1+
# xxx-xx-xx: Version 0.9.15
2+
3+
## Overall changes:
4+
5+
* Added fuzzing with OSS-Fuzz thanks to Catena Cyber.
6+
7+
## LibVNCServer/LibVNCClient:
8+
9+
* Fixed building with OpenSSL >= 3.0.0.
10+
11+
## LibVNCClient:
12+
13+
* Fixed LibVNCClient handling of UltraVNC MSLogonII when built with OpenSSL.
14+
* Added UTF8 clipboard handling.
15+
16+
## LibVNCServer:
17+
18+
* Added a proof-of-concept X11 example server.
19+
20+
121
# 2022-12-18: Version 0.9.14
222

323
0.9.14 represents a gradual improvement over 0.9.13 with lots of developments all over

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,9 +149,9 @@ See the [LibVNCServer API intro documentation](https://libvnc.github.io/doc/html
149149
for how to create a server instance, wire up input handlers and handle cursors.
150150

151151
In case you prefer to learn LibVNCServer by example, have a look at the servers in the
152-
[examples](examples) directory.
152+
[examples/server](examples/server) directory.
153153

154-
For LibVNCClient, examples can be found in [client_examples](client_examples).
154+
For LibVNCClient, examples can be found in [examples/client](examples/client).
155155

156156
Incorporating LibVNCServer/LibVNCClient into your build system
157157
--------------------------------------------------------------

SECURITY.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ team head count.
99

1010
## Reporting a Vulnerability
1111

12-
Mail in to dontmind@sdf.org.
12+
Please use [this form](https://github.com/LibVNC/libvncserver/security/advisories/new).

examples/client/SDLvncviewer.c

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,6 @@ static rfbBool resize(rfbClient* client) {
4242
if (enableResizable)
4343
sdlFlags |= SDL_WINDOW_RESIZABLE;
4444

45-
client->updateRect.x = client->updateRect.y = 0;
46-
client->updateRect.w = width; client->updateRect.h = height;
47-
4845
/* (re)create the surface used as the client's framebuffer */
4946
SDL_FreeSurface(rfbClientGetClientData(client, SDL_Init));
5047
SDL_Surface* sdl=SDL_CreateRGBSurface(0,
@@ -307,7 +304,8 @@ static rfbBool handleSDLEvent(rfbClient *cl, SDL_Event *e)
307304
char *text = SDL_GetClipboardText();
308305
if(text) {
309306
rfbClientLog("sending clipboard text '%s'\n", text);
310-
SendClientCutText(cl, text, strlen(text));
307+
if(!SendClientCutTextUTF8(cl, text, strlen(text)))
308+
SendClientCutText(cl, text, strlen(text));
311309
}
312310
}
313311

@@ -420,18 +418,37 @@ static rfbBool handleSDLEvent(rfbClient *cl, SDL_Event *e)
420418
return TRUE;
421419
}
422420

423-
static void got_selection(rfbClient *cl, const char *text, int len)
421+
static void got_selection_latin1(rfbClient *cl, const char *text, int len)
424422
{
425-
rfbClientLog("received clipboard text '%s'\n", text);
423+
rfbClientLog("received latin1 clipboard text '%s'\n", text);
426424
if(SDL_SetClipboardText(text) != 0)
427-
rfbClientErr("could not set received clipboard text: %s\n", SDL_GetError());
425+
rfbClientErr("could not set received latin1 clipboard text: %s\n", SDL_GetError());
426+
}
427+
428+
static void got_selection_utf8(rfbClient *cl, const char *buf, int len)
429+
{
430+
rfbClientLog("received utf8 clipboard text '%s'\n", buf);
431+
if(SDL_SetClipboardText(buf) != 0)
432+
rfbClientErr("could not set received utf8 clipboard text: %s\n", SDL_GetError());
428433
}
429434

430435

431436
static rfbCredential* get_credential(rfbClient* cl, int credentialType){
432-
rfbCredential *c = malloc(sizeof(rfbCredential));
437+
rfbCredential *c = malloc(sizeof(rfbCredential));
438+
if (!c) {
439+
return NULL;
440+
}
433441
c->userCredential.username = malloc(RFB_BUF_SIZE);
442+
if (!c->userCredential.username) {
443+
free(c);
444+
return NULL;
445+
}
434446
c->userCredential.password = malloc(RFB_BUF_SIZE);
447+
if (!c->userCredential.password) {
448+
free(c->userCredential.username);
449+
free(c);
450+
return NULL;
451+
}
435452

436453
if(credentialType != rfbCredentialTypeUser) {
437454
rfbClientErr("something else than username and password required for authentication\n");
@@ -496,7 +513,11 @@ int main(int argc,char** argv) {
496513
cl->GotFrameBufferUpdate=update;
497514
cl->HandleKeyboardLedState=kbd_leds;
498515
cl->HandleTextChat=text_chat;
499-
cl->GotXCutText = got_selection;
516+
/* two different cut text handlers here for demo purposes, you
517+
might as well use the same callback for both if it doesn't
518+
matter for your application */
519+
cl->GotXCutText = got_selection_latin1;
520+
cl->GotXCutTextUTF8 = got_selection_utf8;
500521
cl->GetCredential = get_credential;
501522
cl->listenPort = LISTEN_PORT_OFFSET;
502523
cl->listen6Port = LISTEN_PORT_OFFSET;

0 commit comments

Comments
 (0)