Skip to content

Commit

Permalink
Merge branch 'master' into multicastvnc
Browse files Browse the repository at this point in the history
  • Loading branch information
bk138 committed Jul 4, 2023
2 parents d915550 + 0e72da1 commit 2771ce3
Show file tree
Hide file tree
Showing 119 changed files with 476 additions and 231 deletions.
34 changes: 14 additions & 20 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,17 @@ jobs:
include:
- os: macos-latest
macos_cmake_options: "-DOPENSSL_ROOT_DIR=/usr/local/opt/openssl" # set this extra var for OSX
- os: windows-latest
windows_cmake_options: "-DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake" # set this extra var for Windows
exclude:
- os: macos-latest
cmake_options: "-DCMAKE_TOOLCHAIN_FILE=../cmake/Toolchain-cross-mingw32-linux.cmake" # don't test MinGW from OSX
- os: windows-latest
cmake_options: "-DCMAKE_TOOLCHAIN_FILE=../cmake/Toolchain-cross-mingw32-linux.cmake" # don't test MinGW from OSX
cmake_options: "-DCMAKE_TOOLCHAIN_FILE=../cmake/Toolchain-cross-mingw32-linux.cmake" # don't test MinGW from Windows
- os: windows-latest
cmake_options: "-DWITH_OPENSSL=ON -DWITH_GNUTLS=OFF -DWITH_GCRYPT=OFF" # don't have OpenSSL on Windows (yet)
- os: windows-latest
cmake_options: "-DWITH_OPENSSL=OFF -DWITH_GNUTLS=ON -DWITH_GCRYPT=ON" # don't have GnuTLS and libgcrypt on Windows (yet)
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
Expand All @@ -34,13 +40,19 @@ jobs:
- name: Install MacOS Build Dependencies
if: ${{ matrix.os == 'macos-latest' }}
run: |
unset HOMEBREW_NO_INSTALL_FROM_API
brew untap homebrew/core homebrew/cask
brew update
brew install sdl2 lzo
- name: Install Windows Build Dependencies
if: ${{ matrix.os == 'windows-latest' }}
run: |
vcpkg install zlib libjpeg-turbo libpng --triplet=x64-windows # could install more but should use run-vcpkg with caching for this
- name: Build
run: |
mkdir build
cd build
cmake ${{ matrix.cmake_options }} ${{ matrix.macos_cmake_options }} ..
cmake ${{ matrix.cmake_options }} ${{ matrix.macos_cmake_options }} ${{ matrix.windows_cmake_options }} ..
cmake --build .
- name: Prepare Test
if: ${{ matrix.os == 'ubuntu-latest' }} # only ubuntu does crosscompile with MinGW toolchain
Expand All @@ -50,21 +62,3 @@ jobs:
run: |
cd build
ctest -C Debug --output-on-failure
fuzzing_build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install Ubuntu Build Dependencies
run: |
sudo apt update
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
- name: Build
env:
CC: "clang"
LIB_FUZZING_ENGINE: "-fsanitize=fuzzer"
CFLAGS: "-fsanitize=address,fuzzer-no-link -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION=1"
run: |
mkdir build
cd build
cmake ..
cmake --build .
26 changes: 26 additions & 0 deletions .github/workflows/cifuzz.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: CIFuzz
on: [pull_request]
jobs:
Fuzzing:
runs-on: ubuntu-latest
steps:
- name: Build Fuzzers
id: build
uses: google/oss-fuzz/infra/cifuzz/actions/build_fuzzers@master
with:
oss-fuzz-project-name: 'libvnc'
dry-run: false
language: c++
- name: Run Fuzzers
uses: google/oss-fuzz/infra/cifuzz/actions/run_fuzzers@master
with:
oss-fuzz-project-name: 'libvnc'
fuzz-seconds: 30
dry-run: false
language: c++
- name: Upload Crash
uses: actions/upload-artifact@v3
if: failure() && steps.build.outcome == 'success'
with:
name: artifacts
path: ./out/artifacts
35 changes: 20 additions & 15 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ set(PACKAGE_NAME "LibVNCServer")
set(FULL_PACKAGE_NAME "LibVNCServer")
set(VERSION_SO "1")
set(PROJECT_BUGREPORT_PATH "https://github.com/LibVNC/libvncserver/issues")
set(LIBVNCSERVER_DIR ${CMAKE_CURRENT_SOURCE_DIR}/libvncserver)
set(COMMON_DIR ${CMAKE_CURRENT_SOURCE_DIR}/common)
set(LIBVNCCLIENT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/libvncclient)
set(LIBVNCSERVER_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src/libvncserver)
set(COMMON_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src/common)
set(LIBVNCCLIENT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src/libvncclient)
set(LIBVNCSRVEXAMPLE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/examples/server)
set(LIBVNCCLIEXAMPLE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/examples/client)
set(TESTS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/test)
Expand All @@ -35,7 +35,12 @@ add_custom_target(
)
endif(CMAKE_GENERATOR MATCHES "Unix Makefiles|Ninja")

include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/libvncserver ${CMAKE_CURRENT_SOURCE_DIR}/common)
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/include
${CMAKE_CURRENT_BINARY_DIR}/include
${LIBVNCSERVER_DIR}
${LIBVNCCLIENT_DIR}
${COMMON_DIR})

# all the build configuration switches
option(LIBVNCSERVER_INSTALL "Generate installation target" ON)
Expand Down Expand Up @@ -357,7 +362,7 @@ endif(WITH_SASL AND LIBSASL2_LIBRARIES AND SASL2_INCLUDE_DIR)
# LIBVNCSERVER_ENOENT_WORKAROUND
# inline

configure_file(${CMAKE_CURRENT_SOURCE_DIR}/rfb/rfbconfig.h.cmakein ${CMAKE_CURRENT_BINARY_DIR}/rfb/rfbconfig.h)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/include/rfb/rfbconfig.h.cmakein ${CMAKE_CURRENT_BINARY_DIR}/include/rfb/rfbconfig.h)

set(LIBVNCSERVER_SOURCES
${LIBVNCSERVER_DIR}/main.c
Expand Down Expand Up @@ -388,7 +393,7 @@ set(LIBVNCSERVER_SOURCES
set(LIBVNCCLIENT_SOURCES
${LIBVNCCLIENT_DIR}/cursor.c
${LIBVNCCLIENT_DIR}/listen.c
${LIBVNCCLIENT_DIR}/rfbproto.c
${LIBVNCCLIENT_DIR}/rfbclient.c
${LIBVNCCLIENT_DIR}/sockets.c
${LIBVNCCLIENT_DIR}/vncviewer.c
${COMMON_DIR}/ghpringbuf.c
Expand Down Expand Up @@ -769,19 +774,19 @@ function(get_link_libraries OUT TARGET)
endfunction()

get_link_libraries(PRIVATE_LIBS vncserver)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libvncserver/libvncserver.pc.cmakein ${CMAKE_CURRENT_BINARY_DIR}/libvncserver.pc @ONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/libvncserver/libvncserver.pc.cmakein ${CMAKE_CURRENT_BINARY_DIR}/libvncserver.pc @ONLY)
get_link_libraries(PRIVATE_LIBS vncclient)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libvncclient/libvncclient.pc.cmakein ${CMAKE_CURRENT_BINARY_DIR}/libvncclient.pc @ONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/libvncclient/libvncclient.pc.cmakein ${CMAKE_CURRENT_BINARY_DIR}/libvncclient.pc @ONLY)

if(LIBVNCSERVER_INSTALL)
set(INSTALL_HEADER_FILES
rfb/keysym.h
rfb/threading.h
rfb/rfb.h
rfb/rfbclient.h
${CMAKE_CURRENT_BINARY_DIR}/rfb/rfbconfig.h
rfb/rfbproto.h
rfb/rfbregion.h
include/rfb/keysym.h
include/rfb/threading.h
include/rfb/rfb.h
include/rfb/rfbclient.h
${CMAKE_CURRENT_BINARY_DIR}/include/rfb/rfbconfig.h
include/rfb/rfbproto.h
include/rfb/rfbregion.h
)

set_property(TARGET vncclient PROPERTY PUBLIC_HEADER ${INSTALL_HEADER_FILES})
Expand Down
20 changes: 20 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
# xxx-xx-xx: Version 0.9.15

## Overall changes:

* Added fuzzing with OSS-Fuzz thanks to Catena Cyber.

## LibVNCServer/LibVNCClient:

* Fixed building with OpenSSL >= 3.0.0.

## LibVNCClient:

* Fixed LibVNCClient handling of UltraVNC MSLogonII when built with OpenSSL.
* Added UTF8 clipboard handling.

## LibVNCServer:

* Added a proof-of-concept X11 example server.


# 2022-12-18: Version 0.9.14

0.9.14 represents a gradual improvement over 0.9.13 with lots of developments all over
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,9 @@ See the [LibVNCServer API intro documentation](https://libvnc.github.io/doc/html
for how to create a server instance, wire up input handlers and handle cursors.

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

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

Incorporating LibVNCServer/LibVNCClient into your build system
--------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ team head count.

## Reporting a Vulnerability

Mail in to [email protected].
Please use [this form](https://github.com/LibVNC/libvncserver/security/advisories/new).
39 changes: 30 additions & 9 deletions examples/client/SDLvncviewer.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,6 @@ static rfbBool resize(rfbClient* client) {
if (enableResizable)
sdlFlags |= SDL_WINDOW_RESIZABLE;

client->updateRect.x = client->updateRect.y = 0;
client->updateRect.w = width; client->updateRect.h = height;

/* (re)create the surface used as the client's framebuffer */
SDL_FreeSurface(rfbClientGetClientData(client, SDL_Init));
SDL_Surface* sdl=SDL_CreateRGBSurface(0,
Expand Down Expand Up @@ -307,7 +304,8 @@ static rfbBool handleSDLEvent(rfbClient *cl, SDL_Event *e)
char *text = SDL_GetClipboardText();
if(text) {
rfbClientLog("sending clipboard text '%s'\n", text);
SendClientCutText(cl, text, strlen(text));
if(!SendClientCutTextUTF8(cl, text, strlen(text)))
SendClientCutText(cl, text, strlen(text));
}
}

Expand Down Expand Up @@ -420,18 +418,37 @@ static rfbBool handleSDLEvent(rfbClient *cl, SDL_Event *e)
return TRUE;
}

static void got_selection(rfbClient *cl, const char *text, int len)
static void got_selection_latin1(rfbClient *cl, const char *text, int len)
{
rfbClientLog("received clipboard text '%s'\n", text);
rfbClientLog("received latin1 clipboard text '%s'\n", text);
if(SDL_SetClipboardText(text) != 0)
rfbClientErr("could not set received clipboard text: %s\n", SDL_GetError());
rfbClientErr("could not set received latin1 clipboard text: %s\n", SDL_GetError());
}

static void got_selection_utf8(rfbClient *cl, const char *buf, int len)
{
rfbClientLog("received utf8 clipboard text '%s'\n", buf);
if(SDL_SetClipboardText(buf) != 0)
rfbClientErr("could not set received utf8 clipboard text: %s\n", SDL_GetError());
}


static rfbCredential* get_credential(rfbClient* cl, int credentialType){
rfbCredential *c = malloc(sizeof(rfbCredential));
rfbCredential *c = malloc(sizeof(rfbCredential));
if (!c) {
return NULL;
}
c->userCredential.username = malloc(RFB_BUF_SIZE);
if (!c->userCredential.username) {
free(c);
return NULL;
}
c->userCredential.password = malloc(RFB_BUF_SIZE);
if (!c->userCredential.password) {
free(c->userCredential.username);
free(c);
return NULL;
}

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

0 comments on commit 2771ce3

Please sign in to comment.