summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSlávek Banko <slavek.banko@axis.cz>2019-02-06 16:56:55 +0100
committerSlávek Banko <slavek.banko@axis.cz>2019-02-06 16:56:55 +0100
commitf3f392caec43b4095bc1d84b315ed7972c13c144 (patch)
tree5c4ba8b5d38f1ae33de71507c5634a15a0b35bfe
parent8c081c8888bccbf5adfe0fc4ec518e2cbfba9871 (diff)
parent0a70095271d845d16a3ed17354841b01f33963ad (diff)
downloadlibtdevnc-f3f392caec43b4095bc1d84b315ed7972c13c144.tar.gz
libtdevnc-f3f392caec43b4095bc1d84b315ed7972c13c144.zip
Merge tag 'LibVNCServer-0.9.12'
Signed-off-by: Slávek Banko <slavek.banko@axis.cz>
-rw-r--r--.appveyor.yml60
-rw-r--r--.gitignore40
-rw-r--r--.travis.yml21
-rw-r--r--CMakeLists.txt403
-rw-r--r--ChangeLog1463
-rw-r--r--LibVNCServer.spec.in97
-rw-r--r--Makefile.am28
-rw-r--r--NEWS35
-rw-r--r--README447
-rw-r--r--[l---------]README.md479
-rw-r--r--TODO23
-rwxr-xr-xautogen.sh4
-rw-r--r--client_examples/Makefile.am38
-rw-r--r--client_examples/SDLvncviewer.c431
-rw-r--r--client_examples/backchannel.c4
-rw-r--r--client_examples/ppmtest.c15
-rw-r--r--client_examples/scrap.c558
-rw-r--r--client_examples/scrap.h18
-rw-r--r--client_examples/vnc2mpg.c688
-rw-r--r--cmake/Modules/FindFFMPEG.cmake227
-rw-r--r--cmake/Modules/FindLZO.cmake31
-rw-r--r--cmake/Modules/FindSDL2.cmake173
-rw-r--r--common/base64.c315
-rw-r--r--common/base64.h10
-rw-r--r--common/d3des.c44
-rw-r--r--common/d3des.h6
-rw-r--r--common/md5.c7
-rw-r--r--common/md5.h20
-rw-r--r--common/rfbcrypto.h (renamed from libvncserver/rfbcrypto.h)6
-rw-r--r--common/rfbcrypto_gnutls.c (renamed from libvncserver/rfbcrypto_gnutls.c)0
-rw-r--r--common/rfbcrypto_included.c (renamed from libvncserver/rfbcrypto_included.c)0
-rw-r--r--common/rfbcrypto_openssl.c (renamed from libvncserver/rfbcrypto_openssl.c)0
-rw-r--r--common/turbojpeg.c6
-rw-r--r--common/vncauth.c7
-rw-r--r--configure.ac599
-rw-r--r--deps/sasl-fix-snprintf-macro.patch26
-rw-r--r--examples/Makefile.am27
-rw-r--r--examples/android/Makefile.am7
-rw-r--r--examples/android/README63
-rw-r--r--examples/android/jni/Android.mk65
-rw-r--r--examples/androidvncserver.c (renamed from examples/android/jni/fbvncserver.c)17
-rw-r--r--examples/repeater.c10
-rw-r--r--examples/vncev.c6
-rw-r--r--libvncclient.pc.cmakein14
-rw-r--r--libvncclient.pc.in14
-rw-r--r--libvncclient/Makefile.am29
-rw-r--r--libvncclient/corre.c6
-rw-r--r--libvncclient/hextile.c8
-rw-r--r--libvncclient/listen.c9
-rw-r--r--libvncclient/rfbproto.c338
-rw-r--r--libvncclient/rre.c4
-rw-r--r--libvncclient/sasl.c582
-rw-r--r--libvncclient/sasl.h39
-rw-r--r--libvncclient/sockets.c66
-rw-r--r--libvncclient/tight.c238
-rw-r--r--libvncclient/tls.h7
-rw-r--r--libvncclient/tls_gnutls.c124
-rw-r--r--libvncclient/tls_none.c11
-rw-r--r--libvncclient/tls_openssl.c274
-rw-r--r--libvncclient/trle.c296
-rw-r--r--libvncclient/ultra.c8
-rw-r--r--libvncclient/vncviewer.c147
-rw-r--r--libvncclient/zlib.c2
-rw-r--r--libvncclient/zrle.c6
-rw-r--r--libvncserver-config.in78
-rw-r--r--libvncserver.pc.cmakein13
-rw-r--r--libvncserver.pc.in14
-rw-r--r--libvncserver/Makefile.am80
-rw-r--r--libvncserver/cargs.c4
-rw-r--r--libvncserver/cursor.c8
-rw-r--r--libvncserver/font.c1
-rw-r--r--libvncserver/httpd.c3
-rw-r--r--libvncserver/main.c74
-rw-r--r--libvncserver/rfbcrypto_polarssl.c26
-rw-r--r--libvncserver/rfbserver.c48
-rw-r--r--libvncserver/scale.c13
-rw-r--r--libvncserver/sockets.c6
-rw-r--r--libvncserver/tableinit24.c11
-rw-r--r--libvncserver/tight.c32
-rw-r--r--libvncserver/tightvnc-filetransfer/filetransfermsg.c16
-rw-r--r--libvncserver/tightvnc-filetransfer/filetransfermsg.h3
-rw-r--r--libvncserver/tightvnc-filetransfer/handlefiletransferrequest.c22
-rw-r--r--libvncserver/tightvnc-filetransfer/rfbtightproto.h1
-rw-r--r--libvncserver/tightvnc-filetransfer/rfbtightserver.c7
-rw-r--r--libvncserver/ultra.c4
-rw-r--r--libvncserver/websockets.c613
-rw-r--r--libvncserver/ws_decode.c563
-rw-r--r--libvncserver/ws_decode.h145
-rw-r--r--libvncserver/zlib.c7
-rw-r--r--m4/.gitignore1
-rw-r--r--m4/ax_prefix_config_h.m4203
-rw-r--r--m4/ax_type_socklen_t.m461
-rw-r--r--m4/libgcrypt.m4123
-rw-r--r--rfb/default8x16.h5
-rw-r--r--rfb/rfb.h9
-rw-r--r--rfb/rfbclient.h69
-rw-r--r--rfb/rfbconfig.h.cmakein (renamed from rfb/rfbconfig.h.cmake)62
-rw-r--r--rfb/rfbint.h.cmake4
-rw-r--r--rfb/rfbproto.h9
-rw-r--r--test/Makefile.am28
-rw-r--r--test/copyrecttest.c1
-rw-r--r--test/tjbench.c15
-rwxr-xr-xtest/wsmaketestframe.py131
-rw-r--r--test/wstest.c206
-rw-r--r--test/wstestdata.inc146
-rw-r--r--webclients/Makefile.am4
-rw-r--r--webclients/index.vnc4
-rw-r--r--webclients/java-applet/Makefile.am5
-rw-r--r--webclients/java-applet/ssl/Makefile.am2
-rw-r--r--webclients/novnc/LICENSE.txt82
-rw-r--r--webclients/novnc/README.md138
-rw-r--r--webclients/novnc/app/error-handler.js56
-rw-r--r--webclients/novnc/app/images/alt.svg92
-rw-r--r--webclients/novnc/app/images/clipboard.svg106
-rw-r--r--webclients/novnc/app/images/connect.svg96
-rw-r--r--webclients/novnc/app/images/ctrl.svg96
-rw-r--r--webclients/novnc/app/images/ctrlaltdel.svg100
-rw-r--r--webclients/novnc/app/images/disconnect.svg94
-rw-r--r--webclients/novnc/app/images/drag.svg76
-rw-r--r--webclients/novnc/app/images/error.svg81
-rw-r--r--webclients/novnc/app/images/esc.svg92
-rw-r--r--webclients/novnc/app/images/expander.svg69
-rw-r--r--webclients/novnc/app/images/fullscreen.svg93
-rw-r--r--webclients/novnc/app/images/handle.svg82
-rw-r--r--webclients/novnc/app/images/handle_bg.svg172
-rw-r--r--webclients/novnc/app/images/icons/Makefile42
-rw-r--r--webclients/novnc/app/images/icons/novnc-120x120.pngbin0 -> 4028 bytes
-rw-r--r--webclients/novnc/app/images/icons/novnc-144x144.pngbin0 -> 4582 bytes
-rw-r--r--webclients/novnc/app/images/icons/novnc-152x152.pngbin0 -> 5216 bytes
-rw-r--r--webclients/novnc/app/images/icons/novnc-16x16.pngbin0 -> 675 bytes
-rw-r--r--webclients/novnc/app/images/icons/novnc-192x192.pngbin0 -> 5787 bytes
-rw-r--r--webclients/novnc/app/images/icons/novnc-24x24.pngbin0 -> 1000 bytes
-rw-r--r--webclients/novnc/app/images/icons/novnc-32x32.pngbin0 -> 1064 bytes
-rw-r--r--webclients/novnc/app/images/icons/novnc-48x48.pngbin0 -> 1397 bytes
-rw-r--r--webclients/novnc/app/images/icons/novnc-60x60.pngbin0 -> 1932 bytes
-rw-r--r--webclients/novnc/app/images/icons/novnc-64x64.pngbin0 -> 1946 bytes
-rw-r--r--webclients/novnc/app/images/icons/novnc-72x72.pngbin0 -> 2699 bytes
-rw-r--r--webclients/novnc/app/images/icons/novnc-76x76.pngbin0 -> 2874 bytes
-rw-r--r--webclients/novnc/app/images/icons/novnc-96x96.pngbin0 -> 2351 bytes
-rw-r--r--webclients/novnc/app/images/icons/novnc-icon-sm.svg163
-rw-r--r--webclients/novnc/app/images/icons/novnc-icon.svg163
-rw-r--r--webclients/novnc/app/images/info.svg81
-rw-r--r--webclients/novnc/app/images/keyboard.svg88
-rw-r--r--webclients/novnc/app/images/mouse_left.svg92
-rw-r--r--webclients/novnc/app/images/mouse_middle.svg92
-rw-r--r--webclients/novnc/app/images/mouse_none.svg92
-rw-r--r--webclients/novnc/app/images/mouse_right.svg92
-rw-r--r--webclients/novnc/app/images/power.svg87
-rw-r--r--webclients/novnc/app/images/settings.svg76
-rw-r--r--webclients/novnc/app/images/tab.svg86
-rw-r--r--webclients/novnc/app/images/toggleextrakeys.svg90
-rw-r--r--webclients/novnc/app/images/warning.svg81
-rw-r--r--webclients/novnc/app/locale/de.json69
-rw-r--r--webclients/novnc/app/locale/el.json69
-rw-r--r--webclients/novnc/app/locale/es.json68
-rw-r--r--webclients/novnc/app/locale/nl.json68
-rw-r--r--webclients/novnc/app/locale/pl.json69
-rw-r--r--webclients/novnc/app/locale/sv.json68
-rw-r--r--webclients/novnc/app/locale/tr.json69
-rw-r--r--webclients/novnc/app/locale/zh.json69
-rw-r--r--webclients/novnc/app/localization.js170
-rw-r--r--webclients/novnc/app/sounds/CREDITS4
-rw-r--r--webclients/novnc/app/sounds/bell.mp3bin0 -> 4531 bytes
-rw-r--r--webclients/novnc/app/sounds/bell.ogabin0 -> 8495 bytes
-rw-r--r--webclients/novnc/app/styles/Orbitron700.ttf (renamed from webclients/novnc/include/Orbitron700.ttf)bin38580 -> 38580 bytes
-rw-r--r--webclients/novnc/app/styles/Orbitron700.woff (renamed from webclients/novnc/include/Orbitron700.woff)bin17472 -> 17472 bytes
-rw-r--r--webclients/novnc/app/styles/base.css902
-rw-r--r--webclients/novnc/app/styles/lite.css63
-rw-r--r--webclients/novnc/app/ui.js1669
-rw-r--r--webclients/novnc/app/webutil.js230
-rw-r--r--webclients/novnc/core/base64.js (renamed from webclients/novnc/include/base64.js)17
-rw-r--r--webclients/novnc/core/des.js (renamed from webclients/novnc/include/des.js)17
-rw-r--r--webclients/novnc/core/display.js698
-rw-r--r--webclients/novnc/core/encodings.js40
-rw-r--r--webclients/novnc/core/inflator.js38
-rw-r--r--webclients/novnc/core/input/domkeytable.js310
-rw-r--r--webclients/novnc/core/input/fixedkeys.js127
-rw-r--r--webclients/novnc/core/input/keyboard.js314
-rw-r--r--webclients/novnc/core/input/keysym.js614
-rw-r--r--webclients/novnc/core/input/keysymdef.js688
-rw-r--r--webclients/novnc/core/input/mouse.js280
-rw-r--r--webclients/novnc/core/input/util.js167
-rw-r--r--webclients/novnc/core/input/vkeys.js116
-rw-r--r--webclients/novnc/core/input/xtscancodes.js171
-rw-r--r--webclients/novnc/core/rfb.js2540
-rw-r--r--webclients/novnc/core/util/browser.js69
-rw-r--r--webclients/novnc/core/util/events.js138
-rw-r--r--webclients/novnc/core/util/eventtarget.js40
-rw-r--r--webclients/novnc/core/util/logging.js51
-rw-r--r--webclients/novnc/core/util/polyfill.js54
-rw-r--r--webclients/novnc/core/util/strings.js15
-rw-r--r--webclients/novnc/core/websock.js316
l---------webclients/novnc/favicon.ico1
-rw-r--r--webclients/novnc/images/alt.pngbin315 -> 0 bytes
-rw-r--r--webclients/novnc/images/clipboard.pngbin388 -> 0 bytes
-rw-r--r--webclients/novnc/images/connect.pngbin319 -> 0 bytes
-rw-r--r--webclients/novnc/images/ctrl.pngbin339 -> 0 bytes
-rw-r--r--webclients/novnc/images/ctrlaltdel.pngbin254 -> 0 bytes
-rw-r--r--webclients/novnc/images/disconnect.pngbin907 -> 0 bytes
-rw-r--r--webclients/novnc/images/drag.pngbin776 -> 0 bytes
-rw-r--r--webclients/novnc/images/esc.pngbin351 -> 0 bytes
-rw-r--r--webclients/novnc/images/favicon.icobin1150 -> 0 bytes
-rw-r--r--webclients/novnc/images/favicon.pngbin354 -> 0 bytes
-rw-r--r--webclients/novnc/images/keyboard.pngbin1059 -> 0 bytes
-rw-r--r--webclients/novnc/images/mouse_left.pngbin410 -> 0 bytes
-rw-r--r--webclients/novnc/images/mouse_middle.pngbin412 -> 0 bytes
-rw-r--r--webclients/novnc/images/mouse_none.pngbin400 -> 0 bytes
-rw-r--r--webclients/novnc/images/mouse_right.pngbin413 -> 0 bytes
-rw-r--r--webclients/novnc/images/power.pngbin328 -> 0 bytes
-rw-r--r--webclients/novnc/images/screen_320x460.pngbin10553 -> 0 bytes
-rw-r--r--webclients/novnc/images/screen_57x57.pngbin1604 -> 0 bytes
-rw-r--r--webclients/novnc/images/screen_700x700.pngbin17856 -> 0 bytes
-rw-r--r--webclients/novnc/images/settings.pngbin2224 -> 0 bytes
-rw-r--r--webclients/novnc/images/showextrakeys.pngbin608 -> 0 bytes
-rw-r--r--webclients/novnc/images/tab.pngbin361 -> 0 bytes
-rw-r--r--webclients/novnc/include/base.css512
-rw-r--r--webclients/novnc/include/black.css71
-rw-r--r--webclients/novnc/include/blue.css64
-rw-r--r--webclients/novnc/include/chrome-app/tcp-client.js321
-rw-r--r--webclients/novnc/include/display.js746
-rw-r--r--webclients/novnc/include/input.js388
-rw-r--r--webclients/novnc/include/jsunzip.js676
-rw-r--r--webclients/novnc/include/keyboard.js543
-rw-r--r--webclients/novnc/include/keysym.js378
-rw-r--r--webclients/novnc/include/keysymdef.js15
-rw-r--r--webclients/novnc/include/logo.js1
-rw-r--r--webclients/novnc/include/playback.js102
-rw-r--r--webclients/novnc/include/rfb.js1882
-rw-r--r--webclients/novnc/include/ui.js979
-rw-r--r--webclients/novnc/include/util.js656
-rw-r--r--webclients/novnc/include/web-socket-js/README.txt109
-rw-r--r--webclients/novnc/include/web-socket-js/WebSocketMain.swfbin177139 -> 0 bytes
-rw-r--r--webclients/novnc/include/web-socket-js/swfobject.js4
-rw-r--r--webclients/novnc/include/web-socket-js/web_socket.js391
-rw-r--r--webclients/novnc/include/websock.js384
-rw-r--r--webclients/novnc/include/webutil.js239
-rw-r--r--webclients/novnc/vendor/browser-es-module-loader/.npmignore0
-rw-r--r--webclients/novnc/vendor/browser-es-module-loader/README.md15
-rw-r--r--webclients/novnc/vendor/browser-es-module-loader/dist/babel-worker.js44024
-rw-r--r--webclients/novnc/vendor/browser-es-module-loader/dist/browser-es-module-loader.js1420
-rw-r--r--webclients/novnc/vendor/browser-es-module-loader/dist/browser-es-module-loader.js.map1
-rw-r--r--webclients/novnc/vendor/browser-es-module-loader/rollup.config.js16
-rw-r--r--webclients/novnc/vendor/browser-es-module-loader/src/babel-worker.js23
-rw-r--r--webclients/novnc/vendor/browser-es-module-loader/src/browser-es-module-loader.js273
-rw-r--r--webclients/novnc/vendor/pako/LICENSE21
-rw-r--r--webclients/novnc/vendor/pako/README.md6
-rw-r--r--webclients/novnc/vendor/pako/lib/utils/common.js45
-rw-r--r--webclients/novnc/vendor/pako/lib/zlib/adler32.js27
-rw-r--r--webclients/novnc/vendor/pako/lib/zlib/constants.js47
-rw-r--r--webclients/novnc/vendor/pako/lib/zlib/crc32.js36
-rw-r--r--webclients/novnc/vendor/pako/lib/zlib/deflate.js1846
-rw-r--r--webclients/novnc/vendor/pako/lib/zlib/gzheader.js35
-rw-r--r--webclients/novnc/vendor/pako/lib/zlib/inffast.js324
-rw-r--r--webclients/novnc/vendor/pako/lib/zlib/inflate.js1527
-rw-r--r--webclients/novnc/vendor/pako/lib/zlib/inftrees.js322
-rw-r--r--webclients/novnc/vendor/pako/lib/zlib/messages.js11
-rw-r--r--webclients/novnc/vendor/pako/lib/zlib/trees.js1195
-rw-r--r--webclients/novnc/vendor/pako/lib/zlib/zstream.js24
-rw-r--r--webclients/novnc/vendor/promise.js255
-rw-r--r--webclients/novnc/vendor/sinon.js14043
-rw-r--r--webclients/novnc/vnc.html437
-rw-r--r--webclients/novnc/vnc_auto.html209
262 files changed, 85823 insertions, 13704 deletions
diff --git a/.appveyor.yml b/.appveyor.yml
new file mode 100644
index 0000000..b176d7c
--- /dev/null
+++ b/.appveyor.yml
@@ -0,0 +1,60 @@
+
+environment:
+ matrix:
+ - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
+ DEVENV_EXE: C:\"Program Files (x86)"\"Microsoft Visual Studio 14.0"\Common7\IDE\devenv.exe
+ VSDEVCMD_BAT: C:\"Program Files (x86)"\"Microsoft Visual Studio 14.0"\Common7\Tools\VsDevCmd.bat
+ - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
+ DEVENV_EXE: C:\"Program Files (x86)"\"Microsoft Visual Studio"\2017\Community\Common7\IDE\devenv.exe
+ VSDEVCMD_BAT: C:\"Program Files (x86)"\"Microsoft Visual Studio"\2017\Community\Common7\Tools\VsDevCmd.bat
+
+install:
+ - if not exist deps mkdir deps
+ - cd deps
+ # zlib
+ - curl -fsSL -o zlib.tar.gz https://github.com/madler/zlib/archive/v1.2.8.tar.gz
+ - 7z x zlib.tar.gz -so | 7z x -si -ttar > nul
+ - move zlib-1.2.8 zlib
+ - cd zlib
+ - cmake .
+ - cmake --build .
+ - cd ..
+ # libPNG
+ - curl -fsSL -o libpng.tar.gz http://prdownloads.sourceforge.net/libpng/libpng-1.6.28.tar.gz?download
+ - 7z x libpng.tar.gz -so | 7z x -si -ttar > nul
+ - move libpng-1.6.28 libpng
+ - cd libpng
+ - cmake . -DZLIB_INCLUDE_DIR=..\zlib -DZLIB_LIBRARY=..\zlib\debug\zlibstaticd.lib
+ - cmake --build .
+ - cd ..
+ # Berkeley DB - required by SASL
+ - curl -fsSL -o db-4.1.25.tar.gz http://download.oracle.com/berkeley-db/db-4.1.25.tar.gz
+ - 7z x db-4.1.25.tar.gz -so | 7z x -si -ttar > nul
+ - move db-4.1.25 db
+ - cd db\build_win32
+ - echo using devenv %DEVENV_EXE%
+ - '%DEVENV_EXE% db_dll.dsp /upgrade'
+ - msbuild /p:Configuration=Release db_dll.vcxproj
+ - cd ..\..
+ # Cyrus SASL
+ - curl -fsSL -o cyrus-sasl-2.1.26.tar.gz https://www.cyrusimap.org/releases/cyrus-sasl-2.1.26.tar.gz
+ - 7z x cyrus-sasl-2.1.26.tar.gz -so | 7z x -si -ttar > nul
+ - move cyrus-sasl-2.1.26 sasl
+ - cd sasl
+ - patch -p1 -i ..\sasl-fix-snprintf-macro.patch
+ - echo using vsdevcmd %VSDEVCMD_BAT%
+ - '%VSDEVCMD_BAT%'
+ - nmake /f NTMakefile OPENSSL_INCLUDE=c:\OpenSSL-Win32\include OPENSSL_LIBPATH=c:\OpenSSL-Win32\lib DB_INCLUDE=c:\projects\libvncserver\deps\db\build_win32 DB_LIBPATH=c:\projects\libvncserver\deps\db\build_win32\release DB_LIB=libdb41.lib install
+ - cd ..
+ # go back to source root
+ - cd ..
+
+build_script:
+ - mkdir build
+ - cd build
+ - cmake --version
+ - cmake .. -DZLIB_INCLUDE_DIR=..\deps\zlib -DZLIB_LIBRARY=..\deps\zlib\debug\zlibstaticd.lib -DPNG_PNG_INCLUDE_DIR=..\deps\libpng -DPNG_LIBRARY=..\deps\libpng\debug\libpng16_staticd.lib -D SASL2_INCLUDE_DIR=c:\cmu\include -D LIBSASL2_LIBRARIES=c:\cmu\lib\libsasl.lib ..
+ - cmake --build .
+ - ctest -C Debug --output-on-failure
+
+
diff --git a/.gitignore b/.gitignore
index fccd7af..8121c9d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,44 +2,24 @@
*~
Makefile
Makefile.in
-compile
-configure
-configure.lineno
-config.status
-config.log
LibVNCServer.spec.in
LibVNCServer.spec
-x11vnc.spec.in
-.deps
-.libs
-aclocal.m4
-autom4te.cache
libvncserver-config
*.pc
-_configs.sed
-config.h
LibVNCServer*.tar.gz
-upload_beta.sh
-stamp-*
-x11vnc*.tar.gz
config.h.in
rfbconfig.h
rfbconfig.h.in
-install-sh
-missing
-mkinstalldirs
-depcomp
-description-pak
-libvncserver*.deb
*.o
-*.lo
-CVS
+*.a
+*.so
+*.so.*
client_examples/SDLvncviewer
client_examples/backchannel
client_examples/gtkvncviewer
client_examples/ppmtest
-config.guess
-config.sub
+client_examples/vnc2mpg
+build/
examples/zippy
examples/backchannel
examples/blooptest
@@ -58,14 +38,12 @@ examples/simple
examples/simple15
examples/storepasswd
examples/vncev
-libtool
-libvncclient/libvncclient.la
-libvncserver/libvncserver.la
test/blooptest
test/cargstest
test/copyrecttest
test/cursortest
test/encodingstest
+test/wstest
/test/tjbench
/test/tjunittest
vncterm/LinuxVNC
@@ -73,14 +51,10 @@ vncterm/VNCommand
vncterm/example
/vncterm/linuxvnc
/vncterm/vncommand
-x11vnc.spec
-x11vnc/x11vnc
CMakeCache.txt
-cmake_install.cmake
+*.cmake
/CMakeFiles
/rfbproto.pdf
/rfbproto.rst
/vencrypt.txt
/INSTALL
-.dirstamp
-/ltmain.sh
diff --git a/.travis.yml b/.travis.yml
index 99ff4b6..dde1238 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,4 +1,6 @@
language: c
+dist: trusty
+sudo: required
os:
- linux
@@ -9,7 +11,20 @@ compiler:
- clang
before_install:
-- 'if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then export CFLAGS="-I/usr/local/opt/openssl/include $CFLAGS" LDFLAGS="-L/usr/local/opt/openssl/lib $LDFLAGS"; fi'
+- |
+ if [[ "${TRAVIS_OS_NAME}" == "linux" ]]; then
+ CMAKE_URL="http://www.cmake.org/files/v3.7/cmake-3.7.2-Linux-x86_64.tar.gz"
+ mkdir -p ${TRAVIS_BUILD_DIR}/deps/cmake && travis_retry wget --quiet -O - ${CMAKE_URL} | tar --strip-components=1 -xz -C ${TRAVIS_BUILD_DIR}/deps/cmake
+ export PATH=${TRAVIS_BUILD_DIR}/deps/cmake/bin:${PATH}
+ fi
+
+# Build steps
+script:
+ - mkdir build
+ - cd build
+ - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get update; sudo apt-get --no-install-suggests --no-install-recommends install libsdl2-dev liblzo2-dev; fi
+ - if [[ "${TRAVIS_OS_NAME}" == "osx" ]]; then brew update; brew install sdl2; fi
+ - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then cmake .. -DOPENSSL_ROOT_DIR=/usr/local/opt/openssl; else cmake ..; fi
+ - cmake --build .
+ - ctest --output-on-failure
-# before build script, run autoreconf
-before_script: autoreconf -fiv \ No newline at end of file
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 37f88e0..c6525ff 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -5,139 +5,142 @@ endif( POLICY CMP0037 )
project(LibVNCServer)
include(CheckFunctionExists)
+include(CheckSymbolExists)
include(CheckIncludeFile)
include(CheckTypeSize)
include(TestBigEndian)
include(CheckCSourceCompiles)
-include(CheckCXXSourceCompiles)
include(CheckCSourceRuns)
+enable_testing()
+
set(PACKAGE_NAME "LibVNCServer")
set(FULL_PACKAGE_NAME "LibVNCServer")
set(VERSION_MAJOR "0")
set(VERSION_MINOR "9")
-set(VERSION_PATCHLEVEL "11")
-set(VERSION_SO "0")
+set(VERSION_PATCHLEVEL "12")
+set(VERSION_SO "1")
set(PACKAGE_VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCHLEVEL}")
-set(PROJECT_BUGREPORT_PATH "http://sourceforge.net/projects/libvncserver")
-set(CMAKE_C_FLAGS "-O2 -W -Wall -g")
+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(LIBVNCSRVTEST_DIR ${CMAKE_CURRENT_SOURCE_DIR}/examples)
-set(LIBVNCCLITEST_DIR ${CMAKE_CURRENT_SOURCE_DIR}/client_examples)
+set(LIBVNCSRVEXAMPLE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/examples)
+set(LIBVNCCLIEXAMPLE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/client_examples)
+set(TESTS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/test)
+set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
+set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/libvncserver ${CMAKE_CURRENT_SOURCE_DIR}/common)
-find_package(ZLIB)
-find_package(JPEG)
-find_package(PNG)
-find_package(SDL)
-find_package(GnuTLS)
-find_package(Threads)
-find_package(X11)
-find_package(OpenSSL)
-find_package(PkgConfig)
-find_library(LIBGCRYPT_LIBRARIES gcrypt)
-
-# Check whether the version of libjpeg we found was libjpeg-turbo and print a
-# warning if not.
-set(CMAKE_REQUIRED_LIBRARIES ${JPEG_LIBRARIES})
-set(CMAKE_REQUIRED_FLAGS -I${JPEG_INCLUDE_DIR})
-
-set(JPEG_TEST_SOURCE "\n
- #include <stdio.h>\n
- #include <jpeglib.h>\n
- int main(void) {\n
- struct jpeg_compress_struct cinfo;\n
- struct jpeg_error_mgr jerr;\n
- cinfo.err=jpeg_std_error(&jerr);\n
- jpeg_create_compress(&cinfo);\n
- cinfo.input_components = 3;\n
- jpeg_set_defaults(&cinfo);\n
- cinfo.in_color_space = JCS_EXT_RGB;\n
- jpeg_default_colorspace(&cinfo);\n
- return 0;\n
- }")
-
-if(CMAKE_CROSSCOMPILING)
- check_c_source_compiles("${JPEG_TEST_SOURCE}" FOUND_LIBJPEG_TURBO)
-else()
- check_c_source_runs("${JPEG_TEST_SOURCE}" FOUND_LIBJPEG_TURBO)
+# all the build configuration switches
+option(BUILD_SHARED_LIBS "Build shared libraries" ${UNIX})
+option(WITH_ZLIB "Search for the zlib compression library to support additional encodings" ON)
+option(WITH_LZO "Search for the LZO compression library to omit internal miniLZO implementation" ON)
+option(WITH_JPEG "Search for the libjpeg compression library to support additional encodings" ON)
+option(WITH_PNG "Search for the PNG compression library to support additional encodings" ON)
+option(WITH_SDL "Search for the Simple Direct Media Layer library to build an example SDL vnc client" ON)
+option(WITH_THREADS "Search for a threading library to build with multithreading support" ON)
+option(WITH_GNUTLS "Search for the GnuTLS secure communications library to support encryption" ON)
+option(WITH_OPENSSL "Search for the OpenSSL cryptography library to support encryption" ON)
+option(WITH_SYSTEMD "Search for libsystemd to build with systemd socket activation support" ON)
+option(WITH_GCRYPT "Search for libgcrypt to support additional authentication methods in LibVNCClient" ON)
+option(WITH_FFMPEG "Search for FFMPEG to build an example VNC to MPEG encoder" ON)
+option(WITH_TIGHTVNC_FILETRANSFER "Enable filetransfer if there is pthreads support" ON)
+option(WITH_24BPP "Allow 24 bpp" ON)
+option(WITH_IPv6 "Enable IPv6 Support" ON)
+option(WITH_WEBSOCKETS "Build with websockets support" ON)
+option(WITH_SASL "Build with SASL support" ON)
+
+
+
+if(WITH_ZLIB)
+ find_package(ZLIB)
+endif(WITH_ZLIB)
+
+if(WITH_LZO)
+ find_package(LZO)
endif()
-set(CMAKE_REQUIRED_LIBRARIES)
-set(CMAKE_REQUIRED_FLAGS)
-set(CMAKE_REQUIRED_DEFINITIONS)
-
-if(NOT FOUND_LIBJPEG_TURBO)
- message(WARNING "*** The libjpeg library you are building against is not libjpeg-turbo. Performance will be reduced. You can obtain libjpeg-turbo from: https://sourceforge.net/projects/libjpeg-turbo/files/ ***")
-endif()
+if(WITH_JPEG)
+ find_package(JPEG)
+ if(JPEG_FOUND)
+ # Check whether the version of libjpeg we found was libjpeg-turbo and print a
+ # warning if not.
+ set(CMAKE_REQUIRED_LIBRARIES ${JPEG_LIBRARIES})
+ set(CMAKE_REQUIRED_FLAGS -I${JPEG_INCLUDE_DIR})
+
+ set(JPEG_TEST_SOURCE "\n
+ #include <stdio.h>\n
+ #include <jpeglib.h>\n
+ int main(void) {\n
+ struct jpeg_compress_struct cinfo;\n
+ struct jpeg_error_mgr jerr;\n
+ cinfo.err=jpeg_std_error(&jerr);\n
+ jpeg_create_compress(&cinfo);\n
+ cinfo.input_components = 3;\n
+ jpeg_set_defaults(&cinfo);\n
+ cinfo.in_color_space = JCS_EXT_RGB;\n
+ jpeg_default_colorspace(&cinfo);\n
+ return 0;\n
+ }")
+
+ if(CMAKE_CROSSCOMPILING)
+ check_c_source_compiles("${JPEG_TEST_SOURCE}" FOUND_LIBJPEG_TURBO)
+ else()
+ check_c_source_runs("${JPEG_TEST_SOURCE}" FOUND_LIBJPEG_TURBO)
+ endif()
-# On systems such as GNU/Linux with glibc, __b64_ntop is defined in a
-# separate library, libresolv. On some others, such as FreeBSD, it is
-# part of libc itself. We first check if __b64_ntop is found without
-# additional libraries, and then try looking for it with libresolv if
-# the first test fails.
-check_function_exists(__b64_ntop HAVE_B64_IN_LIBC)
-if(NOT HAVE_B64_IN_LIBC)
- set(CMAKE_REQUIRED_LIBRARIES resolv)
- check_function_exists(__b64_ntop HAVE_B64_IN_LIBRESOLV)
set(CMAKE_REQUIRED_LIBRARIES)
+ set(CMAKE_REQUIRED_FLAGS)
+ set(CMAKE_REQUIRED_DEFINITIONS)
- if(HAVE_B64_IN_LIBRESOLV)
- set(RESOLV_LIB "resolv")
- endif(HAVE_B64_IN_LIBRESOLV)
-endif(NOT HAVE_B64_IN_LIBC)
+ if(NOT FOUND_LIBJPEG_TURBO)
+ message(WARNING "*** The libjpeg library you are building against is not libjpeg-turbo. Performance will be reduced. You can obtain libjpeg-turbo from: https://sourceforge.net/projects/libjpeg-turbo/files/ ***")
+ endif()
+ endif(JPEG_FOUND)
+endif(WITH_JPEG)
-if(Threads_FOUND)
- option(TIGHTVNC_FILETRANSFER "Enable filetransfer" ON)
-endif(Threads_FOUND)
-if(ZLIB_FOUND)
- set(LIBVNCSERVER_HAVE_LIBZ 1)
-endif(ZLIB_FOUND)
-if(JPEG_FOUND)
- set(LIBVNCSERVER_HAVE_LIBJPEG 1)
-endif(JPEG_FOUND)
-if(PNG_FOUND)
- set(LIBVNCSERVER_HAVE_LIBPNG 1)
-endif(PNG_FOUND)
-option(LIBVNCSERVER_ALLOW24BPP "Allow 24 bpp" ON)
-pkg_check_modules(SYSTEMD "libsystemd")
-if(SYSTEMD_FOUND)
- option(LIBVNCSERVER_WITH_SYSTEMD "Build with systemd socket activation support" ON)
-endif(SYSTEMD_FOUND)
+if(WITH_PNG)
+ find_package(PNG)
+endif(WITH_PNG)
-if(LIBVNCSERVER_WITH_SYSTEMD)
- add_definitions(-DLIBVNCSERVER_WITH_SYSTEMD)
- include_directories(${SYSTEMD_INCLUDE_DIRS})
- set(ADDITIONAL_LIBS ${ADDITIONAL_LIBS} ${SYSTEMD_LIBRARIES})
-endif(LIBVNCSERVER_WITH_SYSTEMD)
-if(GNUTLS_FOUND)
- set(LIBVNCSERVER_WITH_CLIENT_TLS 1)
- option(LIBVNCSERVER_WITH_WEBSOCKETS "Build with websockets support (gnutls)" ON)
- set(WEBSOCKET_LIBRARIES ${RESOLV_LIB} ${GNUTLS_LIBRARIES})
- set(WSSRCS ${LIBVNCSERVER_DIR}/rfbssl_gnutls.c ${LIBVNCSERVER_DIR}/rfbcrypto_gnutls.c)
- include_directories(${GNUTLS_INCLUDE_DIR})
-elseif(OPENSSL_FOUND)
- option(LIBVNCSERVER_WITH_WEBSOCKETS "Build with websockets support (openssl)" ON)
- set(WEBSOCKET_LIBRARIES ${RESOLV_LIB} ${OPENSSL_LIBRARIES})
- set(WSSRCS ${LIBVNCSERVER_DIR}/rfbssl_openssl.c ${LIBVNCSERVER_DIR}/rfbcrypto_openssl.c)
- include_directories(${OPENSSL_INCLUDE_DIR})
-else()
- option(LIBVNCSERVER_WITH_WEBSOCKETS "Build with websockets support (no ssl)" ON)
- set(WEBSOCKET_LIBRARIES ${RESOLV_LIB})
- set(WSSRCS ${LIBVNCSERVER_DIR}/rfbssl_none.c ${LIBVNCSERVER_DIR}/rfbcrypto_included.c ${COMMON_DIR}/md5.c ${COMMON_DIR}/sha1.c)
-endif()
+if(WITH_SDL)
+ find_package(SDL2)
+endif(WITH_SDL)
+
+
+if(WITH_THREADS)
+ find_package(Threads)
+endif(WITH_THREADS)
+
+
+if(WITH_GNUTLS)
+ find_package(GnuTLS)
+endif(WITH_GNUTLS)
+
+
+if(WITH_OPENSSL)
+ find_package(OpenSSL)
+endif(WITH_OPENSSL)
-if(LIBGCRYPT_LIBRARIES)
- message(STATUS "Found libgcrypt: ${LIBGCRYPT_LIBRARIES}")
- set(LIBVNCSERVER_WITH_CLIENT_GCRYPT 1)
- set(ADDITIONAL_LIBS ${ADDITIONAL_LIBS} ${LIBGCRYPT_LIBRARIES})
-endif(LIBGCRYPT_LIBRARIES)
+
+if(WITH_SYSTEMD AND NOT ANDROID)
+ find_package(PkgConfig)
+ pkg_check_modules(SYSTEMD "libsystemd")
+endif(WITH_SYSTEMD AND NOT ANDROID)
+
+
+if(WITH_GCRYPT)
+ find_library(LIBGCRYPT_LIBRARIES gcrypt)
+endif(WITH_GCRYPT)
+
+if(WITH_FFMPEG)
+ find_package(FFMPEG 3.1.0)
+endif(WITH_FFMPEG)
check_include_file("endian.h" LIBVNCSERVER_HAVE_ENDIAN_H)
@@ -150,6 +153,8 @@ check_include_file("sys/time.h" LIBVNCSERVER_HAVE_SYS_TIME_H)
check_include_file("sys/types.h" LIBVNCSERVER_HAVE_SYS_TYPES_H)
check_include_file("sys/wait.h" LIBVNCSERVER_HAVE_SYS_WAIT_H)
check_include_file("unistd.h" LIBVNCSERVER_HAVE_UNISTD_H)
+check_include_file("sys/uio.h" LIBVNCSERVER_HAVE_SYS_UIO_H)
+
# headers needed for check_type_size()
check_include_file("vfork.h" LIBVNCSERVER_HAVE_VFORK_H)
@@ -159,15 +164,115 @@ check_include_file("stdint.h" HAVE_STDINT_H)
check_include_file("stddef.h" HAVE_STDDEF_H)
check_include_file("sys/types.h" HAVE_SYS_TYPES_H)
+# error out if required headers not found
+if(NOT HAVE_STDINT_H)
+ message(FATAL_ERROR "Could NOT find required header stdint.h")
+endif()
+
check_function_exists(gettimeofday LIBVNCSERVER_HAVE_GETTIMEOFDAY)
check_function_exists(vfork LIBVNCSERVER_HAVE_VFORK)
check_function_exists(vprintf LIBVNCSERVER_HAVE_VPRINTF)
+check_function_exists(mmap LIBVNCSERVER_HAVE_MMAP)
+check_function_exists(fork LIBVNCSERVER_HAVE_FORK)
+check_function_exists(ftime LIBVNCSERVER_HAVE_FTIME)
+check_function_exists(gethostbyname LIBVNCSERVER_HAVE_GETHOSTBYNAME)
+check_function_exists(gethostname LIBVNCSERVER_HAVE_GETHOSTNAME)
+check_function_exists(inet_ntoa LIBVNCSERVER_HAVE_INET_NTOA)
+check_function_exists(memmove LIBVNCSERVER_HAVE_MEMMOVE)
+check_function_exists(memset LIBVNCSERVER_HAVE_MEMSET)
+check_function_exists(mkfifo LIBVNCSERVER_HAVE_MKFIFO)
+check_function_exists(select LIBVNCSERVER_HAVE_SELECT)
+check_function_exists(socket LIBVNCSERVER_HAVE_SOCKET)
+check_function_exists(strchr LIBVNCSERVER_HAVE_STRCHR)
+check_function_exists(strcspn LIBVNCSERVER_HAVE_STRCSPN)
+check_function_exists(strdup LIBVNCSERVER_HAVE_STRDUP)
+check_function_exists(strerror LIBVNCSERVER_HAVE_STRERROR)
+check_function_exists(strstr LIBVNCSERVER_HAVE_STRSTR)
+
+check_symbol_exists(htobe64 "endian.h" LIBVNCSERVER_HAVE_HTOBE64)
+check_symbol_exists(OSSwapHostToBigInt64 "libkern/OSByteOrder.h" LIBVNCSERVER_HAVE_OSSWAPHOSTTOBIGINT64)
+
+if(Threads_FOUND)
+ set(ADDITIONAL_LIBS ${ADDITIONAL_LIBS} ${CMAKE_THREAD_LIBS_INIT})
+endif(Threads_FOUND)
+if(ZLIB_FOUND)
+ set(LIBVNCSERVER_HAVE_LIBZ 1)
+else()
+ unset(ZLIB_LIBRARIES) # would otherwise contain -NOTFOUND, confusing target_link_libraries()
+endif(ZLIB_FOUND)
+if(LZO_FOUND)
+ set(LIBVNCSERVER_HAVE_LZO 1)
+else()
+ unset(LZO_LIBRARIES CACHE) # would otherwise contain -NOTFOUND, confusing target_link_libraries()
+endif()
+if(JPEG_FOUND)
+ set(LIBVNCSERVER_HAVE_LIBJPEG 1)
+else()
+ unset(JPEG_LIBRARIES) # would otherwise confuse target_link_libraries()
+endif(JPEG_FOUND)
+if(PNG_FOUND)
+ set(LIBVNCSERVER_HAVE_LIBPNG 1)
+endif(PNG_FOUND)
+if(NOT OPENSSL_FOUND)
+ unset(OPENSSL_LIBRARIES) # would otherwise contain -NOTFOUND, confusing target_link_libraries()
+endif()
+if(SYSTEMD_FOUND)
+ add_definitions(-DLIBVNCSERVER_WITH_SYSTEMD)
+ include_directories(${SYSTEMD_INCLUDE_DIRS})
+ set(ADDITIONAL_LIBS ${ADDITIONAL_LIBS} ${SYSTEMD_LIBRARIES})
+endif(SYSTEMD_FOUND)
+
+if(LIBVNCSERVER_HAVE_SYS_UIO_H)
+ if(GNUTLS_FOUND)
+ message(STATUS "Building crypto with GnuTLS")
+ set(CRYPTO_LIBRARIES ${GNUTLS_LIBRARIES})
+ set(CRYPTO_SOURCES ${COMMON_DIR}/rfbcrypto_gnutls.c)
+ include_directories(${GNUTLS_INCLUDE_DIR})
+ elseif(OPENSSL_FOUND)
+ message(STATUS "Building crypto with OpenSSL")
+ set(CRYPTO_LIBRARIES ${OPENSSL_LIBRARIES})
+ set(CRYPTO_SOURCES ${COMMON_DIR}/rfbcrypto_openssl.c)
+ else()
+ message(STATUS "Building crypto with builtin functions")
+ set(CRYPTO_SOURCES ${COMMON_DIR}/rfbcrypto_included.c ${COMMON_DIR}/md5.c ${COMMON_DIR}/sha1.c)
+ endif()
+ set(LIBVNCSERVER_HAVE_CRYPTO 1)
+endif(LIBVNCSERVER_HAVE_SYS_UIO_H)
+
+
+if(WITH_WEBSOCKETS AND LIBVNCSERVER_HAVE_CRYPTO AND (LIBVNCSERVER_HAVE_HTOBE64 OR LIBVNCSERVER_HAVE_OSSWAPHOSTTOBIGINT64))
+ set(LIBVNCSERVER_WITH_WEBSOCKETS 1)
+endif()
+
+if(WITH_GCRYPT AND LIBGCRYPT_LIBRARIES)
+ message(STATUS "Found libgcrypt: ${LIBGCRYPT_LIBRARIES}")
+ set(LIBVNCSERVER_WITH_CLIENT_GCRYPT 1)
+ set(ADDITIONAL_LIBS ${ADDITIONAL_LIBS} ${LIBGCRYPT_LIBRARIES})
+endif(WITH_GCRYPT AND LIBGCRYPT_LIBRARIES)
+
+if(GNUTLS_FOUND)
+ set(LIBVNCSERVER_HAVE_GNUTLS 1)
+endif(GNUTLS_FOUND)
+
+if(OPENSSL_FOUND)
+ set(LIBVNCSERVER_HAVE_LIBSSL 1)
+endif(OPENSSL_FOUND)
+
+if(WITH_IPv6)
+ if(WIN32 AND LIBVNCSERVER_HAVE_WS2TCPIP_H AND LIBVNCSERVER_HAVE_VPRINTF)
+ set(LIBVNCSERVER_IPv6 1)
+ endif()
+ if(NOT WIN32)
+ set(LIBVNCSERVER_IPv6 1)
+ endif()
+endif(WITH_IPv6)
-if(LIBVNCSERVER_HAVE_WS2TCPIP_H AND LIBVNCSERVER_HAVE_VPRINTF)
- option(LIBVNCSERVER_IPv6 "Enable IPv6 Support" ON)
+if(WITH_24BPP)
+ set(LIBVNCSERVER_ALLOW24BPP 1)
endif()
+
if(CMAKE_USE_PTHREADS_INIT)
set(LIBVNCSERVER_HAVE_LIBPTHREAD 1)
endif(CMAKE_USE_PTHREADS_INIT)
@@ -190,11 +295,23 @@ endif(NOT HAVE_LIBVNCSERVER_IN_ADDR_T)
TEST_BIG_ENDIAN(LIBVNCSERVER_WORDS_BIGENDIAN)
+if(WITH_SASL)
+ find_path(SASL2_INCLUDE_DIR sasl/sasl.h)
+ find_library(LIBSASL2_LIBRARIES sasl2 libsasl.lib)
+endif(WITH_SASL)
+
+if(WITH_SASL AND LIBSASL2_LIBRARIES AND SASL2_INCLUDE_DIR)
+ message(STATUS "Building with SASL: ${LIBSASL2_LIBRARIES} and ${SASL2_INCLUDE_DIR}")
+ set(LIBVNCSERVER_HAVE_SASL 1)
+ set(ADDITIONAL_LIBS ${ADDITIONAL_LIBS} ${LIBSASL2_LIBRARIES})
+ include_directories(${SASL2_INCLUDE_DIR})
+endif(WITH_SASL AND LIBSASL2_LIBRARIES AND SASL2_INCLUDE_DIR)
+
# TODO:
# LIBVNCSERVER_ENOENT_WORKAROUND
# inline
-configure_file(${CMAKE_CURRENT_SOURCE_DIR}/rfb/rfbconfig.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/rfb/rfbconfig.h)
+configure_file(${CMAKE_CURRENT_SOURCE_DIR}/rfb/rfbconfig.h.cmakein ${CMAKE_CURRENT_BINARY_DIR}/rfb/rfbconfig.h)
set(LIBVNCSERVER_SOURCES
${LIBVNCSERVER_DIR}/main.cc
@@ -216,7 +333,6 @@ set(LIBVNCSERVER_SOURCES
${COMMON_DIR}/d3des.c
${COMMON_DIR}/vncauth.c
${LIBVNCSERVER_DIR}/cargs.c
- ${COMMON_DIR}/minilzo.c
${LIBVNCSERVER_DIR}/ultra.c
${LIBVNCSERVER_DIR}/scale.c
)
@@ -227,24 +343,51 @@ set(LIBVNCCLIENT_SOURCES
${LIBVNCCLIENT_DIR}/rfbproto.c
${LIBVNCCLIENT_DIR}/sockets.c
${LIBVNCCLIENT_DIR}/vncviewer.c
- ${COMMON_DIR}/minilzo.c
)
+if(JPEG_FOUND)
+ set(LIBVNCCLIENT_SOURCES
+ ${LIBVNCCLIENT_SOURCES}
+ ${COMMON_DIR}/turbojpeg.c
+ )
+endif()
+
if(GNUTLS_FOUND)
set(LIBVNCCLIENT_SOURCES
${LIBVNCCLIENT_SOURCES}
${LIBVNCCLIENT_DIR}/tls_gnutls.c
)
+ set(LIBVNCSERVER_SOURCES
+ ${LIBVNCSERVER_SOURCES}
+ ${LIBVNCSERVER_DIR}/rfbssl_gnutls.c
+ )
+ include_directories(${GNUTLS_INCLUDE_DIR})
elseif(OPENSSL_FOUND)
set(LIBVNCCLIENT_SOURCES
${LIBVNCCLIENT_SOURCES}
${LIBVNCCLIENT_DIR}/tls_openssl.c
)
+ set(LIBVNCSERVER_SOURCES
+ ${LIBVNCSERVER_SOURCES}
+ ${LIBVNCSERVER_DIR}/rfbssl_openssl.c
+ )
+ include_directories(${OPENSSL_INCLUDE_DIR})
else()
set(LIBVNCCLIENT_SOURCES
${LIBVNCCLIENT_SOURCES}
${LIBVNCCLIENT_DIR}/tls_none.c
)
+ set(LIBVNCSERVER_SOURCES
+ ${LIBVNCSERVER_SOURCES}
+ ${LIBVNCSERVER_DIR}/rfbssl_none.c
+ )
+endif()
+
+if(LIBVNCSERVER_HAVE_SASL)
+ set(LIBVNCCLIENT_SOURCES
+ ${LIBVNCCLIENT_SOURCES}
+ ${LIBVNCCLIENT_DIR}/sasl.c
+ )
endif()
if(ZLIB_FOUND)
@@ -259,6 +402,20 @@ if(ZLIB_FOUND)
)
endif(ZLIB_FOUND)
+if(LZO_FOUND)
+ add_definitions(-DLIBVNCSERVER_HAVE_LZO)
+ include_directories(${LZO_INCLUDE_DIR})
+else()
+ set(LIBVNCSERVER_SOURCES
+ ${LIBVNCSERVER_SOURCES}
+ ${COMMON_DIR}/minilzo.c
+ )
+ set(LIBVNCCLIENT_SOURCES
+ ${LIBVNCCLIENT_SOURCES}
+ ${COMMON_DIR}/minilzo.c
+ )
+endif()
+
if(JPEG_FOUND)
add_definitions(-DLIBVNCSERVER_HAVE_LIBJPEG)
include_directories(${JPEG_INCLUDE_DIR})
@@ -268,7 +425,6 @@ endif(JPEG_FOUND)
if(PNG_FOUND)
add_definitions(-DLIBVNCSERVER_HAVE_LIBPNG)
include_directories(${PNG_INCLUDE_DIR})
- set(TIGHT_C ${LIBVNCSERVER_DIR}/tight.c ${COMMON_DIR}/turbojpeg.c)
endif(PNG_FOUND)
set(LIBVNCSERVER_SOURCES
@@ -276,7 +432,7 @@ set(LIBVNCSERVER_SOURCES
${TIGHT_C}
)
-if(TIGHTVNC_FILETRANSFER)
+if(WITH_TIGHTVNC_FILETRANSFER AND CMAKE_USE_PTHREADS_INIT)
set(LIBVNCSERVER_SOURCES
${LIBVNCSERVER_SOURCES}
${LIBVNCSERVER_DIR}/tightvnc-filetransfer/rfbtightserver.c
@@ -284,14 +440,16 @@ if(TIGHTVNC_FILETRANSFER)
${LIBVNCSERVER_DIR}/tightvnc-filetransfer/filetransfermsg.c
${LIBVNCSERVER_DIR}/tightvnc-filetransfer/filelistinfo.c
)
-endif(TIGHTVNC_FILETRANSFER)
+endif(WITH_TIGHTVNC_FILETRANSFER AND CMAKE_USE_PTHREADS_INIT)
if(LIBVNCSERVER_WITH_WEBSOCKETS)
add_definitions(-DLIBVNCSERVER_WITH_WEBSOCKETS)
set(LIBVNCSERVER_SOURCES
${LIBVNCSERVER_SOURCES}
${LIBVNCSERVER_DIR}/websockets.c
- ${WSSRCS}
+ ${LIBVNCSERVER_DIR}/ws_decode.c
+ ${COMMON_DIR}/base64.c
+ ${CRYPTO_SOURCES}
)
endif(LIBVNCSERVER_WITH_WEBSOCKETS)
@@ -301,7 +459,13 @@ tde_add_library( tdevncclient STATIC_PIC AUTOMOC
SOURCES
${LIBVNCCLIENT_SOURCES}
LINK
- pthread ${ADDITIONAL_LIBS} ${ZLIB_LIBRARIES} ${JPEG_LIBRARIES} ${GNUTLS_LIBRARIES} ${OPENSSL_LIBRARIES}
+ pthread
+ ${ADDITIONAL_LIBS}
+ ${ZLIB_LIBRARIES}
+ ${LZO_LIBRARIES}
+ ${JPEG_LIBRARIES}
+ ${GNUTLS_LIBRARIES}
+ ${OPENSSL_LIBRARIES}
)
##### tdevncserver (static) ########################
@@ -310,5 +474,12 @@ tde_add_library( tdevncserver STATIC_PIC AUTOMOC
SOURCES
${LIBVNCSERVER_SOURCES}
LINK
- ${ADDITIONAL_LIBS} ${ZLIB_LIBRARIES} ${JPEG_LIBRARIES} ${PNG_LIBRARIES} ${WEBSOCKET_LIBRARIES}
+ ${ADDITIONAL_LIBS}
+ ${ZLIB_LIBRARIES}
+ ${LZO_LIBRARIES}
+ ${JPEG_LIBRARIES}
+ ${PNG_LIBRARIES}
+ ${CRYPTO_LIBRARIES}
+ ${GNUTLS_LIBRARIES}
+ ${OPENSSL_LIBRARIES}
)
diff --git a/ChangeLog b/ChangeLog
index f701eb0..fc3cb2c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,1143 @@
+2019-01-06 Christian Beier <dontmind@freeshell.org>
+
+ * rfb/rfb.h: Move pipe_notify_client_thread to end of rfbClientRec in order to retain ABI compatibility.
+
+2019-01-06 Christian Beier <dontmind@freeshell.org>
+
+ * libvncserver/main.c: Fix comment style and be a bit more verbose ... explaining cedae6e6f97b14f5df3ea7c5f7efd59f2bc9ad82.
+
+2019-01-06 Christian Beier <dontmind@freeshell.org>
+
+ * : Merge pull request #238 from tetrane/pr-fix-use-after-free Fix use-after-free and concurrent access segmentation fault
+
+2019-01-06 Christian Beier <dontmind@freeshell.org>
+
+ * CMakeLists.txt: CMake: require stdint.h This is used at quite a few places in the code, so make it
+ mandatory.
+
+2019-01-06 Christian Beier <dontmind@freeshell.org>
+
+ * libvncserver/rfbserver.c: Error out in
+ rfbProcessFileTransferReadBuffer if length can not be allocated re #273
+
+2019-01-06 Christian Beier <dontmind@freeshell.org>
+
+ * libvncclient/rfbproto.c: LibVNCClient: remove now-useless cast re #273
+
+2019-01-06 Christian Beier <dontmind@freeshell.org>
+
+ * libvncclient/rfbproto.c: LibVNCClient: fail on server-sent desktop
+ name lengths longer than 1MB re #273
+
+2019-01-05 Christian Beier <dontmind@freeshell.org>
+
+ * .appveyor.yml: AppVeyorCI: update cyrus-sasl URL
+
+2018-12-29 Christian Beier <dontmind@freeshell.org>
+
+ * README.md: README: link LiberaPay team account
+
+2018-12-29 Christian Beier <dontmind@freeshell.org>
+
+ * : Merge pull request #267 from veyon/external-lzo Allow to use global LZO library instead of miniLZO
+
+2018-12-29 Christian Beier <dontmind@freeshell.org>
+
+ * libvncclient/rfbproto.c: LibVNCClient: ignore server-sent cut text
+ longer than 1MB This is in line with how LibVNCServer does it (28afb6c537dc82ba04d5f245b15ca7205c6dbb9c) and fixes part of #273.
+
+2018-12-28 Christian Beier <dontmind@freeshell.org>
+
+ * .appveyor.yml, deps/sasl-fix-snprintf-macro.patch: Revert
+ "AppVeyorCI: update cyrus-sasl to 2.1.27, remove patch" This reverts commit bcd3eaeb83181ab5491aa6d641e2a7b8d424d88a.
+
+2018-12-28 Christian Beier <dontmind@freeshell.org>
+
+ * .appveyor.yml, deps/sasl-fix-snprintf-macro.patch: AppVeyorCI:
+ update cyrus-sasl to 2.1.27, remove patch
+
+2018-12-28 Christian Beier <dontmind@freeshell.org>
+
+ * .gitignore: .gitignore: remove autotools and x11vnc leftovers
+
+2018-12-28 Christian Beier <dontmind@freeshell.org>
+
+ * .gitignore: .gitignore: fix for in-tree builds, add 'build' dir re #248
+
+2018-12-28 Christian Beier <dontmind@freeshell.org>
+
+ * .gitignore: Revert "Remove .gitignore obsoleted by CMake" This reverts commit d6c907ffbc36f4ad7663a44538b15e650a6ddf40.
+
+2018-12-06 Quentin BUATHIER <qbuathier@tetrane.com>
+
+ * libvncserver/main.c: Check the return code of pipe
+
+2018-11-29 Christian Beier <dontmind@freeshell.org>
+
+ * : Merge pull request #269 from rgacogne/fix-misleading-indentation Fix -Wmisleading-indentation warnings
+
+2018-11-22 Tobias Junghans <tobydox@veyon.io>
+
+ * .travis.yml, CMakeLists.txt, cmake/Modules/FindLZO.cmake,
+ libvncclient/rfbproto.c, libvncserver/ultra.c,
+ rfb/rfbconfig.h.cmakein: Allow to use global LZO library instead of
+ miniLZO The complete LZO library nowadays is installed on many systems so we
+ can optionally make use of it and omit internal miniLZO
+ implementation.
+
+2018-11-19 Christian Beier <dontmind@freeshell.org>
+
+ * : Merge pull request #259 from veyon/cursor-shift LibVNCClient: fix integer shifts for cursor colors
+
+2018-11-07 Tobias Junghans <tobydox@veyon.io>
+
+ * libvncserver/tight.c, libvncserver/zlib.c: LibVNCServer: properly
+ use thread-local storage The TLS macro never has been defined due to the missing
+ LIBVNCSERVER_HAVE_TLS macro. This revises the macro logic to also
+ cover Win32 builds with MSVC.
+
+2018-11-18 Christian Beier <dontmind@freeshell.org>
+
+ * : Merge pull request #263 from veyon/custom-auth-handlers LibVNCClient: add support for custom auth handlers
+
+2018-11-11 Christian Beier <dontmind@freeshell.org>
+
+ * libvncserver/cargs.c: Add SSL options to rfbUsage output
+
+2018-11-10 Christian Beier <dontmind@freeshell.org>
+
+ * libvncserver/tightvnc-filetransfer/handlefiletransferrequest.c:
+ tightvnc-filetransfer: do not close stuff from within a thread ... as this crashes badly and the client is closed by the main
+ thread machinery afterwards. re #242
+
+2018-11-09 Christian Beier <dontmind@freeshell.org>
+
+ * README, README.md: README: rename to README.md We had the original name lingering on for the Autotools packaging
+ process, but that is gone since.
+
+2018-11-07 Christian Beier <dontmind@freeshell.org>
+
+ * : Merge pull request #261 from veyon/misc-fixes Misc fixes
+
+2018-11-07 Tobias Junghans <tobydox@veyon.io>
+
+ * common/d3des.c: common: d3des: use per-thread key register When encrypting/decrypting from different threads this can race due
+ to the global key register.
+
+2018-11-07 Tobias Junghans <tobydox@veyon.io>
+
+ * common/d3des.c, common/d3des.h, libvncclient/rfbproto.c: common:
+ d3des: drop unused rfbCPKey()
+
+2018-11-07 Tobias Junghans <tobydox@veyon.io>
+
+ * common/d3des.c: common: d3des: make static arrays const
+
+2018-11-06 Tobias Junghans <tobydox@veyon.io>
+
+ * libvncclient/tls.h, libvncclient/tls_gnutls.c,
+ libvncclient/tls_none.c, libvncclient/tls_openssl.c: LibVNCClient:
+ pass buffer as const to WriteToTLS()
+
+2018-11-06 Tobias Junghans <tobydox@veyon.io>
+
+ * rfb/default8x16.h: rfb: add header guard for default8x16
+
+2018-11-06 Tobias Junghans <tobydox@veyon.io>
+
+ * libvncclient/sasl.c, libvncclient/sockets.c,
+ libvncserver/sockets.c: Undef error codes before redefining them for
+ WSA Fixes compiler warnings about redefined macros from errno.h.
+
+2018-11-06 Tobias Junghans <tobydox@veyon.io>
+
+ * libvncclient/rfbproto.c: LibVNCClient: init pad field for set
+ encodings msg
+
+2018-11-06 Tobias Junghans <tobydox@veyon.io>
+
+ * README: README: add Veyon to projects using libvncserver
+
+2018-11-05 Christian Beier <dontmind@freeshell.org>
+
+ * README: README. add a reference to client examples Closes #224
+
+2018-11-05 Christian Beier <dontmind@freeshell.org>
+
+ * README: README: add VirtualBox to projects using us
+
+2018-11-05 Christian Beier <dontmind@freeshell.org>
+
+ * README: README: fix header structure, add some markups for
+ commands
+
+2018-11-05 Christian Beier <dontmind@freeshell.org>
+
+ * : Merge pull request #260 from veyon/free-client-buffers LibVNCClient: free buffers in rfbClientCleanup()
+
+2018-11-05 Tobias Junghans <tobydox@veyon.io>
+
+ * libvncserver/cursor.c: LibVNCClient: fix integer shifts for cursor
+ colors Shifting values > 32768 by 16 places can cause undefined results for
+ signed integers. Therefore cast color components to unsigned integer
+ before shifting.
+
+2018-10-22 Christian Beier <dontmind@freeshell.org>
+
+ * libvncserver/tightvnc-filetransfer/handlefiletransferrequest.c:
+ tightvnc-filetransfer: when creating a new download thread, make
+ sure the previous one ends re #242
+
+2018-10-21 Christian Beier <dontmind@freeshell.org>
+
+ * libvncserver/tightvnc-filetransfer/filetransfermsg.c,
+ libvncserver/tightvnc-filetransfer/rfbtightserver.c:
+ tightvnc-filetransfer: wait for download thread end in
+ CloseUndoneFileDownload() ...and use it when deregistering the file transfer extension. Closes #242
+
+2018-10-21 Christian Beier <dontmind@freeshell.org>
+
+ * libvncserver/tightvnc-filetransfer/filetransfermsg.c,
+ libvncserver/tightvnc-filetransfer/filetransfermsg.h,
+ libvncserver/tightvnc-filetransfer/handlefiletransferrequest.c:
+ tightvnc-filetransfer: refactor CloseUndoneFileTransfer() into two
+ functions ...for closing upload and download separately. re #242
+
+2018-10-21 Christian Beier <dontmind@freeshell.org>
+
+ * libvncserver/tightvnc-filetransfer/handlefiletransferrequest.c,
+ libvncserver/tightvnc-filetransfer/rfbtightproto.h:
+ tightvnc-filetransfer: tie the download thread to the control
+ structure re #242
+
+2018-10-21 Christian Beier <dontmind@freeshell.org>
+
+ * libvncserver/tightvnc-filetransfer/handlefiletransferrequest.c:
+ tightvnc-filetransfer: fix heap use-after-free One can only guess what the intended semantics were here, but as
+ every other rfbCloseClient() call in this file is followed by an
+ immediate return, let's assume this was forgotton in this case. Anyway, don't forget to clean up to not leak memory. Closes #241
+
+2018-10-21 Christian Beier <dontmind@freeshell.org>
+
+ * libvncserver/rfbserver.c: LibVNCServer: fix heap out-of-bound
+ write access Closes #243
+
+2018-10-04 Christian Beier <dontmind@freeshell.org>
+
+ * libvncclient/corre.c: LibVNCClient: really fix #250
+
+2018-10-01 Christian Beier <dontmind@freeshell.org>
+
+ * libvncserver/rfbserver.c, libvncserver/websockets.c: websockets:
+ remove Flash fallback Closes #162
+
+2018-10-01 Christian Beier <dontmind@freeshell.org>
+
+ * webclients/index.vnc, webclients/novnc/LICENSE.txt,
+ webclients/novnc/README.md, webclients/novnc/app/error-handler.js,
+ webclients/novnc/app/images/alt.svg,
+ webclients/novnc/app/images/clipboard.svg,
+ webclients/novnc/app/images/connect.svg,
+ webclients/novnc/app/images/ctrl.svg,
+ webclients/novnc/app/images/ctrlaltdel.svg,
+ webclients/novnc/app/images/disconnect.svg,
+ webclients/novnc/app/images/drag.svg,
+ webclients/novnc/app/images/error.svg,
+ webclients/novnc/app/images/esc.svg,
+ webclients/novnc/app/images/expander.svg,
+ webclients/novnc/app/images/fullscreen.svg,
+ webclients/novnc/app/images/handle.svg,
+ webclients/novnc/app/images/handle_bg.svg,
+ webclients/novnc/app/images/icons/Makefile,
+ webclients/novnc/app/images/icons/novnc-icon-sm.svg,
+ webclients/novnc/app/images/icons/novnc-icon.svg,
+ webclients/novnc/app/images/info.svg,
+ webclients/novnc/app/images/keyboard.svg,
+ webclients/novnc/app/images/mouse_left.svg,
+ webclients/novnc/app/images/mouse_middle.svg,
+ webclients/novnc/app/images/mouse_none.svg,
+ webclients/novnc/app/images/mouse_right.svg,
+ webclients/novnc/app/images/power.svg,
+ webclients/novnc/app/images/settings.svg,
+ webclients/novnc/app/images/tab.svg,
+ webclients/novnc/app/images/toggleextrakeys.svg,
+ webclients/novnc/app/images/warning.svg,
+ webclients/novnc/app/locale/de.json,
+ webclients/novnc/app/locale/el.json,
+ webclients/novnc/app/locale/es.json,
+ webclients/novnc/app/locale/nl.json,
+ webclients/novnc/app/locale/pl.json,
+ webclients/novnc/app/locale/sv.json,
+ webclients/novnc/app/locale/tr.json,
+ webclients/novnc/app/locale/zh.json,
+ webclients/novnc/app/localization.js,
+ webclients/novnc/app/sounds/CREDITS,
+ webclients/novnc/app/styles/base.css,
+ webclients/novnc/app/styles/lite.css, webclients/novnc/app/ui.js,
+ webclients/novnc/app/webutil.js, webclients/novnc/{include =>
+ core}/base64.js, webclients/novnc/{include => core}/des.js,
+ webclients/novnc/core/display.js,
+ webclients/novnc/core/encodings.js,
+ webclients/novnc/core/inflator.js,
+ webclients/novnc/core/input/domkeytable.js,
+ webclients/novnc/core/input/fixedkeys.js,
+ webclients/novnc/core/input/keyboard.js,
+ webclients/novnc/core/input/keysym.js,
+ webclients/novnc/core/input/keysymdef.js,
+ webclients/novnc/core/input/mouse.js,
+ webclients/novnc/core/input/util.js,
+ webclients/novnc/core/input/vkeys.js,
+ webclients/novnc/core/input/xtscancodes.js,
+ webclients/novnc/core/rfb.js,
+ webclients/novnc/core/util/browser.js,
+ webclients/novnc/core/util/events.js,
+ webclients/novnc/core/util/eventtarget.js,
+ webclients/novnc/core/util/logging.js,
+ webclients/novnc/core/util/polyfill.js,
+ webclients/novnc/core/util/strings.js,
+ webclients/novnc/core/websock.js, webclients/novnc/favicon.ico,
+ webclients/novnc/include/base.css,
+ webclients/novnc/include/black.css,
+ webclients/novnc/include/blue.css,
+ webclients/novnc/include/chrome-app/tcp-client.js,
+ webclients/novnc/include/display.js,
+ webclients/novnc/include/input.js,
+ webclients/novnc/include/jsunzip.js,
+ webclients/novnc/include/keyboard.js,
+ webclients/novnc/include/keysym.js,
+ webclients/novnc/include/keysymdef.js,
+ webclients/novnc/include/logo.js,
+ webclients/novnc/include/playback.js,
+ webclients/novnc/include/rfb.js, webclients/novnc/include/ui.js,
+ webclients/novnc/include/util.js,
+ webclients/novnc/include/web-socket-js/README.txt,
+ webclients/novnc/include/web-socket-js/swfobject.js,
+ webclients/novnc/include/web-socket-js/web_socket.js,
+ webclients/novnc/include/websock.js,
+ webclients/novnc/include/webutil.js,
+ webclients/novnc/vendor/browser-es-module-loader/.npmignore,
+ webclients/novnc/vendor/browser-es-module-loader/README.md,
+ webclients/novnc/vendor/browser-es-module-loader/dist/babel-worker.
+ js,
+ webclients/novnc/vendor/browser-es-module-loader/dist/browser-es-mo
+ dule-loader.js,
+ webclients/novnc/vendor/browser-es-module-loader/dist/browser-es-mo
+ dule-loader.js.map,
+ webclients/novnc/vendor/browser-es-module-loader/rollup.config.js,
+ webclients/novnc/vendor/browser-es-module-loader/src/babel-worker.j
+ s,
+ webclients/novnc/vendor/browser-es-module-loader/src/browser-es-mod
+ ule-loader.js, webclients/novnc/vendor/pako/LICENSE,
+ webclients/novnc/vendor/pako/README.md,
+ webclients/novnc/vendor/pako/lib/utils/common.js,
+ webclients/novnc/vendor/pako/lib/zlib/adler32.js,
+ webclients/novnc/vendor/pako/lib/zlib/constants.js,
+ webclients/novnc/vendor/pako/lib/zlib/crc32.js,
+ webclients/novnc/vendor/pako/lib/zlib/deflate.js,
+ webclients/novnc/vendor/pako/lib/zlib/gzheader.js,
+ webclients/novnc/vendor/pako/lib/zlib/inffast.js,
+ webclients/novnc/vendor/pako/lib/zlib/inflate.js,
+ webclients/novnc/vendor/pako/lib/zlib/inftrees.js,
+ webclients/novnc/vendor/pako/lib/zlib/messages.js,
+ webclients/novnc/vendor/pako/lib/zlib/trees.js,
+ webclients/novnc/vendor/pako/lib/zlib/zstream.js,
+ webclients/novnc/vendor/promise.js,
+ webclients/novnc/vendor/sinon.js, webclients/novnc/vnc.html,
+ webclients/novnc/vnc_auto.html: Update bundled noVNC to latest
+ release 1.0.0 Closes #148
+
+2018-10-01 Christian Beier <dontmind@freeshell.org>
+
+ * libvncserver/httpd.c: httpd: send proper MIME type for Javascript
+ files re #148
+
+2018-10-01 Christian Beier <dontmind@freeshell.org>
+
+ * libvncclient/ultra.c: LibVNCClient: make sure Ultra decoding
+ cannot dereference a null pointer Closes #254
+
+2018-09-30 Christian Beier <dontmind@freeshell.org>
+
+ * CMakeLists.txt: CMake: require some form of hton64() for
+ websockets Closes #127
+
+2018-09-30 DRC <information@virtualgl.org>
+
+ * libvncserver/ws_decode.h: Fix compilaton with gcc 4.4.x Closes #204 Signed-off-by: Christian Beier <dontmind@freeshell.org>
+
+2018-09-29 Christian Beier <dontmind@freeshell.org>
+
+ * libvncclient/rfbproto.c: LibVNCClient: fix three possible heap
+ buffer overflows An attacker could feed `0xffffffff`, causing a `malloc(0)` for the
+ buffers which are subsequently written to. Closes #247
+
+2018-09-29 Christian Beier <dontmind@freeshell.org>
+
+ * libvncclient/corre.c: LibVNCClient: make sure ReadFromRFBServer()
+ does not write after buffer end in CoRRE decoding Closes #250
+
+2018-09-29 Christian Beier <dontmind@freeshell.org>
+
+ * libvncclient/rfbproto.c: LibVNCClient: fix possible infinite loop Closes #251
+
+2018-09-29 Christian Beier <dontmind@freeshell.org>
+
+ * libvncclient/rfbproto.c: LibVNCClient: don't leak uninitialised
+ memory to remote The pad fields of the rfbClientCutTextMsg and rfbKeyEventMsg could
+ contain arbitray memory belonging to the process, don't leak this to
+ the remote. Closes #252
+
+2018-09-29 Christian Beier <dontmind@freeshell.org>
+
+ * examples/repeater.c, libvncclient/rfbproto.c: When connecting to a
+ repeater, only send initialised string Closes #253
+
+2018-09-29 Christian Beier <dontmind@freeshell.org>
+
+ * CMakeLists.txt: CMake: build the repeater example as well
+
+2018-09-27 Christian Beier <dontmind@freeshell.org>
+
+ * libvncclient/tight.c, rfb/rfbclient.h: Remove the turbojpeg.h
+ dependency from public headers Closes #230
+
+2018-09-27 Christian Beier <dontmind@freeshell.org>
+
+ * CMakeLists.txt: CMake: fix build error that occured on Windows
+ with CMake 3.12
+
+2018-09-27 Christian Beier <dontmind@freeshell.org>
+
+ * .appveyor.yml: AppVeyorCI: print CMake version
+
+2018-09-26 Christian Beier <dontmind@freeshell.org>
+
+ * CMakeLists.txt: CMake: only do jpeg-turbo tests if a libjpeg was
+ found
+
+2018-09-26 Christian Beier <dontmind@freeshell.org>
+
+ * .gitignore: Remove .gitignore obsoleted by CMake re #248
+
+2018-08-10 Christian Beier <dontmind@freeshell.org>
+
+ * CMakeLists.txt: CMake: make get_link_libraries() not crash when
+ there are no linked libraries at all
+
+2018-08-09 Quentin BUATHIER <qbuathier@tetrane.com>
+
+ * libvncserver/main.c, libvncserver/rfbserver.c, rfb/rfb.h: Fix the
+ concurrent issue hapenning between the freeing of the client and the
+ clientOutput thread
+
+2018-08-08 Quentin BUATHIER <qbuathier@tetrane.com>
+
+ * libvncserver/main.c: Fix use-after-free
+
+2018-07-30 Christian Beier <dontmind@freeshell.org>
+
+ * client_examples/SDLvncviewer.c: SDLvncviewer: work around
+ SDL_TEXTINPUT not generating chars with CTRL down
+
+2018-07-30 Christian Beier <dontmind@freeshell.org>
+
+ * client_examples/SDLvncviewer.c: SDLvncviewer: handle mouse wheel
+ events
+
+2018-07-28 Christian Beier <dontmind@freeshell.org>
+
+ * client_examples/SDLvncviewer.c: SDLvncviewer: adhere to C89
+
+2018-07-28 Christian Beier <dontmind@freeshell.org>
+
+ * client_examples/SDLvncviewer.c: SDLvncviewer: implement Unicode
+ input handling
+
+2018-07-26 Christian Beier <dontmind@freeshell.org>
+
+ * .travis.yml: TravisCI: install SDL2 dev packages for OSX as well
+
+2018-07-26 Christian Beier <dontmind@freeshell.org>
+
+ * .travis.yml: TravisCI: install SDL2 dev packages
+
+2018-07-26 Christian Beier <dontmind@freeshell.org>
+
+ * client_examples/SDLvncviewer.c: SDLvncviewer: remove obsolete
+ video scaling code
+
+2018-07-26 Christian Beier <dontmind@freeshell.org>
+
+ * CMakeLists.txt, client_examples/SDLvncviewer.c,
+ client_examples/scrap.c, client_examples/scrap.h: SDLvncviewer: use
+ SDL2 for clipboard handling By using this, we can get rid of our own homebrewn solution
+ scrap.[c|h] and drop X11 from the build system.
+
+2018-07-25 Christian Beier <dontmind@freeshell.org>
+
+ * client_examples/SDLvncviewer.c: SDLvncviewer: make input work with
+ SDL2 ... at least somewhat. This is far from perfect but no regression
+ compared to SDL1.2 functionality.
+
+2018-05-16 Christian Beier <dontmind@freeshell.org>
+
+ * client_examples/SDLvncviewer.c, client_examples/scrap.c:
+ SDLvncviewer: make display work with SDL2
+
+2018-05-12 Christian Beier <dontmind@freeshell.org>
+
+ * CMakeLists.txt, cmake/Modules/FindSDL2.cmake: CMake: look for SDL2
+ instead of SDL FindSDL2.cmake was downloaded from
+
+ https://github.com/tcbrindle/sdl2-cmake-scripts/blob/master/FindSDL2.cmake
+
+2018-07-25 Christian Beier <dontmind@freeshell.org>
+
+ * client_examples/SDLvncviewer.c: SDLvncviewer: add a very simple
+ GetCredentials callback
+
+2018-07-08 Christian Beier <dontmind@freeshell.org>
+
+ * CMakeLists.txt, rfb/rfbconfig.h.cmakein: CMake: add a
+ LIBVNCSERVER_HAVE_GNUTLS #define
+
+2018-07-08 Christian Beier <dontmind@freeshell.org>
+
+ * CMakeLists.txt, rfb/rfb.h: build: decouple GnuTLS|OpenSSL
+ detection from WebSockets support
+
+2018-06-29 Christian Beier <dontmind@freeshell.org>
+
+ * common/rfbcrypto_polarssl.c: crypto: remove polarssl wrapper This is not even in the build system anymore.
+
+2018-06-29 Christian Beier <dontmind@freeshell.org>
+
+ * CMakeLists.txt: CMake: declare that websockets depend on crypto
+
+2018-06-29 Christian Beier <dontmind@freeshell.org>
+
+ * rfb/rfbconfig.h.cmakein: build: remove
+ LIBVNCSERVER_WITH_CLIENT_TLS #define It is not used anywhere anymore.
+
+2018-06-29 Christian Beier <dontmind@freeshell.org>
+
+ * CMakeLists.txt, {libvncserver => common}/rfbcrypto.h,
+ {libvncserver => common}/rfbcrypto_gnutls.c, {libvncserver =>
+ common}/rfbcrypto_included.c, {libvncserver =>
+ common}/rfbcrypto_openssl.c, {libvncserver =>
+ common}/rfbcrypto_polarssl.c: crypto: move to common As of now, only LibVNCServer makes uses of these digest functions
+ _and_ they depend on sys/uio.h, but in the future LibVNCClient will
+ need those as well.
+
+2018-06-26 Christian Beier <dontmind@freeshell.org>
+
+ * : Merge pull request #235 from eddiejames/master Tight: export SendCompressedData and SendTightHeader functions
+
+2018-06-16 Christian Beier <dontmind@freeshell.org>
+
+ * .appveyor.yml: AppVeyorCI: remove unused statements
+
+2018-06-16 Christian Beier <dontmind@freeshell.org>
+
+ * .appveyor.yml: AppVeyorCI: remove Visual Studio 2013 as it somehow
+ got broken at AppVeyor's side
+
+2018-06-16 Christian Beier <dontmind@freeshell.org>
+
+ * README: README: remove reference to functions not existing anymore Closes #202.
+
+2018-05-14 Christian Beier <dontmind@freeshell.org>
+
+ * : Merge pull request #215 from
+ BastiaanOlij/fix_nozlib_compile_error libvncclient: zrle.c: Move undef of REALBPP down rfbproto.c which includes this file expects an undefined REALBPP
+ after the inclusion. Do this whether or not there is zlib available.
+
+2018-03-24 Christian Beier <dontmind@freeshell.org>
+
+ * .appveyor.yml, deps/sasl-fix-snprintf-macro.patch: AppVeyorCI:
+ build with Visual Studio 2017 as well
+
+2018-03-24 Christian Beier <dontmind@freeshell.org>
+
+ * libvncserver/rfbserver.c: rfbserver: fix a typo
+
+2018-03-24 Christian Beier <dontmind@freeshell.org>
+
+ * libvncserver/rfbserver.c: rfbserver: get rid of inttypes.h again
+
+2018-03-24 Christian Beier <dontmind@freeshell.org>
+
+ * libvncclient/sasl.h: libvncclient/sasl: prefix the header guard
+ (again) to fix a warning
+
+2018-03-24 Christian Beier <dontmind@freeshell.org>
+
+ * CMakeLists.txt, client_examples/scrap.c: SDLvncviewer: enable the
+ X11 clipboard if X11 was found
+
+2018-03-13 Christian Beier <dontmind@freeshell.org>
+
+ * examples/androidvncserver.c: androidvncserver: fix print_usage and
+ a compiler warning
+
+2018-03-13 Christian Beier <dontmind@freeshell.org>
+
+ * examples/androidvncserver.c: androidvncserver: add some
+ boilerplate comment that should have been in the 1st code drop
+
+2018-03-13 Christian Beier <dontmind@freeshell.org>
+
+ * examples/androidvncserver.c: androidvncserver: fix a quite serious
+ typo Closes #225.
+
+2018-02-26 Petr Písař <ppisar@redhat.com>
+
+ * libvncserver/rfbserver.c: Limit client cut text length to 1 MB This patch constrains a client cut text length to 1 MB. Otherwise a
+ client could make server allocate 2 GB of memory and that seems to
+ be to much to classify it as a denial of service. The limit also prevents from an integer overflow followed by copying
+ an uninitilized memory when processing msg.cct.length value larger
+ than SIZE_MAX or INT_MAX - sz_rfbClientCutTextMsg. This patch also corrects accepting length value of zero (malloc(0)
+ is interpreted on differnet systems differently). CVE-2018-7225 <https://github.com/LibVNC/libvncserver/issues/218>
+
+2018-02-27 Christian Beier <dontmind@freeshell.org>
+
+ * .appveyor.yml: AppVeyorCI: set path to devenv tool based on
+ environment
+
+2018-02-26 Christian Beier <cb@shoutrlabs.com>
+
+ * examples/androidvncserver.c: androidvncserver: remove keycodes not
+ in NDK anymore This makes the android VNC server example build again.
+
+2018-01-27 Bastiaan Olij <mux213@gmail.com>
+
+ * libvncclient/zrle.c: Moved undef of REALBPP down
+
+2018-01-23 Christian Beier <dontmind@freeshell.org>
+
+ * : Merge pull request #203 from dcommander/turbovnc-client Include Tight decoding optimizations from TurboVNC
+
+2018-01-22 Christian Beier <dontmind@freeshell.org>
+
+ * : Merge pull request #197 from wwqwwqwd/master Add trle decoder
+
+2017-09-02 Christian Beier <dontmind@freeshell.org>
+
+ * CMakeLists.txt, libvncclient/rfbproto.c, libvncclient/{rfbsasl.c
+ => sasl.c}, libvncclient/{rfbsasl.h => sasl.h},
+ libvncclient/sockets.c: libvncclient: rename rfbsasl.[c|h] to
+ sasl.[c|h] to be in line with naming of other files
+
+2017-09-02 Christian Beier <dontmind@freeshell.org>
+
+ * libvncclient/rfbproto.c, libvncclient/rfbsasl.h,
+ libvncclient/sockets.c, rfb/rfbproto.h: Move HAVE_SASL #ifdefs into
+ header file to have less LOC
+
+2017-09-02 Christian Beier <dontmind@freeshell.org>
+
+ * client_examples/ppmtest.c: Fix building whithout SASL
+
+2017-07-07 Christian Beier <dontmind@freeshell.org>
+
+ * : Merge pull request #188 from Cordius/master fix: the function should not return a value
+
+2017-04-21 simon <root@simon.home>
+
+ * .appveyor.yml, CMakeLists.txt, client_examples/ppmtest.c,
+ libvncclient/rfbproto.c, libvncclient/rfbsasl.c,
+ libvncclient/rfbsasl.h, libvncclient/sockets.c, libvncclient/tls.h,
+ libvncclient/tls_gnutls.c, libvncclient/tls_none.c,
+ libvncclient/tls_openssl.c, libvncclient/vncviewer.c,
+ rfb/rfbclient.h, rfb/rfbconfig.h.cmakein, rfb/rfbproto.h: Added SASL
+ authentication support Added SASL support to OpenSSL
+
+2017-06-20 Christian Beier <dontmind@freeshell.org>
+
+ * : Merge pull request #161 from jlesage/master-base64-compat websockets: Fixed compilation of websockets on systems where there
+ is no implementation of base64 functions.
+
+2017-05-15 Christian Beier <dontmind@freeshell.org>
+
+ * : Merge pull request #158 from kempniu/gtk-vnc-0.7.0-compat websockets: Ensure compatibility with gtk-vnc 0.7.0+
+
+2017-05-14 Christian Beier <dontmind@freeshell.org>
+
+ * CMakeLists.txt: websockets: only build tests for a
+ websockets-enabled build
+
+2017-05-14 Christian Beier <dontmind@freeshell.org>
+
+ * libvncserver/websockets.c, rfb/rfb.h: websockets: restore
+ webSocketCheckDisconnect() to keep API compatibility
+
+2017-02-27 Andreas Weigel <andreaswe@securepoint.de>
+
+ * libvncserver/ws_decode.c, libvncserver/ws_decode.h: remove
+ potential 64 bit len overflow calculation
+
+2017-02-27 Andreas Weigel <andreaswe@securepoint.de>
+
+ * libvncserver/websockets.c, libvncserver/ws_decode.c,
+ libvncserver/ws_decode.h, test/wsmaketestframe.py, test/wstest.c,
+ test/wstestdata.inc: add decode support for continuation frames use FIN bit and implement opcode 0x00 make consistent use of uint64_t for big frame sizes
+
+2017-02-23 Andreas Weigel <andreaswe@securepoint.de>
+
+ * CMakeLists.txt, test/wsmaketestframe.py, test/wstest.c,
+ test/{wstestdata.c => wstestdata.inc}: fix problems in test and
+ requests for cmake build add missing stdarg header fix hardcoded errno integer values in tests add dependency to wstestdata and rename to prevent building it as c
+ source
+
+2017-02-23 Andreas Weigel <andreaswe@securepoint.de>
+
+ * libvncserver/rfbserver.c, libvncserver/websockets.c, rfb/rfb.h:
+ remove Hixie-specific MD5 and check functions
+
+2017-02-20 Andreas Weigel <andreaswe@securepoint.de>
+
+ * .gitignore, CMakeLists.txt, libvncserver/ws_decode.c,
+ libvncserver/ws_decode.h, test/wsmaketestframe.py, test/wstest.c,
+ test/wstestdata.c: add generation wstest to cmake add wstestdata.c, because the python data generation script has too
+ many dependencies remove some redundance from jpeg test creation add support for decoding close messages
+
+2017-02-20 Andreas Weigel <andreaswe@securepoint.de>
+
+ * .gitignore, libvncserver/websockets.c, libvncserver/ws_decode.c,
+ libvncserver/ws_decode.h, test/wsmaketestframe.py, test/wstest.c:
+ add ws_decode tests modify automake to include ws_decode test add python frame generator for decode tests modify configure to only include ws_decode test if preconditions are
+ fulfilled
+
+2017-02-16 Andreas Weigel <andreaswe@securepoint.de>
+
+ * libvncserver/websockets.c: remove obsolete hixie protocol support
+
+2017-02-16 Andreas Weigel <andreaswe@securepoint.de>
+
+ * libvncserver/websockets.c, libvncserver/ws_decode.c,
+ libvncserver/ws_decode.h: factor out hybi decode part to make it
+ testable remove direct dependency on rfbClientPtr structure in hybi decode
+ function(s)
+
+2017-02-15 Andreas Weigel <andreaswe@securepoint.de>
+
+ * libvncserver/websockets.c: fix overflow and refactor websockets
+ decode (Hybi) fix critical heap-based buffer overflow which allowed easy
+ modification of a return address via an overwritten function pointer fix bug causing connections to fail due a "one websocket frame = one
+ ws_read" assumption, which failed with LibVNCServer-0.9.11 refactor websocket Hybi decode to use a simple state machine for
+ decoding of websocket frames
+
+2017-05-14 Christian Beier <dontmind@freeshell.org>
+
+ * : Merge pull request #175 from simonwaterman/x509verify Added support for X509 server certificate verification
+
+2017-05-12 Christian Beier <dontmind@freeshell.org>
+
+ * : Merge pull request #178 from lioncash/leak font: Fix a small resource leak in a failure case in
+ rfbLoadConsoleFont()
+
+2017-05-05 simon <root@simon.home>
+
+ * libvncclient/tls_openssl.c, rfb/rfbclient.h: X509 certificate
+ verification for OpenSSL
+
+2017-04-25 simon <root@simon.home>
+
+ * libvncclient/tls_gnutls.c: Removed comment left over from
+ development
+
+2017-04-25 simon <root@simon.home>
+
+ * libvncclient/tls_gnutls.c: Modified certificate verification for
+ compatibility with GnuTLS 2.12.23
+
+2017-04-21 Christian Beier <dontmind@freeshell.org>
+
+ * CMakeLists.txt, rfb/rfbconfig.h.cmakein: CMake: add all function
+ checks that used to be in configure.ac Fixes #174
+
+2017-04-21 Christian Beier <dontmind@freeshell.org>
+
+ * CMakeLists.txt, rfb/{rfbconfig.h.cmake => rfbconfig.h.cmakein}:
+ CMake: properly name rfbconfig.h cmake template
+
+2017-04-21 Christian Beier <dontmind@freeshell.org>
+
+ * .travis.yml: TravisCI: point OSX CMake to OpenSSL root dir
+
+2017-04-21 Christian Beier <dontmind@freeshell.org>
+
+ * CMakeLists.txt, cmake/Modules/FindFFMPEG.cmake: CMake: include a
+ FindFFMPEG module and use it Thankfully taken from
+
+ https://github.com/robotology/ycm/blob/master/find-modules/FindFFMPEG.cmake
+
+2017-04-20 tmcqueen-materials <tmcqueen-materials@users.noreply.github.com>
+
+ * client_examples/vnc2mpg.c: Update vnc2mpg.c correct mistaken references to update_time...
+
+2017-04-20 simon <root@simon.home>
+
+ * libvncclient/tls_gnutls.c: Added support for X509 server
+ certificate verification as part of the handshake process.
+
+2017-04-18 Christian Beier <dontmind@freeshell.org>
+
+ * CMakeLists.txt, rfb/rfbconfig.h.cmake: CMake: set
+ LIBVNCSERVER_HAVE_FORK in rfbconfig.h if fork() found
+
+2017-04-18 Christian Beier <dontmind@freeshell.org>
+
+ * CMakeLists.txt, rfb/rfbconfig.h.cmake: CMake: set
+ LIBVNCSERVER_HAVE_LIBSSL in rfbconfig.h if OpenSSL found
+
+2017-04-18 Christian Beier <dontmind@freeshell.org>
+
+ * CMakeLists.txt, rfb/rfbconfig.h.cmake: CMake: detect mmap() and
+ write result to rfbconfig.h
+
+2017-04-13 tmcqueen-materials <tmcqueen-materials@users.noreply.github.com>
+
+ * client_examples/vnc2mpg.c: Update vnc2mpg.c This update makes the example work on versions of ffmpeg newer than
+ "ancient," fixes a bunch of bugs in the process, and with better
+ documentation of the pitfalls.
+
+2017-04-03 dborth <dborth@gmail.com>
+
+ * libvncclient/vncviewer.c: Set trueColour flag to 1 instead of 255 It turns out some server implementations (namely VMware ESXi 6.5)
+ expect 1 as the only non-zero value for the SetPixelFormat message
+ whereas the protocol states every non-zero value is valid
+
+ (https://github.com/rfbproto/rfbproto/blob/master/rfbproto.rst#setpixelformat).Anyway, setting this to 1 shouldn't hurt. Fixes #141
+
+2017-03-26 Christian Beier <dontmind@freeshell.org>
+
+ * CMakeLists.txt, examples/android/README,
+ examples/android/jni/Android.mk,
+ examples/{android/jni/fbvncserver.c => androidvncserver.c}: CMake:
+ automatically build androidvncserver when crosscompiling for Android
+
+2017-03-26 Christian Beier <dontmind@freeshell.org>
+
+ * README, libvncclient/listen.c, rfb/rfbclient.h: Fix building for
+ Android and add build instructions to README
+
+2017-03-26 Christian Beier <dontmind@freeshell.org>
+
+ * CMakeLists.txt: CMake: when crosscompiling for Android, don't look
+ for systemd
+
+2017-03-26 Christian Beier <dontmind@freeshell.org>
+
+ * libvncclient/vncviewer.c: Fix a compiler warning
+
+2017-03-26 Christian Beier <dontmind@freeshell.org>
+
+ * CMakeLists.txt: CMake: only build TurboJPEG unit tests if lib has
+ jpeg support
+
+2017-03-26 Christian Beier <dontmind@freeshell.org>
+
+ * .appveyor.yml: AppVeyorCI: change libpng download link to sth that
+ works
+
+2017-02-22 Christian Beier <dontmind@freeshell.org>
+
+ * TODO: Update TODO, at least a bit
+
+2017-02-21 Christian Beier <dontmind@freeshell.org>
+
+ * .appveyor.yml: AppVeyorCI: use static zlib and libpng
+
+2017-02-21 Christian Beier <dontmind@freeshell.org>
+
+ * CMakeLists.txt: CMake: remove check for C++ compiler We don't have any C++ sources.
+
+2017-02-21 Christian Beier <cb@shoutrlabs.com>
+
+ * .appveyor.yml, .travis.yml: CI: let tests output to console on
+ failure
+
+2017-02-21 Christian Beier <cb@shoutrlabs.com>
+
+ * rfb/rfbproto.h: rfbproto: re-add erroneously removed SOCKET
+ definition
+
+2017-02-21 Christian Beier <dontmind@freeshell.org>
+
+ * .appveyor.yml: AppVeyorCI: make ctest more verbose
+
+2017-02-21 Christian Beier <dontmind@freeshell.org>
+
+ * libvncserver/main.c: rfbInitServer: only init Winsock once
+
+2017-02-21 Christian Beier <dontmind@freeshell.org>
+
+ * rfb/rfbproto.h: rfbproto: remove SOCKET redefinitions
+
+2017-02-21 Christian Beier <dontmind@freeshell.org>
+
+ * libvncserver/main.c: Add an rfbLogPError that shows something on
+ WIN32
+
+2017-02-21 Christian Beier <dontmind@freeshell.org>
+
+ * rfb/rfbproto.h: Fix "rfbBool's size is not 1" runtime error with
+ MSVC
+
+2017-02-21 Christian Beier <dontmind@freeshell.org>
+
+ * CMakeLists.txt: CMake: only add tjunittest if turbojpeg found
+
+2017-02-21 Christian Beier <dontmind@freeshell.org>
+
+ * .appveyor.yml: AppVeyorCI: really add the test config to AppVeyor
+
+2017-02-21 Christian Beier <dontmind@freeshell.org>
+
+ * .travis.yml: Revert "AppVeyorCI: supply a test config aka build
+ type" This reverts commit e18ec43c2df1a91911f8fd98bff52a232b6f757c.
+
+2017-02-21 Christian Beier <dontmind@freeshell.org>
+
+ * .travis.yml: AppVeyorCI: supply a test config aka build type
+
+2017-02-21 Christian Beier <dontmind@freeshell.org>
+
+ * README: README: add build instructions
+
+2017-02-21 Christian Beier <dontmind@freeshell.org>
+
+ * .appveyor.yml: AppVeyorCI: run them tests
+
+2017-02-21 Christian Beier <dontmind@freeshell.org>
+
+ * test/copyrecttest.c: test: tell MSVC to use math defines
+
+2017-02-21 Christian Beier <dontmind@freeshell.org>
+
+ * : Merge pull request #156 from The-42/drop-autotools drop autotools
+
+2017-02-21 Christian Beier <dontmind@freeshell.org>
+
+ * CMakeLists.txt: CMake: enable the tests that succeed
+
+2017-02-21 Christian Beier <dontmind@freeshell.org>
+
+ * CMakeLists.txt: CMake: add libm to tests only on Unix
+
+2017-02-21 Christian Beier <dontmind@freeshell.org>
+
+ * CMakeLists.txt: CMake: build the tests
+
+2017-02-21 Christian Beier <dontmind@freeshell.org>
+
+ * CMakeLists.txt: CMake: properly name examples as examples, not
+ tests
+
+2017-02-20 Christian Beier <dontmind@freeshell.org>
+
+ * libvncserver/scale.c: Fix building in C89 mode FIXME: this should probably be refactored into a common header.
+
+2017-02-20 Christian Beier <dontmind@freeshell.org>
+
+ * CMakeLists.txt: CMake: make shared-lib build configurable and
+ choose sensible platform defaults
+
+2017-02-20 Christian Beier <dontmind@freeshell.org>
+
+ * CMakeLists.txt: CMake: set examples's output dirs in a
+ cross-platform way
+
+2017-02-14 Michał Kępień <github@kempniu.pl>
+
+ * libvncserver/websockets.c: Ensure compatibility with gtk-vnc
+ 0.7.0+
+
+2017-02-08 Bert van Hall <bert.vanhall@gmx.de>
+
+ * LibVNCServer.spec.in, Makefile.am, autogen.sh,
+ client_examples/Makefile.am, configure.ac, examples/Makefile.am,
+ examples/android/Makefile.am, libvncclient.pc.in,
+ libvncclient/Makefile.am, libvncserver-config.in,
+ libvncserver.pc.in, libvncserver/Makefile.am, m4/.gitignore,
+ m4/ax_prefix_config_h.m4, m4/ax_type_socklen_t.m4, m4/libgcrypt.m4,
+ test/Makefile.am, webclients/Makefile.am,
+ webclients/java-applet/Makefile.am,
+ webclients/java-applet/ssl/Makefile.am: drop autotools Since autotools officially is no longer supported (see various
+ github issues), drop the related infrastructure to stop tempting
+ people to use it for building. Signed-off-by: Bert van Hall <bert.vanhall@gmx.de>
+
+2017-01-31 Christian Beier <dontmind@freeshell.org>
+
+ * : Merge pull request #153 from The-42/openssl-1.1.x-support Openssl 1.1.x support
+
+2017-01-31 Christian Beier <dontmind@freeshell.org>
+
+ * CMakeLists.txt: CMake: set OpenSSL include dir regardless of
+ websockets being enabled or not
+
+2017-01-31 Christian Beier <dontmind@freeshell.org>
+
+ * rfb/rfbint.h.cmake: CMake: that file ain't used no more
+
+2017-01-29 Christian Beier <dontmind@freeshell.org>
+
+ * examples/vncev.c: Fix vncev example compilation on Windows
+
+2017-01-29 Christian Beier <dontmind@freeshell.org>
+
+ * CMakeLists.txt: CMake: the blooptest example needs pthreads
+
+2017-01-29 Christian Beier <dontmind@freeshell.org>
+
+ * .travis.yml: TravisCI: install a newer CMake on Linux
+
+2017-01-29 Christian Beier <dontmind@freeshell.org>
+
+ * CMakeLists.txt: CMake: fix examples linking when building with
+ MSVC
+
+2017-01-29 Christian Beier <dontmind@freeshell.org>
+
+ * CMakeLists.txt: CMake: as of now, the tight sources need libjpeg,
+ libpng alone is not enough
+
+2017-01-29 Christian Beier <dontmind@freeshell.org>
+
+ * .appveyor.yml: AppVeyor: detect libpng for main build
+
+2017-01-29 Christian Beier <dontmind@freeshell.org>
+
+ * .appveyor.yml: AppVeyor: more libpng build tuning
+
+2016-11-18 Christian Beier <dontmind@freeshell.org>
+
+ * README: AppveyorCI: add badge.
+
+2017-01-29 Christian Beier <dontmind@freeshell.org>
+
+ * .appveyor.yml: AppVeyor: fix libpng download cmd
+
+2017-01-28 Christian Beier <dontmind@freeshell.org>
+
+ * .appveyor.yml: AppVeyor: add appveyor.yml from ci branch.
+
+2017-01-28 Christian Beier <dontmind@freeshell.org>
+
+ * libvncserver/rfbcrypto.h: Fix building websockets with GnuTLS.
+
+2017-01-28 Christian Beier <dontmind@freeshell.org>
+
+ * libvncserver/rfbcrypto.h: Fix typo
+
+2017-01-28 Christian Beier <dontmind@freeshell.org>
+
+ * libvncserver/rfbcrypto.h: Fix websockets building
+
+2017-01-28 Christian Beier <dontmind@freeshell.org>
+
+ * common/md5.h, libvncserver/httpd.c, libvncserver/rfbcrypto.h,
+ libvncserver/rfbserver.c,
+ libvncserver/tightvnc-filetransfer/filetransfermsg.c,
+ libvncserver/tightvnc-filetransfer/handlefiletransferrequest.c,
+ libvncserver/websockets.c, rfb/rfb.h: Various #ifdef fixes to allow
+ building with MSVC2014
+
+2017-01-28 Christian Beier <dontmind@freeshell.org>
+
+ * CMakeLists.txt: CMake: as of now, websockets support requires
+ sys/uio.h
+
+2017-01-28 Christian Beier <dontmind@freeshell.org>
+
+ * rfb/rfbconfig.h.cmake: CMake: add a HAVE_SYS_UIO_H flag to
+ rfbconfig.h
+
+2017-01-28 Christian Beier <dontmind@freeshell.org>
+
+ * CMakeLists.txt: CMake: TightVNC-filetransfer requires pthreads as
+ of now
+
+2017-01-28 Christian Beier <dontmind@freeshell.org>
+
+ * common/vncauth.c, libvncclient/listen.c, libvncclient/sockets.c,
+ rfb/rfbclient.h: Fix LibVNCClient compilation with MSVC 2014
+
+2017-01-28 CHris B <cb@shoutr.net>
+
+ * CMakeLists.txt: CMake: fix build system generation when zlib or
+ OpenSSL not found
+
+2017-01-28 CHris B <cb@shoutr.net>
+
+ * CMakeLists.txt: CMake: do not include NOTFOUND libs in pkg-config
+ snippets
+
+2017-01-22 Christian Beier <dontmind@freeshell.org>
+
+ * CMakeLists.txt: CMake: make the build configurable.
+
+2016-11-18 Christian Beier <dontmind@freeshell.org>
+
+ * CMakeLists.txt: CMake: remove platform-specific flags.
+
+2017-01-02 Christian Beier <dontmind@freeshell.org>
+
+ * CMakeLists.txt: CMake: bump version.
+
+2017-01-02 Christian Beier <dontmind@freeshell.org>
+
+ * CMakeLists.txt, libvncclient.pc.cmakein: CMake: generate and
+ install pkgconfig files.
+
+2017-01-02 Christian Beier <dontmind@freeshell.org>
+
+ * CMakeLists.txt, libvncclient.pc.cmakein, libvncserver.pc.cmakein:
+ CMake: bump SOVERSION to 1. Fixes https://github.com/LibVNC/libvncserver/issues/149
+
+2017-01-02 Christian Beier <dontmind@freeshell.org>
+
+ * CMakeLists.txt: CMake: update bugreport path
+
+2016-12-30 Christian Beier <cb@shoutrlabs.com>
+
+ * libvncserver/websockets.c: Make websockets code build on OSX
+ without SSL.
+
+2016-12-30 Christian Beier <cb@shoutrlabs.com>
+
+ * CMakeLists.txt: Fix some OSX linker problems.
+
+2016-12-30 Christian Beier <dontmind@freeshell.org>
+
+ * libvncserver/websockets.c: Use unprefixed b64_* functions in
+ websockets code.
+
+2016-12-30 Christian Beier <dontmind@freeshell.org>
+
+ * common/md5.c, common/md5.h: Fix building on OSX without SSL.
+
+2016-12-30 Christian Beier <dontmind@freeshell.org>
+
+ * .travis.yml: TravisCI: use newer dist.
+
+2016-12-30 Christian Beier <dontmind@freeshell.org>
+
+ * CMakeLists.txt: CMake: CMP0037 requires CMake 3.0.
+
+2016-12-30 Christian Beier <dontmind@freeshell.org>
+
+ * CMakeLists.txt: CMake: output examples to respective directories.
+
+2016-11-18 Christian Beier <dontmind@freeshell.org>
+
+ * .travis.yml: TravisCI: switch to CMake. Conflicts: .travis.yml
+
+2016-12-30 Christian Beier <dontmind@freeshell.org>
+
+ * ChangeLog: Update ChangeLog.
+
2016-12-29 Christian Beier <dontmind@freeshell.org>
* README: Fix README markdown.
@@ -103,6 +1243,14 @@
negative number. This will make it possible for x11vnc to enforce
its -noipv6 option, as discussed in the following bug report: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=672449
+2016-06-21 Balazs Ludmany <ludmany.balazs@cloud.bme.hu>
+
+ * libvncclient/corre.c, libvncclient/hextile.c,
+ libvncclient/rfbproto.c, libvncclient/rre.c, libvncclient/tight.c,
+ libvncclient/ultra.c, libvncclient/vncviewer.c,
+ libvncclient/zlib.c, libvncclient/zrle.c, rfb/rfbclient.h: Add
+ function pointers for every type of rectangle
+
2016-06-05 Christian Beier <dontmind@freeshell.org>
* NEWS: Update NEWS.
@@ -210,18 +1358,18 @@
* examples/camera.c: Fix memory access error in camera.c example
-2016-03-05 Cédric Georges <cgeorges@edge-airport.com>
+2016-03-05 Cdric Georges <cgeorges@edge-airport.com>
* CMakeLists.txt, libvncclient/tls_gnutls.c: Append missing include
directory for GNUTLS and OPENSSL in CMake project Append support of
gnutls > v 2.99.01 (gnutls_transport_set_global_errno have a
different signature)
-2016-03-05 Cédric Georges <cgeorges@edge-airport.com>
+2016-03-05 Cdric Georges <cgeorges@edge-airport.com>
* CMakeLists.txt: re-up comment
-2016-03-05 Cédric Georges <cgeorges@edge-airport.com>
+2016-03-05 Cdric Georges <cgeorges@edge-airport.com>
* CMakeLists.txt, rfb/rfbconfig.h.cmake: Append IPv6 option in CMake
Project
@@ -322,7 +1470,7 @@
* client_examples/gtkvncviewer.c, configure.ac,
libvncclient/Makefile.am, libvncclient/h264.c,
libvncclient/rfbproto.c, libvncclient/vncviewer.c, rfb/rfbproto.h:
- Revert "LibVNCClient: Add H.264 encoding for framebuffer updates" This reverts commit d891478ec985660c03f95cffda0e6a1ad4ba350c. Conflicts: configure.ac libvncclient/h264.c
+ Revert "LibVNCClient: Add H.264 encoding for framebuffer updates" This reverts commit d891478ec985660c03f95cffda0e6a1ad4ba350c. Conflicts: configure.ac libvncclient/h264.c
2015-04-17 Christian Beier <dontmind@freeshell.org>
@@ -339,12 +1487,12 @@
prepended. Respect that here and have autotools autodetect the
appropriate tool.
-2015-04-13 Benjamin Dürholt <b.duerholt@portunity.de>
+2015-04-13 Benjamin Drholt <b.duerholt@portunity.de>
* libvncserver/rfbssl_gnutls.c, libvncserver/tight.c: Changed C++
style comments to C ones
-2015-04-10 Benjamin Dürholt <b.duerholt@portunity.de>
+2015-04-10 Benjamin Drholt <b.duerholt@portunity.de>
* libvncserver/rfbssl_gnutls.c, libvncserver/tight.c: prevent
segfault
@@ -525,7 +1673,7 @@
([oCERT-2014-008]): LibVNCServer HandleRFBServerMessage rfbServerCutText malicious
msg.sct.length It looks like there may be a chance for potential memory corruption
when a LibVNCServer client attempts to process a Server Cut Text
- message. case rfbServerCutText: { char *buffer; if (!ReadFromRFBServer(client, ((char *)&msg) + 1, sz_rfbServerCutTextMsg - 1)) return FALSE; msg.sct.length = rfbClientSwap32IfLE(msg.sct.length); <<
+ message. case rfbServerCutText: { char *buffer; if (!ReadFromRFBServer(client, ((char *)&msg) + 1, sz_rfbServerCutTextMsg - 1)) return FALSE; msg.sct.length = rfbClientSwap32IfLE(msg.sct.length); <<
Retrieve malicious length buffer = malloc(msg.sct.length+1); << Allocate buffer. Can
return 0x0 if (!ReadFromRFBServer(client, buffer, msg.sct.length)) <<
Attempt to write to buffer return FALSE; buffer[msg.sct.length] = 0; << Attempt to write to buffer if (client->GotXCutText) client->GotXCutText(client, buffer, msg.sct.length); <<
@@ -1036,7 +2184,7 @@
2014-04-05 Johannes Schindelin <johannes.schindelin@gmx.de>
- * .gitignore: Ignore the vencrypt document https://www.berrange.com/~dan/vencrypt.txt Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
+ * .gitignore: Ignore the vencrypt document https://www.berrange.com/~dan/vencrypt.txt Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2014-04-05 Johannes Schindelin <johannes.schindelin@gmx.de>
@@ -1055,7 +2203,7 @@
* .gitignore, examples/Makefile.am, examples/repeater.c: Add an
example how to connect to an UltraVNC-style repeater UltraVNC offers an add-on to connect clients and servers via IDs
with a so-called repeater (e.g. to bridge firewalled clients and
- servers): http://www.uvnc.com/products/uvnc-repeater.html This example demonstrates how to use that feature with a
+ servers): http://www.uvnc.com/products/uvnc-repeater.html This example demonstrates how to use that feature with a
LibVNCServer-based server. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2014-04-05 Christian Beier <dontmind@freeshell.org>
@@ -1071,7 +2219,7 @@
2014-03-30 Johannes Schindelin <johannes.schindelin@gmx.de>
* .gitignore: Ignore more generated files While at it, also ignore the documentation of the RFB protocol best
- downloaded manually from http://www.realvnc.com/docs/rfbproto.pdf Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
+ downloaded manually from http://www.realvnc.com/docs/rfbproto.pdf Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2014-03-30 Robbert Klarenbeek <robbertkl@users.sourceforge.net>
@@ -1415,10 +2563,9 @@
2012-04-14 Christian Beier <dontmind@freeshell.org>
- * libvncclient/Makefile.am, libvncclient/tls.c,
- libvncclient/tls_gnutls.c, libvncclient/tls_none.c,
- libvncclient/tls_openssl.c: Add the OpenSSL libvncclient TLS version
- to the build system.
+ * libvncclient/Makefile.am, libvncclient/{tls.c => tls_gnutls.c},
+ libvncclient/tls_none.c, libvncclient/tls_openssl.c: Add the OpenSSL
+ libvncclient TLS version to the build system.
2012-04-12 Christian Beier <dontmind@freeshell.org>
@@ -1818,88 +2965,64 @@
2011-11-09 Christian Beier <dontmind@freeshell.org>
* configure.ac, webclients/Makefile.am, webclients/index.vnc,
- webclients/java-applet/Makefile.am,
- webclients/java-applet/javaviewer.pseudo_proxy.patch,
- webclients/java-applet/ssl/Makefile.am,
- webclients/java-applet/ssl/README,
- webclients/java-applet/ssl/index.vnc,
- webclients/java-applet/ssl/onetimekey,
- webclients/java-applet/ssl/proxy.vnc,
- webclients/java-applet/ssl/ss_vncviewer,
- webclients/java-applet/ssl/tightvnc-1.3dev7_javasrc-vncviewer-curso
- r-colors+no-tab-traversal.patch,
- webclients/java-applet/ssl/tightvnc-1.3dev7_javasrc-vncviewer-ssl.p
- atch, webclients/java-applet/ssl/ultra.vnc,
- webclients/java-applet/ssl/ultraproxy.vnc,
- webclients/java-applet/ssl/ultrasigned.vnc,
- webclients/java-applet/ssl/ultravnc-102-JavaViewer-ssl-etc.patch,
- webclients/javaviewer.pseudo_proxy.patch,
- webclients/ssl/Makefile.am, webclients/ssl/README,
- webclients/ssl/index.vnc, webclients/ssl/onetimekey,
- webclients/ssl/proxy.vnc, webclients/ssl/ss_vncviewer,
- webclients/ssl/tightvnc-1.3dev7_javasrc-vncviewer-cursor-colors+no-
- tab-traversal.patch,
- webclients/ssl/tightvnc-1.3dev7_javasrc-vncviewer-ssl.patch,
- webclients/ssl/ultra.vnc, webclients/ssl/ultraproxy.vnc,
- webclients/ssl/ultrasigned.vnc,
- webclients/ssl/ultravnc-102-JavaViewer-ssl-etc.patch: Move the java
- stuff into webclients/java-applet.
+ webclients/java-applet/Makefile.am, webclients/{ =>
+ java-applet}/javaviewer.pseudo_proxy.patch, webclients/{ =>
+ java-applet}/ssl/Makefile.am, webclients/{ =>
+ java-applet}/ssl/README, webclients/{ =>
+ java-applet}/ssl/index.vnc, webclients/{ =>
+ java-applet}/ssl/onetimekey, webclients/{ =>
+ java-applet}/ssl/proxy.vnc, webclients/{ =>
+ java-applet}/ssl/ss_vncviewer, webclients/{ =>
+ java-applet}/ssl/tightvnc-1.3dev7_javasrc-vncviewer-cursor-colors+n
+ o-tab-traversal.patch, webclients/{ =>
+ java-applet}/ssl/tightvnc-1.3dev7_javasrc-vncviewer-ssl.patch,
+ webclients/{ => java-applet}/ssl/ultra.vnc, webclients/{ =>
+ java-applet}/ssl/ultraproxy.vnc, webclients/{ =>
+ java-applet}/ssl/ultrasigned.vnc, webclients/{ =>
+ java-applet}/ssl/ultravnc-102-JavaViewer-ssl-etc.patch: Move the
+ java stuff into webclients/java-applet.
2011-11-09 Christian Beier <dontmind@freeshell.org>
- * LibVNCServer.spec.in, Makefile.am, README, classes/Makefile.am,
- classes/index.vnc, classes/javaviewer.pseudo_proxy.patch,
- classes/novnc/LICENSE.txt, classes/novnc/README.md,
- classes/novnc/favicon.ico, classes/novnc/include/base.css,
- classes/novnc/include/base64.js, classes/novnc/include/black.css,
- classes/novnc/include/blue.css, classes/novnc/include/des.js,
- classes/novnc/include/display.js, classes/novnc/include/input.js,
- classes/novnc/include/logo.js, classes/novnc/include/playback.js,
- classes/novnc/include/rfb.js, classes/novnc/include/ui.js,
- classes/novnc/include/util.js, classes/novnc/include/vnc.js,
- classes/novnc/include/web-socket-js/README.txt,
- classes/novnc/include/web-socket-js/swfobject.js,
- classes/novnc/include/web-socket-js/web_socket.js,
- classes/novnc/include/websock.js, classes/novnc/include/webutil.js,
- classes/novnc/vnc.html, classes/novnc/vnc_auto.html,
- classes/ssl/Makefile.am, classes/ssl/README, classes/ssl/index.vnc,
- classes/ssl/onetimekey, classes/ssl/proxy.vnc,
- classes/ssl/ss_vncviewer,
- classes/ssl/tightvnc-1.3dev7_javasrc-vncviewer-cursor-colors+no-tab
- -traversal.patch,
- classes/ssl/tightvnc-1.3dev7_javasrc-vncviewer-ssl.patch,
- classes/ssl/ultra.vnc, classes/ssl/ultraproxy.vnc,
- classes/ssl/ultrasigned.vnc,
- classes/ssl/ultravnc-102-JavaViewer-ssl-etc.patch, configure.ac,
+ * LibVNCServer.spec.in, Makefile.am, README, configure.ac,
examples/example.c, examples/pnmshow.c, examples/pnmshow24.c,
- rfb/rfb.h, webclients/Makefile.am, webclients/index.vnc,
- webclients/javaviewer.pseudo_proxy.patch,
- webclients/novnc/LICENSE.txt, webclients/novnc/README.md,
- webclients/novnc/favicon.ico, webclients/novnc/include/base.css,
- webclients/novnc/include/base64.js,
- webclients/novnc/include/black.css,
- webclients/novnc/include/blue.css, webclients/novnc/include/des.js,
- webclients/novnc/include/display.js,
- webclients/novnc/include/input.js,
- webclients/novnc/include/logo.js,
- webclients/novnc/include/playback.js,
- webclients/novnc/include/rfb.js, webclients/novnc/include/ui.js,
- webclients/novnc/include/util.js, webclients/novnc/include/vnc.js,
- webclients/novnc/include/web-socket-js/README.txt,
- webclients/novnc/include/web-socket-js/swfobject.js,
- webclients/novnc/include/web-socket-js/web_socket.js,
- webclients/novnc/include/websock.js,
- webclients/novnc/include/webutil.js, webclients/novnc/vnc.html,
- webclients/novnc/vnc_auto.html, webclients/ssl/Makefile.am,
- webclients/ssl/README, webclients/ssl/index.vnc,
- webclients/ssl/onetimekey, webclients/ssl/proxy.vnc,
- webclients/ssl/ss_vncviewer,
- webclients/ssl/tightvnc-1.3dev7_javasrc-vncviewer-cursor-colors+no-
- tab-traversal.patch,
- webclients/ssl/tightvnc-1.3dev7_javasrc-vncviewer-ssl.patch,
- webclients/ssl/ultra.vnc, webclients/ssl/ultraproxy.vnc,
- webclients/ssl/ultrasigned.vnc,
- webclients/ssl/ultravnc-102-JavaViewer-ssl-etc.patch: Rename
+ rfb/rfb.h, {classes => webclients}/Makefile.am, {classes =>
+ webclients}/index.vnc, {classes =>
+ webclients}/javaviewer.pseudo_proxy.patch, {classes =>
+ webclients}/novnc/LICENSE.txt, {classes =>
+ webclients}/novnc/README.md, {classes =>
+ webclients}/novnc/favicon.ico, {classes =>
+ webclients}/novnc/include/base.css, {classes =>
+ webclients}/novnc/include/base64.js, {classes =>
+ webclients}/novnc/include/black.css, {classes =>
+ webclients}/novnc/include/blue.css, {classes =>
+ webclients}/novnc/include/des.js, {classes =>
+ webclients}/novnc/include/display.js, {classes =>
+ webclients}/novnc/include/input.js, {classes =>
+ webclients}/novnc/include/logo.js, {classes =>
+ webclients}/novnc/include/playback.js, {classes =>
+ webclients}/novnc/include/rfb.js, {classes =>
+ webclients}/novnc/include/ui.js, {classes =>
+ webclients}/novnc/include/util.js, {classes =>
+ webclients}/novnc/include/vnc.js, {classes =>
+ webclients}/novnc/include/web-socket-js/README.txt, {classes =>
+ webclients}/novnc/include/web-socket-js/swfobject.js, {classes =>
+ webclients}/novnc/include/web-socket-js/web_socket.js, {classes =>
+ webclients}/novnc/include/websock.js, {classes =>
+ webclients}/novnc/include/webutil.js, {classes =>
+ webclients}/novnc/vnc.html, {classes =>
+ webclients}/novnc/vnc_auto.html, {classes =>
+ webclients}/ssl/Makefile.am, {classes => webclients}/ssl/README,
+ {classes => webclients}/ssl/index.vnc, {classes =>
+ webclients}/ssl/onetimekey, {classes => webclients}/ssl/proxy.vnc,
+ {classes => webclients}/ssl/ss_vncviewer, {classes =>
+ webclients}/ssl/tightvnc-1.3dev7_javasrc-vncviewer-cursor-colors+no
+ -tab-traversal.patch, {classes =>
+ webclients}/ssl/tightvnc-1.3dev7_javasrc-vncviewer-ssl.patch,
+ {classes => webclients}/ssl/ultra.vnc, {classes =>
+ webclients}/ssl/ultraproxy.vnc, {classes =>
+ webclients}/ssl/ultrasigned.vnc, {classes =>
+ webclients}/ssl/ultravnc-102-JavaViewer-ssl-etc.patch: Rename
'classes' dir to 'webclients'.
2011-11-09 Christian Beier <dontmind@freeshell.org>
@@ -1972,7 +3095,7 @@
2011-10-16 George Fleury <gfleury@gmail.com>
* libvncserver/rfbserver.c: Fix memory leak I was debbuging some code tonight and i found a pointer that is not
- been freed, so i think there is maybe a memory leak, so it is... there is the malloc caller reverse order: ( malloc cl->statEncList ) <- rfbStatLookupEncoding <- rfbStatRecordEncodingSent <- rfbSendCursorPos <- rfbSendFramebufferUpdate <- rfbProcessEvents I didnt look the whole libvncserver api, but i am using
+ been freed, so i think there is maybe a memory leak, so it is... there is the malloc caller reverse order: ( malloc cl->statEncList ) <- rfbStatLookupEncoding <- rfbStatRecordEncodingSent <- rfbSendCursorPos <- rfbSendFramebufferUpdate <- rfbProcessEvents I didnt look the whole libvncserver api, but i am using
rfbReverseConnection with rfbProcessEvents, and then when the client
connection dies, i am calling a rfbShutdownServer and
rfbScreenCleanup, but the malloc at rfbStatLookupEncoding isnt been
@@ -2190,9 +3313,9 @@
2011-08-16 Gernot Tenchio <gernot.tenchio@securepoint.de>
- * CMakeLists.txt, common/md5.c, common/md5.h,
- libvncserver/Makefile.am, libvncserver/md5.c, libvncserver/md5.h:
- Move libvncserver/md5* to common Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
+ * CMakeLists.txt, {libvncserver => common}/md5.c, {libvncserver =>
+ common}/md5.h, libvncserver/Makefile.am: Move libvncserver/md5* to
+ common Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2011-08-16 Gernot Tenchio <gernot.tenchio@securepoint.de>
@@ -2325,7 +3448,7 @@
mechanism. This is required to be able to do proper event loop integration with
Qt. Idea was taken from vino's libvncserver fork. Signed-off-by: Christian Beier <dontmind@freeshell.org>
-2011-05-06 Cristian Rodríguez <crrodriguez@opensuse.org>
+2011-05-06 Cristian Rodrguez <crrodriguez@opensuse.org>
* libvncserver/tightvnc-filetransfer/filetransfermsg.c: Fix buffer
overflow Signed-off-by: Cristian Rodríguez <crrodriguez@opensuse.org>
@@ -2381,7 +3504,7 @@
2011-03-29 Christian Beier <dontmind@freeshell.org>
- * bdf2c.pl, consolefont2c.pl, utils/bdf2c.pl,
+ * bdf2c.pl => utils/bdf2c.pl, consolefont2c.pl =>
utils/consolefont2c.pl, utils/git2cl.pl: Add a git-log to GNU-Style
ChangeLog converter script. Also put all helper scripts into a utils directory.
@@ -2499,8 +3622,9 @@
2011-03-10 Christian Beier <dontmind@freeshell.org>
- * Makefile.am, configure.ac, contrib/Makefile.am, contrib/zippy.c,
- examples/Makefile.am, examples/zippy.c: Move zippy.c to examples.
+ * Makefile.am, configure.ac, contrib/Makefile.am,
+ examples/Makefile.am, {contrib => examples}/zippy.c: Move zippy.c to
+ examples.
2011-03-03 Christian Beier <dontmind@freeshell.org>
@@ -2560,16 +3684,16 @@
2011-01-25 Christian Beier <dontmind@freeshell.org>
- * CMakeLists.txt, common/d3des.c, common/d3des.h, common/lzoconf.h,
- common/minilzo.c, common/minilzo.h, common/vncauth.c,
- common/zywrletemplate.c, libvncclient/Makefile.am,
- libvncclient/lzoconf.h, libvncclient/minilzo.c,
+ * CMakeLists.txt, {libvncserver => common}/d3des.c, {libvncserver
+ => common}/d3des.h, {libvncclient => common}/lzoconf.h,
+ {libvncserver => common}/minilzo.c, {libvncserver =>
+ common}/minilzo.h, {libvncserver => common}/vncauth.c,
+ {libvncserver => common}/zywrletemplate.c,
+ libvncclient/Makefile.am, libvncclient/minilzo.c,
libvncclient/minilzo.h, libvncclient/rfbproto.c,
libvncclient/zrle.c, libvncserver/Makefile.am,
- libvncserver/d3des.c, libvncserver/d3des.h, libvncserver/lzoconf.h,
- libvncserver/minilzo.c, libvncserver/minilzo.h,
- libvncserver/vncauth.c, libvncserver/zywrletemplate.c: Put files
- used by both libs into a 'common' dir. No functional changes. All files used by _both_ libvncserver and
+ libvncserver/lzoconf.h: Put files used by both libs into a 'common'
+ dir. No functional changes. All files used by _both_ libvncserver and
libvncclient are put into a 'common' directory and references from
other files as well as Autotools and CMake build systems are
updated. Signed-off-by: Christian Beier <dontmind@freeshell.org>
@@ -7227,7 +8351,7 @@
2004-10-16 dscho <dscho>
- * test/Makefile.am, test/encodingstest.c, test/tight-1.c: rename
+ * test/Makefile.am, test/{tight-1.c => encodingstest.c}: rename
tight-1.c into encodingstest.c, fixing it in the process. It now
passes all encodings except corre (broken) and zrle (not yet
implemented in libvncclient)
@@ -7505,7 +8629,7 @@
2004-06-07 dscho <dscho>
- * LibVNCServer.spec.in, Makefile.am, libvncserver.spec.in,
+ * libvncserver.spec.in => LibVNCServer.spec.in, Makefile.am,
prepare_x11vnc_dist.sh: fix bug 968264: make rpm did not work with
x11vnc package
@@ -7535,11 +8659,11 @@
* ChangeLog, Makefile.am, TODO, client_examples/Makefile.am,
client_examples/SDLvncviewer.c, client_examples/ppmtest.c,
configure.ac, contrib/Makefile.am, examples/Makefile.am,
- examples/blooptest.c, examples/copyrecttest.c,
- libvncclient/Makefile.am, libvncclient/client_test.c,
- libvncclient/sockets.c, libvncclient/vncviewer.c,
- libvncserver/Makefile.am, prepare_x11vnc_dist.sh, rfb/rfbclient.h,
- test/Makefile.am, test/blooptest.c, test/copyrecttest.c,
+ examples/blooptest.c, libvncclient/Makefile.am,
+ libvncclient/client_test.c, libvncclient/sockets.c,
+ libvncclient/vncviewer.c, libvncserver/Makefile.am,
+ prepare_x11vnc_dist.sh, rfb/rfbclient.h, test/Makefile.am,
+ test/blooptest.c, {examples => test}/copyrecttest.c,
test/tight-1.c, x11vnc/Makefile.am: add client_examples/, add
SDLvncviewer, libvncclient API changes, suppress automake CFLAGS
nagging
@@ -7570,37 +8694,37 @@
2004-05-25 dscho <dscho>
- * ChangeLog, Makefile.am, auth.c, cargs.c, configure.ac,
- contrib/ChangeLog, contrib/Makefile.am, contrib/x11vnc.c, corre.c,
- cursor.c, cutpaste.c, d3des.c, d3des.h, draw.c,
- examples/Makefile.am, examples/regiontest.c, font.c, hextile.c,
- httpd.c, libvncclient/rfbproto.c, libvncserver/Makefile.am,
- libvncserver/auth.c, libvncserver/cargs.c, libvncserver/config.h,
- libvncserver/corre.c, libvncserver/cursor.c,
- libvncserver/cutpaste.c, libvncserver/d3des.c,
- libvncserver/d3des.h, libvncserver/draw.c, libvncserver/font.c,
- libvncserver/hextile.c, libvncserver/httpd.c, libvncserver/main.c,
- libvncserver/rfbconfig.h, libvncserver/rfbregion.c,
- libvncserver/rfbserver.c, libvncserver/rre.c,
- libvncserver/selbox.c, libvncserver/sockets.c,
- libvncserver/stats.c, libvncserver/tableinit24.c,
- libvncserver/tableinitcmtemplate.c,
- libvncserver/tableinittctemplate.c,
- libvncserver/tabletrans24template.c,
- libvncserver/tabletranstemplate.c, libvncserver/tight.c,
- libvncserver/translate.c, libvncserver/vncauth.c,
- libvncserver/zlib.c, libvncserver/zrle.c,
- libvncserver/zrleencodetemplate.c, libvncserver/zrleoutstream.c,
- libvncserver/zrleoutstream.h, libvncserver/zrlepalettehelper.c,
- libvncserver/zrlepalettehelper.h, libvncserver/zrletypes.h, main.c,
- rfbregion.c, rfbserver.c, rre.c, selbox.c, sockets.c, stats.c,
- tableinit24.c, tableinitcmtemplate.c, tableinittctemplate.c,
- tabletrans24template.c, tabletranstemplate.c, test/Makefile.am,
- tight.c, translate.c, vncauth.c, vncterm/Makefile.am,
- x11vnc/ChangeLog, x11vnc/Makefile.am, x11vnc/x11vnc.c, zlib.c,
- zrle.c, zrleencodetemplate.c, zrleoutstream.c, zrleoutstream.h,
- zrlepalettehelper.c, zrlepalettehelper.h, zrletypes.h: move the
- library into libvncserver/, x11vnc into x11vnc/
+ * ChangeLog, Makefile.am, configure.ac, contrib/Makefile.am,
+ examples/Makefile.am, examples/regiontest.c,
+ libvncclient/rfbproto.c, libvncserver/Makefile.am, auth.c =>
+ libvncserver/auth.c, cargs.c => libvncserver/cargs.c,
+ libvncserver/config.h, corre.c => libvncserver/corre.c, cursor.c =>
+ libvncserver/cursor.c, cutpaste.c => libvncserver/cutpaste.c,
+ d3des.c => libvncserver/d3des.c, d3des.h => libvncserver/d3des.h,
+ draw.c => libvncserver/draw.c, font.c => libvncserver/font.c,
+ hextile.c => libvncserver/hextile.c, httpd.c =>
+ libvncserver/httpd.c, main.c => libvncserver/main.c,
+ libvncserver/rfbconfig.h, rfbregion.c => libvncserver/rfbregion.c,
+ rfbserver.c => libvncserver/rfbserver.c, rre.c =>
+ libvncserver/rre.c, selbox.c => libvncserver/selbox.c, sockets.c =>
+ libvncserver/sockets.c, stats.c => libvncserver/stats.c,
+ tableinit24.c => libvncserver/tableinit24.c, tableinitcmtemplate.c
+ => libvncserver/tableinitcmtemplate.c, tableinittctemplate.c =>
+ libvncserver/tableinittctemplate.c, tabletrans24template.c =>
+ libvncserver/tabletrans24template.c, tabletranstemplate.c =>
+ libvncserver/tabletranstemplate.c, tight.c => libvncserver/tight.c,
+ translate.c => libvncserver/translate.c, vncauth.c =>
+ libvncserver/vncauth.c, zlib.c => libvncserver/zlib.c, zrle.c =>
+ libvncserver/zrle.c, zrleencodetemplate.c =>
+ libvncserver/zrleencodetemplate.c, zrleoutstream.c =>
+ libvncserver/zrleoutstream.c, zrleoutstream.h =>
+ libvncserver/zrleoutstream.h, zrlepalettehelper.c =>
+ libvncserver/zrlepalettehelper.c, zrlepalettehelper.h =>
+ libvncserver/zrlepalettehelper.h, zrletypes.h =>
+ libvncserver/zrletypes.h, test/Makefile.am, vncterm/Makefile.am,
+ {contrib => x11vnc}/ChangeLog, x11vnc/Makefile.am, {contrib =>
+ x11vnc}/x11vnc.c: move the library into libvncserver/, x11vnc into
+ x11vnc/
2004-05-22 runge <runge>
@@ -8106,11 +9230,10 @@
2003-02-18 dscho <dscho>
- * Makefile.am, configure.ac, include/.cvsignore,
- include/default8x16.h, include/keysym.h, include/rfb.h,
- include/rfbproto.h, include/rfbregion.h, rfb/default8x16.h,
- rfb/keysym.h, rfb/rfb.h, rfb/rfbproto.h, rfb/rfbregion.h: moved
- include/ to rfb/
+ * Makefile.am, configure.ac, include/.cvsignore, {include =>
+ rfb}/default8x16.h, {include => rfb}/keysym.h, {include =>
+ rfb}/rfb.h, {include => rfb}/rfbproto.h, {include =>
+ rfb}/rfbregion.h: moved include/ to rfb/
2003-02-18 dscho <dscho>
@@ -8198,15 +9321,15 @@
2003-02-09 dscho <dscho>
- * .cvsignore, configure.ac, examples/mac.c, mac.c: moved the
+ * .cvsignore, configure.ac, mac.c => examples/mac.c: moved the
OSXvnc-server to examples; IRIX fixes (not really IRIX, but shows
there)
2003-02-09 dscho <dscho>
* Makefile.am, examples/Makefile.am, examples/regiontest.c,
- examples/sratest.c, include/rfbregion.h, main.c, rfbregion.c,
- rfbserver.c, sraRegion.c, sraRegion.h, translate.c: renamed
+ examples/sratest.c, sraRegion.h => include/rfbregion.h, main.c,
+ sraRegion.c => rfbregion.c, rfbserver.c, translate.c: renamed
sraRegion to rfbregion and put it in include/; will be installed now
2003-02-09 dscho <dscho>
@@ -8289,7 +9412,7 @@
2003-02-08 dscho <dscho>
- * AUTHORS, CHANGES, ChangeLog, NEWS, TODO: further autoconf'ing
+ * AUTHORS, CHANGES => ChangeLog, NEWS, TODO: further autoconf'ing
2003-02-08 dscho <dscho>
@@ -8297,7 +9420,7 @@
contrib/Makefile, contrib/Makefile.am, examples/Makefile,
examples/Makefile.am, examples/example.c, include/rfb.h,
include/rfbproto.h, main.c, rfbserver.c, sockets.c, tight.c,
- zlib.c, zrle.cc, zrle.cxx: autoconf'ed everything
+ zlib.c, zrle.cc => zrle.cxx: autoconf'ed everything
2003-02-07 dscho <dscho>
@@ -8310,19 +9433,19 @@
2003-02-07 dscho <dscho>
- * 1instance.c, Makefile, contrib/Makefile, contrib/zippy.c,
- default8x16.h, examples/1instance.c, examples/pnmshow24.c,
- include/default8x16.h, include/keysym.h, include/rfb.h,
- include/rfbproto.h, keysym.h, main.c, radon.h, rfb.h, rfbproto.h:
+ * Makefile, contrib/Makefile, contrib/zippy.c, 1instance.c =>
+ examples/1instance.c, examples/pnmshow24.c, default8x16.h =>
+ include/default8x16.h, keysym.h => include/keysym.h, rfb.h =>
+ include/rfb.h, rfbproto.h => include/rfbproto.h, main.c, radon.h:
moved files to include; moved a file to examples/
2003-02-07 dscho <dscho>
- * CHANGES, example.c, example.dsp, examples/example.c,
- examples/example.dsp, examples/fontsel.c, examples/pnmshow.c,
- examples/pnmshow24.c, examples/storepasswd.c, examples/vncev.c,
- fontsel.c, pnmshow.c, pnmshow24.c, storepasswd.c, vncev.c: moved
- files to contrib/ and examples/
+ * CHANGES, example.c => examples/example.c, example.dsp =>
+ examples/example.dsp, fontsel.c => examples/fontsel.c, pnmshow.c =>
+ examples/pnmshow.c, pnmshow24.c => examples/pnmshow24.c,
+ storepasswd.c => examples/storepasswd.c, vncev.c =>
+ examples/vncev.c: moved files to contrib/ and examples/
2002-12-30 dscho <dscho>
@@ -8367,8 +9490,8 @@
2002-12-06 dscho <dscho>
- * CHANGES, Makefile, contrib/x11vnc.c, contrib/zippy.c, httpd.c,
- main.c, rfb.h, x11vnc.c, zippy.c: compiler warnings, contrib
+ * CHANGES, Makefile, contrib/x11vnc.c, zippy.c => contrib/zippy.c,
+ httpd.c, main.c, rfb.h, x11vnc.c: compiler warnings, contrib
directory, new x11vnc from Karl Runge
2002-10-29 dscho <dscho>
@@ -8971,9 +10094,9 @@
2001-09-25 dscho <dscho>
- * d3des.c, d3des.h, libvncauth/Imakefile, libvncauth/Makefile,
- libvncauth/d3des.c, libvncauth/d3des.h, libvncauth/vncauth.c,
- libvncauth/vncauth.h, vncauth.c: permanently moved authorization
+ * libvncauth/d3des.c => d3des.c, libvncauth/d3des.h => d3des.h,
+ libvncauth/Imakefile, libvncauth/Makefile, libvncauth/vncauth.h,
+ libvncauth/vncauth.c => vncauth.c: permanently moved authorization
2001-09-25 dscho <dscho>
diff --git a/LibVNCServer.spec.in b/LibVNCServer.spec.in
deleted file mode 100644
index 13fe351..0000000
--- a/LibVNCServer.spec.in
+++ /dev/null
@@ -1,97 +0,0 @@
-# Note that this is NOT a relocatable package
-Name: @PACKAGE@
-Version: @VERSION@
-Release: 2
-Summary: a library to make writing a vnc server easy
-Copyright: GPL
-Group: Libraries/Network
-Packager: Johannes.Schindelin <Johannes.Schindelin@gmx.de>
-Source: %{name}-%{version}.tar.gz
-BuildRoot: %{_tmppath}/%{name}-%{version}-buildroot
-
-%description
-LibVNCServer makes writing a VNC server (or more correctly, a program
-exporting a framebuffer via the Remote Frame Buffer protocol) easy.
-
-It is based on OSXvnc, which in turn is based on the original Xvnc by
-ORL, later AT&T research labs in UK.
-
-It hides the programmer from the tedious task of managing clients and
-compression schemata.
-
-LibVNCServer was put together and is (actively ;-) maintained by
-Johannes Schindelin <Johannes.Schindelin@gmx.de>
-
-%package devel
-Requires: %{name} = %{version}
-Summary: Static Libraries and Header Files for LibVNCServer
-Group: Libraries/Network
-Requires: %{name} = %{version}
-
-%description devel
-Static Libraries and Header Files for LibVNCServer.
-
-%package x11vnc
-Requires: %{name} = %{version}
-Summary: VNC server for the current X11 session
-Group: User Interface/X
-Requires: %{name} = %{version}
-
-%description x11vnc
-x11vnc is to X Window System what WinVNC is to Windows, i.e. a server
-which serves the current X Window System desktop via RFB (VNC)
-protocol to the user.
-
-Based on the ideas of x0rfbserver and on LibVNCServer, it has evolved
-into a versatile and performant while still easy to use program.
-
-%prep
-%setup -n %{name}-%{version}
-
-%build
-# CFLAGS="$RPM_OPT_FLAGS" ./configure --prefix=%{_prefix}
-%configure
-make
-
-%install
-[ -n "%{buildroot}" -a "%{buildroot}" != / ] && rm -rf %{buildroot}
-# make install prefix=%{buildroot}%{_prefix}
-%makeinstall includedir="%{buildroot}%{_includedir}/rfb"
-
-%{__install} -d -m0755 %{buildroot}%{_datadir}/x11vnc/classes
-%{__install} webclients/VncViewer.jar webclients/index.vnc \
- %{buildroot}%{_datadir}/x11vnc/classes
-
-%clean
-[ -n "%{buildroot}" -a "%{buildroot}" != / ] && rm -rf %{buildroot}
-
-%pre
-%post
-%preun
-%postun
-
-%files
-%defattr(-,root,root)
-%doc README INSTALL AUTHORS ChangeLog NEWS TODO
-%{_bindir}/LinuxVNC
-%{_bindir}/libvncserver-config
-%{_libdir}/libvncclient.*
-%{_libdir}/libvncserver.*
-
-%files devel
-%defattr(-,root,root)
-%{_includedir}/rfb/*
-
-%files x11vnc
-%defattr(-,root,root)
-%{_bindir}/x11vnc
-%{_mandir}/man1/x11vnc.1*
-%{_datadir}/x11vnc/classes
-
-%changelog
-* Fri Aug 19 2005 Alberto Lusiani <alusiani@gmail.com> release 2
-- create separate package for x11vnc to prevent conflicts with x11vnc rpm
-- create devel package, needed to compile but not needed for running
-* Sun Feb 9 2003 Johannes Schindelin
-- created libvncserver.spec.in
-
diff --git a/Makefile.am b/Makefile.am
deleted file mode 100644
index a7bc64d..0000000
--- a/Makefile.am
+++ /dev/null
@@ -1,28 +0,0 @@
-ACLOCAL_AMFLAGS = -I m4
-
-SUBDIRS=libvncserver examples libvncclient webclients client_examples test
-DIST_SUBDIRS=libvncserver examples libvncclient webclients client_examples test
-EXTRA_DIST = CMakeLists.txt rfb/rfbconfig.h.cmake
-
-bin_SCRIPTS = libvncserver-config
-
-pkgconfigdir = $(libdir)/pkgconfig
-pkgconfig_DATA = libvncserver.pc libvncclient.pc
-
-includedir=$(prefix)/include/rfb
-
-include_HEADERS=rfb/rfb.h rfb/rfbconfig.h rfb/rfbproto.h \
- rfb/keysym.h rfb/rfbregion.h rfb/rfbclient.h
-
-$(PACKAGE)-$(VERSION).tar.gz: dist
-
-if HAVE_RPM
-# Rule to build RPM distribution package
-rpm: $(PACKAGE)-$(VERSION).tar.gz $(PACKAGE).spec
- cp $(PACKAGE)-$(VERSION).tar.gz @RPMSOURCEDIR@
- rpmbuild -ba $(PACKAGE).spec
-endif
-
-t:
- $(MAKE) -C test test
-
diff --git a/NEWS b/NEWS
index 8618efe..6f41e7b 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,38 @@
+0.9.12
+ - Overall changes:
+ * CMake now is the default build system, Autotools were removed.
+ * In addition to TravisCI, all commits are now build-tested by AppVeyorCI.
+
+ - LibVNCServer/LibVNCClient:
+ * Numerous build fixes for Visual Studio compilers to the extent that
+ one can now _build_ the project with these. The needed changes for
+ successfully _running_ stuff will be implemented in 0.9.13.
+ * Fixed building for Android and added build instructions.
+ * Removed the unused PolarSSL wrapper.
+ * Updated the bundled noVNC to latest release 1.0.0.
+ * Allowed to use global LZO library instead of miniLZO.
+
+ - LibVNCClient:
+ * Support for OpenSSL 1.1.x.
+ * Support for overriding the default rectangle decode handlers (with
+ hardware-accelerated ones for instance) thanks to Balazs Ludmany.
+ * vnc2mpg updated.
+ * Added support for X509 server certificate verification as part of the
+ handshake process thanks to Simon Waterman.
+ * Added a TRLE decoder thanks to Wiki Wang.
+ * Included Tight decoding optimizations from TurboVNC thanks to DRC.
+ * Ported the SDL viewer from SDL 1.2 to SDL 2.0.
+ * Numerous security fixes.
+ * Added support for custom auth handlers in order to support additional
+ security types.
+
+ - LibVNCServer:
+ * Websockets rework to remove obsolete code thanks to Andreas Weigel.
+ * Ensured compatibility with gtk-vnc 0.7.0+ thanks to Michał Kępień.
+ * The built-in webserver now sends correct MIME type for Javascript.
+ * Numerous memory management issues fixed.
+ * Made the TightVNC-style file transfer more stable.
+
0.9.11
- Overall changes:
* LibVNCServer/LibVNCClient development now uses continous intregration,
diff --git a/README b/README
deleted file mode 100644
index c930307..0000000
--- a/README
+++ /dev/null
@@ -1,447 +0,0 @@
-[![Build Status](https://travis-ci.org/LibVNC/libvncserver.svg?branch=master)](https://travis-ci.org/LibVNC/libvncserver)
-
-LibVNCServer: A library for easy implementation of a VNC server.
-Copyright (C) 2001-2003 Johannes E. Schindelin
-
-If you already used LibVNCServer, you probably want to read NEWS.
-
-What is it?
------------
-
-VNC is a set of programs using the RFB (Remote Frame Buffer) protocol. They
-are designed to "export" a frame buffer via net (if you don't know VNC, I
-suggest you read "Basics" below). It is already in wide use for
-administration, but it is not that easy to program a server yourself.
-
-This has been changed by LibVNCServer.
-
-There are two examples included:
- - example, a shared scribble sheet
- - pnmshow, a program to show PNMs (pictures) over the net.
-
-The examples are not too well documented, but easy straight forward and a
-good starting point.
-
-Try example: it outputs on which port it listens (default: 5900), so it is
-display 0. To view, call
- vncviewer :0
-You should see a sheet with a gradient and "Hello World!" written on it. Try
-to paint something. Note that every time you click, there is some bigger blot,
-whereas when you drag the mouse while clicked you draw a line. The size of the
-blot depends on the mouse button you click. Open a second vncviewer with
-the same parameters and watch it as you paint in the other window. This also
-works over internet. You just have to know either the name or the IP of your
-machine. Then it is
- vncviewer machine.where.example.runs.com:0
-or similar for the remote client. Now you are ready to type something. Be sure
-that your mouse sits still, because every time the mouse moves, the cursor is
-reset to the position of the pointer! If you are done with that demo, press
-the down or up arrows. If your viewer supports it, then the dimensions of the
-sheet change. Just press Escape in the viewer. Note that the server still
-runs, even if you closed both windows. When you reconnect now, everything you
-painted and wrote is still there. You can press "Page Up" for a blank page.
-
-The demo pnmshow is much simpler: you either provide a filename as argument
-or pipe a file through stdin. Note that the file has to be a raw pnm/ppm file,
-i.e. a truecolour graphics. Only the Escape key is implemented. This may be
-the best starting point if you want to learn how to use LibVNCServer. You
-are confronted with the fact that the bytes per pixel can only be 8, 16 or 32.
-
-Projects using it
-----------------------------------------
-
-VNC for KDE
-http://www.tjansen.de/krfb
-
-GemsVNC
-http://www.elilabs.com/~rj/gemsvnc/
-
-VNC for Netware
-http://forge.novell.com/modules/xfmod/project/?vncnw
-
-RDesktop
-http://rdesktop.sourceforge.net
-
-VNCpp
-https://github.com/ocrespo/VNCpp
-
-
-Mail me, if your application is missing!
-
-How to use
-----------
-
-To make a server, you just have to initialise a server structure using the
-function rfbDefaultScreenInit, like
- rfbScreenInfoPtr rfbScreen =
- rfbGetScreen(argc,argv,width,height,8,3,bpp);
-where byte per pixel should be 1, 2 or 4. If performance doesn't matter,
-you may try bpp=3 (internally one cannot use native data types in this
-case; if you want to use this, look at pnmshow24).
-
-
-You then can set hooks and io functions (see below) or other
-options (see below).
-
-And you allocate the frame buffer like this:
- rfbScreen->frameBuffer = (char*)malloc(width*height*bpp);
-
-After that, you initialize the server, like
- rfbInitServer(rfbScreen);
-
-You can use a blocking event loop, a background (pthread based) event loop,
-or implement your own using the rfbProcessEvents function.
-
-Making it interactive
----------------------
-
-Input is handled by IO functions (see below).
-
-Whenever you change something in the frame buffer, call rfbMarkRectAsModified.
-You should make sure that the cursor is not drawn before drawing yourself
-by calling rfbUndrawCursor. You can also draw the cursor using rfbDrawCursor,
-but it hardly seems necessary. For cursor details, see below.
-
-Utility functions
------------------
-
-Whenever you draw something, you have to call
- rfbMarkRectAsModified(screen,x1,y1,x2,y2).
-This tells LibVNCServer to send updates to all connected clients.
-
-Before you draw something, be sure to call
- rfbUndrawCursor(screen).
-This tells LibVNCServer to hide the cursor.
-Remark: There are vncviewers out there, which know a cursor encoding, so
-that network traffic is low, and also the cursor doesn't need to be
-drawn the cursor every time an update is sent. LibVNCServer handles
-all the details. Just set the cursor and don't bother any more.
-
-To set the mouse coordinates (or emulate mouse clicks), call
- rfbDefaultPtrAddEvent(buttonMask,x,y,cl);
-IMPORTANT: do this at the end of your function, because this actually draws
-the cursor if no cursor encoding is active.
-
-What is the difference between rfbScreenInfoPtr and rfbClientPtr?
------------------------------------------------------------------
-
-The rfbScreenInfoPtr is a pointer to a rfbScreenInfo structure, which
-holds information about the server, like pixel format, io functions,
-frame buffer etc.
-
-The rfbClientPtr is a pointer to an rfbClientRec structure, which holds
-information about a client, like pixel format, socket of the
-connection, etc.
-
-A server can have several clients, but needn't have any. So, if you
-have a server and three clients are connected, you have one instance
-of a rfbScreenInfo and three instances of rfbClientRec's.
-
-The rfbClientRec structure holds a member
- rfbScreenInfoPtr screen
-which points to the server and a member
- rfbClientPtr next
-to the next client.
-
-The rfbScreenInfo structure holds a member
- rfbClientPtr rfbClientHead
-which points to the first client.
-
-So, to access the server from the client structure, you use client->screen.
-To access all clients from a server, get screen->rfbClientHead and
-iterate using client->next.
-
-If you change client settings, be sure to use the provided iterator
- rfbGetClientIterator(rfbScreen)
-with
- rfbClientIteratorNext(iterator)
-and
- rfbReleaseClientIterator
-to prevent thread clashes.
-
-Other options
--------------
-
-These options have to be set between rfbGetScreen and rfbInitServer.
-
-If you already have a socket to talk to, just set rfbScreen->inetdSock
-(originally this is for inetd handling, but why not use it for your purpose?).
-
-To also start an HTTP server (running on port 5800+display_number), you have
-to set rfbScreen->httpdDir to a directory containing vncviewer.jar and
-index.vnc (like the included "webclients" directory).
-
-Hooks and IO functions
-----------------------
-
-There exist the following IO functions as members of rfbScreen:
-kbdAddEvent, kbdReleaseAllKeys, ptrAddEvent and setXCutText
-
-kbdAddEvent(rfbBool down,rfbKeySym key,rfbClientPtr cl)
- is called when a key is pressed.
-kbdReleaseAllKeys(rfbClientPtr cl)
- is not called at all (maybe in the future).
-ptrAddEvent(int buttonMask,int x,int y,rfbClientPtr cl)
- is called when the mouse moves or a button is pressed.
- WARNING: if you want to have proper cursor handling, call
- rfbDefaultPtrAddEvent(buttonMask,x,y,cl)
- in your own function. This sets the coordinates of the cursor.
-setXCutText(char* str,int len,rfbClientPtr cl)
- is called when the selection changes.
-
-There are only two hooks:
-newClientHook(rfbClientPtr cl)
- is called when a new client has connected.
-displayHook
- is called just before a frame buffer update is sent.
-
-You can also override the following methods:
-getCursorPtr(rfbClientPtr cl)
- This could be used to make an animated cursor (if you really want ...)
-setTranslateFunction(rfbClientPtr cl)
- If you insist on colour maps or something more obscure, you have to
- implement this. Default is a trueColour mapping.
-
-Cursor handling
----------------
-
-The screen holds a pointer
- rfbCursorPtr cursor
-to the current cursor. Whenever you set it, remember that any dynamically
-created cursor (like return value from rfbMakeXCursor) is not free'd!
-
-The rfbCursor structure consists mainly of a mask and a source. The mask
-describes, which pixels are drawn for the cursor (a cursor needn't be
-rectangular). The source describes, which colour those pixels should have.
-
-The standard is an XCursor: a cursor with a foreground and a background
-colour (stored in backRed,backGreen,backBlue and the same for foreground
-in a range from 0-0xffff). Therefore, the arrays "mask" and "source"
-contain pixels as single bits stored in bytes in MSB order. The rows are
-padded, such that each row begins with a new byte (i.e. a 10x4
-cursor's mask has 2x4 bytes, because 2 bytes are needed to hold 10 bits).
-
-It is however very easy to make a cursor like this:
-
-char* cur=" "
- " xx "
- " x "
- " ";
-char* mask="xxxx"
- "xxxx"
- "xxxx"
- "xxx ";
-rfbCursorPtr c=rfbMakeXCursor(4,4,cur,mask);
-
-You can even set "mask" to NULL in this call and LibVNCServer will calculate
-a mask for you (dynamically, so you have to free it yourself).
-
-There is also an array named "richSource" for colourful cursors. They have
-the same format as the frameBuffer (i.e. if the server is 32 bit,
-a 10x4 cursor has 4x10x4 bytes).
-
-History
--------
-
-LibVNCServer is based on Tridia VNC and OSXvnc, which in turn are based on
-the original code from ORL/AT&T.
-
-When I began hacking with computers, my first interest was speed. So, when I
-got around assembler, I programmed the floppy to do much of the work, because
-its clock rate was higher than that of my C64. This was my first experience
-with client/server techniques.
-
-When I came around Xwindows (much later), I was at once intrigued by the
-elegance of such connectedness between the different computers. I used it
-a lot - not the least priority lay on games. However, when I tried it over
-modem from home, it was no longer that much fun.
-
-When I started working with ASP (Application Service Provider) programs, I
-tumbled across Tarantella and Citrix. Being a security fanatic, the idea of
-running a server on windows didn't appeal to me, so Citrix went down the
-basket. However, Tarantella has its own problems (security as well as the
-high price). But at the same time somebody told me about this "great little
-administrator's tool" named VNC. Being used to windows programs' sizes, the
-surprise was reciprocal inverse to the size of VNC!
-
-At the same time, the program "rdesktop" (a native Linux client for the
-Terminal Services of Windows servers) came to my attention. There where even
-works under way to make a protocol converter "rdp2vnc" out of this. However,
-my primary goal was a slow connection and rdp2vnc could only speak RRE
-encoding, which is not that funny with just 5kB/s. Tim Edmonds, the original
-author of rdp2vnc, suggested that I adapt it to Hextile Encoding, which is
-better. I first tried that, but had no success at all (crunchy pictures).
-
-Also, I liked the idea of an HTTP server included and possibly other
-encodings like the Tight Encodings from Const Kaplinsky. So I started looking
-for libraries implementing a VNC server where I could steal what I can't make.
-I found some programs based on the demo server from AT&T, which was also the
-basis for rdp2vnc (can only speak Raw and RRE encoding). There were some
-rumors that GGI has a VNC backend, but I didn't find any code, so probably
-there wasn't a working version anyway.
-
-All of a sudden, everything changed: I read on freshmeat that "OSXvnc" was
-released. I looked at the code and it was not much of a problem to work out
-a simple server - using every functionality there is in Xvnc. It became clear
-to me that I *had* to build a library out of it, so everybody can use it.
-Every change, every new feature can propagate to every user of it.
-
-It also makes everything easier:
- You don't care about the cursor, once set (or use the standard cursor).
-You don't care about those sockets. You don't care about encodings.
-You just change your frame buffer and inform the library about it. Every once
-in a while you call rfbProcessEvents and that's it.
-
-Basics
-------
-
-VNC (Virtual network computing) works like this: You set up a server and can
-connect to it via vncviewers. The communication uses a protocol named RFB
-(Remote Frame Buffer). If the server supports HTTP, you can also connect
-using a java enabled browser. In this case, the server sends back a
-vncviewer applet with the correct settings.
-
-There exist several encodings for VNC, which are used to compress the regions
-which have changed before they are sent to the client. A client need not be
-able to understand every encoding, but at least Raw encoding. Which encoding
-it understands is negotiated by the RFB protocol.
-
-The following encodings are known to me:
-Raw, RRE, CoRRE, Hextile, CopyRect from the original AT&T code and
-Tight, ZLib, LastRect, XCursor, RichCursor from Const Kaplinsky et al.
-
-If you are using a modem, you want to try the "new" encodings. Especially
-with my 56k modem I like ZLib or Tight with Quality 0. In my tests, it even
-beats Tarantella.
-
-There is the possibility to set a password, which is also negotiated by the
-RFB protocol, but IT IS NOT SECURE. Anybody sniffing your net can get the
-password. You really should tunnel through SSH.
-
-Windows or: why do you do that to me?
---------------------------------------------
-
-If you love products from Redmod, you better skip this paragraph.
-I am always amazed how people react whenever Microsoft(tm) puts in some
-features into their products which were around for a long time. Especially
-reporters seem to not know dick about what they are reporting about! But
-what is every time annoying again, is that they don't do it right. Every
-concept has its new name (remember what enumerators used to be until
-Mickeysoft(tm) claimed that enumerators are what we thought were iterators.
-Yeah right, enumerators are also containers. They are not separated. Muddy.)
-
-There are three packages you want to get hold of: zlib, jpeg and pthreads.
-The latter is not strictly necessary, but when you put something like this
-into your source:
-
-```
-#define MUTEX(s)
- struct {
- int something;
- MUTEX(latex);
- }
-```
-
-Microsoft's C++ compiler doesn't do it. It complains that this is an error.
-This, however, is how I implemented mutexes in case you don't need pthreads,
-and so don't need the mutex.
-
-You can find the packages at
-http://www.gimp.org/win32/extralibs-dev-20001007.zip
-
-Thanks go to all the GIMP team!
-
-What are those other targets in the Makefile?
----------------------------------------------
-
-OSXvnc-server is the original OSXvnc adapted to use the library, which was in
-turn adapted from OSXvnc. As you easily can see, the OSX dependend part is
-minimal.
-
-storepasswd is the original program to save a vnc style password in a file.
-Unfortunately, authentication as every vncviewer speaks it means the server
-has to know the plain password. You really should tunnel via ssh or use
-your own PasswordCheck to build a PIN/TAN system.
-
-sratest is a test unit. Run it to assert correct behaviour of sraRegion. I
-wrote this to test my iterator implementation.
-
-blooptest is a test of pthreads. It is just the example, but with a background
-loop to hunt down thread lockups.
-
-pnmshow24 is like pnmshow, but it uses 3 bytes/pixel internally, which is not
-as efficient as 4 bytes/pixel for translation, because there is no native data
-type of that size, so you have to memcpy pixels and be real cautious with
-endianness. Anyway, it works.
-
-fontsel is a test for rfbSelectBox and rfbLoadConsoleFont. If you have Linux
-console fonts, you can browse them via VNC. Directory browsing not implemented
-yet :-(
-
-Why I don't feel bad about GPL
-------------------------------
-
-At the beginning of this projects I would have liked to make it a BSD
-license. However, it is based on plenty of GPL'ed code, so it has to be
-a GPL. I hear BeeGee complaining: "but that's invasive, every derivative
-work, even just linking, makes my software GPL!"
-
-Yeah. That's right. It is because there are nasty jarheads out there who
-would take anybody's work and claim it their own, selling it for much too
-much money, stealing freedom and innovation from others, saying they were
-the maintainers of innovation, lying, making money with that.
-
-The people at AT&T worked really well to produce something as clean and lean
-as VNC. The managers decided that for their fame, they would release the
-program for free. But not only that! They realized that by releasing also
-the code for free, VNC would become an evolving little child, conquering
-new worlds, making its parents very proud. As well they can be! To protect
-this innovation, they decided to make it GPL, not BSD. The principal
-difference is: You can make closed source programs deriving from BSD, not
-from GPL. You have to give proper credit with both.
-
-Now, why not BSD? Well, imagine your child being some famous actor. Along
-comes a manager who exploits your child exclusively, that is: nobody else
-can profit from the child, it itself included. Got it?
-
-What reason do you have now to use this library commercially?
-
-Several: You don't have to give away your product. Then you have effectively
-circumvented the GPL, because you have the benefits of other's work and you
-don't give back anything and you will be in hell for that. In fact, this
-library, as my other projects, is a payback for all the free software I can
-use (and sometimes, make better). For example, just now, I am using XEmacs
-on top of XFree86, all running under Linux.
-
-Better: Use a concept like MySQL. This is free software, however, they make
-money with it. If you want something implemented, you have the choice:
-Ask them to do it (and pay a fair price), or do it yourself, normally giving
-back your enhancements to the free world of computing.
-
-Learn from it: If you like the style this is written, learn how to imitate
-it. If you don't like the style, learn how to avoid those things you don't
-like. I learnt so much, just from looking at code like Linux, XEmacs,
-LilyPond, STL, etc.
-
-License
--------
-
-This program is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License
-as published by the Free Software Foundation; either version 2
-of the License, or (at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.dfdf
-
-Contact
--------
-
-To contact me, mail me: Johannes dot Schindelin at gmx dot de
-
diff --git a/README.md b/README.md
index 100b938..a29c550 120000..100644
--- a/README.md
+++ b/README.md
@@ -1 +1,478 @@
-README \ No newline at end of file
+[![Build Status](https://travis-ci.org/LibVNC/libvncserver.svg?branch=master)](https://travis-ci.org/LibVNC/libvncserver)
+[![Build status](https://ci.appveyor.com/api/projects/status/fao6m1md3q4g2bwn/branch/master?svg=true)](https://ci.appveyor.com/project/bk138/libvncserver/branch/master)
+[![Help making this possible](https://liberapay.com/assets/widgets/donate.svg)](https://liberapay.com/LibVNC/donate)
+
+LibVNCServer: A library for easy implementation of a VNC server.
+Copyright (C) 2001-2003 Johannes E. Schindelin
+
+If you already used LibVNCServer, you probably want to read NEWS.
+
+What is it?
+===========
+
+VNC is a set of programs using the RFB (Remote Frame Buffer) protocol. They
+are designed to "export" a frame buffer via net (if you don't know VNC, I
+suggest you read "Basics" below). It is already in wide use for
+administration, but it is not that easy to program a server yourself.
+
+This has been changed by LibVNCServer.
+
+There are two examples included:
+ - example, a shared scribble sheet
+ - pnmshow, a program to show PNMs (pictures) over the net.
+
+The examples are not too well documented, but easy straight forward and a
+good starting point.
+
+Try example: it outputs on which port it listens (default: 5900), so it is
+display 0. To view, call
+ `vncviewer :0`
+You should see a sheet with a gradient and "Hello World!" written on it. Try
+to paint something. Note that every time you click, there is some bigger blot,
+whereas when you drag the mouse while clicked you draw a line. The size of the
+blot depends on the mouse button you click. Open a second vncviewer with
+the same parameters and watch it as you paint in the other window. This also
+works over internet. You just have to know either the name or the IP of your
+machine. Then it is
+ `vncviewer machine.where.example.runs.com:0`
+or similar for the remote client. Now you are ready to type something. Be sure
+that your mouse sits still, because every time the mouse moves, the cursor is
+reset to the position of the pointer! If you are done with that demo, press
+the down or up arrows. If your viewer supports it, then the dimensions of the
+sheet change. Just press Escape in the viewer. Note that the server still
+runs, even if you closed both windows. When you reconnect now, everything you
+painted and wrote is still there. You can press "Page Up" for a blank page.
+
+The demo pnmshow is much simpler: you either provide a filename as argument
+or pipe a file through stdin. Note that the file has to be a raw pnm/ppm file,
+i.e. a truecolour graphics. Only the Escape key is implemented. This may be
+the best starting point if you want to learn how to use LibVNCServer. You
+are confronted with the fact that the bytes per pixel can only be 8, 16 or 32.
+
+If you want to build a VNC client instead, please have a look at the [various
+client examples](./client_examples).
+
+Projects using it
+=================
+
+VNC for KDE
+http://www.tjansen.de/krfb
+
+GemsVNC
+http://www.elilabs.com/~rj/gemsvnc/
+
+VNC for Netware
+http://forge.novell.com/modules/xfmod/project/?vncnw
+
+RDesktop
+http://rdesktop.sourceforge.net
+
+VNCpp
+https://github.com/ocrespo/VNCpp
+
+VirtualBox
+https://www.virtualbox.org/
+
+Veyon
+https://veyon.io
+
+Mail me, if your application is missing!
+
+How to build
+============
+
+LibVNCServer uses CMake, so you can build via:
+
+ mkdir build
+ cd build
+ cmake ..
+ cmake --build .
+
+For some more comprehensive examples that include installation of dependencies, see
+the [Unix CI](.travis.yml) and [Windows CI](.appveyor.yml) build setups.
+
+Crosscompiling involves some more advanced command line switches but is easily possible
+as well.
+
+For instance, building for Android (see https://developer.android.com/ndk/guides/cmake.html as a reference):
+
+ mkdir build
+ cd build
+ cmake .. -DANDROID_NDK=<path> -DCMAKE_TOOLCHAIN_FILE=<path> -DANDROID_NATIVE_API_LEVEL=<API level you want> -DWITH_PNG=OFF # NDK not shipping png per default
+ cmake --build .
+
+
+How to use
+==========
+
+To make a server, you just have to initialise a server structure using the
+function rfbDefaultScreenInit, like
+ rfbScreenInfoPtr rfbScreen =
+ rfbGetScreen(argc,argv,width,height,8,3,bpp);
+where byte per pixel should be 1, 2 or 4. If performance doesn't matter,
+you may try bpp=3 (internally one cannot use native data types in this
+case; if you want to use this, look at pnmshow24).
+
+
+You then can set hooks and io functions (see below) or other
+options (see below).
+
+And you allocate the frame buffer like this:
+ rfbScreen->frameBuffer = (char*)malloc(width*height*bpp);
+
+After that, you initialize the server, like
+ rfbInitServer(rfbScreen);
+
+You can use a blocking event loop, a background (pthread based) event loop,
+or implement your own using the rfbProcessEvents function.
+
+Making it interactive
+---------------------
+
+Input is handled by IO functions (see below).
+
+Whenever you change something in the frame buffer, call rfbMarkRectAsModified.
+
+Utility functions
+-----------------
+
+Whenever you draw something, you have to call
+ rfbMarkRectAsModified(screen,x1,y1,x2,y2).
+This tells LibVNCServer to send updates to all connected clients.
+
+Before you draw something, be sure to call
+ rfbUndrawCursor(screen).
+This tells LibVNCServer to hide the cursor.
+Remark: There are vncviewers out there, which know a cursor encoding, so
+that network traffic is low, and also the cursor doesn't need to be
+drawn the cursor every time an update is sent. LibVNCServer handles
+all the details. Just set the cursor and don't bother any more.
+
+To set the mouse coordinates (or emulate mouse clicks), call
+ rfbDefaultPtrAddEvent(buttonMask,x,y,cl);
+IMPORTANT: do this at the end of your function, because this actually draws
+the cursor if no cursor encoding is active.
+
+What is the difference between rfbScreenInfoPtr and rfbClientPtr?
+-----------------------------------------------------------------
+
+The rfbScreenInfoPtr is a pointer to a rfbScreenInfo structure, which
+holds information about the server, like pixel format, io functions,
+frame buffer etc.
+
+The rfbClientPtr is a pointer to an rfbClientRec structure, which holds
+information about a client, like pixel format, socket of the
+connection, etc.
+
+A server can have several clients, but needn't have any. So, if you
+have a server and three clients are connected, you have one instance
+of a rfbScreenInfo and three instances of rfbClientRec's.
+
+The rfbClientRec structure holds a member
+ rfbScreenInfoPtr screen
+which points to the server and a member
+ rfbClientPtr next
+to the next client.
+
+The rfbScreenInfo structure holds a member
+ rfbClientPtr rfbClientHead
+which points to the first client.
+
+So, to access the server from the client structure, you use client->screen.
+To access all clients from a server, get screen->rfbClientHead and
+iterate using client->next.
+
+If you change client settings, be sure to use the provided iterator
+ rfbGetClientIterator(rfbScreen)
+with
+ rfbClientIteratorNext(iterator)
+and
+ rfbReleaseClientIterator
+to prevent thread clashes.
+
+Other options
+-------------
+
+These options have to be set between rfbGetScreen and rfbInitServer.
+
+If you already have a socket to talk to, just set rfbScreen->inetdSock
+(originally this is for inetd handling, but why not use it for your purpose?).
+
+To also start an HTTP server (running on port 5800+display_number), you have
+to set rfbScreen->httpdDir to a directory containing vncviewer.jar and
+index.vnc (like the included "webclients" directory).
+
+Hooks and IO functions
+----------------------
+
+There exist the following IO functions as members of rfbScreen:
+kbdAddEvent, kbdReleaseAllKeys, ptrAddEvent and setXCutText
+
+kbdAddEvent(rfbBool down,rfbKeySym key,rfbClientPtr cl)
+ is called when a key is pressed.
+kbdReleaseAllKeys(rfbClientPtr cl)
+ is not called at all (maybe in the future).
+ptrAddEvent(int buttonMask,int x,int y,rfbClientPtr cl)
+ is called when the mouse moves or a button is pressed.
+ WARNING: if you want to have proper cursor handling, call
+ rfbDefaultPtrAddEvent(buttonMask,x,y,cl)
+ in your own function. This sets the coordinates of the cursor.
+setXCutText(char* str,int len,rfbClientPtr cl)
+ is called when the selection changes.
+
+There are only two hooks:
+newClientHook(rfbClientPtr cl)
+ is called when a new client has connected.
+displayHook
+ is called just before a frame buffer update is sent.
+
+You can also override the following methods:
+getCursorPtr(rfbClientPtr cl)
+ This could be used to make an animated cursor (if you really want ...)
+setTranslateFunction(rfbClientPtr cl)
+ If you insist on colour maps or something more obscure, you have to
+ implement this. Default is a trueColour mapping.
+
+Cursor handling
+---------------
+
+The screen holds a pointer
+ rfbCursorPtr cursor
+to the current cursor. Whenever you set it, remember that any dynamically
+created cursor (like return value from rfbMakeXCursor) is not free'd!
+
+The rfbCursor structure consists mainly of a mask and a source. The mask
+describes, which pixels are drawn for the cursor (a cursor needn't be
+rectangular). The source describes, which colour those pixels should have.
+
+The standard is an XCursor: a cursor with a foreground and a background
+colour (stored in backRed,backGreen,backBlue and the same for foreground
+in a range from 0-0xffff). Therefore, the arrays "mask" and "source"
+contain pixels as single bits stored in bytes in MSB order. The rows are
+padded, such that each row begins with a new byte (i.e. a 10x4
+cursor's mask has 2x4 bytes, because 2 bytes are needed to hold 10 bits).
+
+It is however very easy to make a cursor like this:
+
+char* cur=" "
+ " xx "
+ " x "
+ " ";
+char* mask="xxxx"
+ "xxxx"
+ "xxxx"
+ "xxx ";
+rfbCursorPtr c=rfbMakeXCursor(4,4,cur,mask);
+
+You can even set "mask" to NULL in this call and LibVNCServer will calculate
+a mask for you (dynamically, so you have to free it yourself).
+
+There is also an array named "richSource" for colourful cursors. They have
+the same format as the frameBuffer (i.e. if the server is 32 bit,
+a 10x4 cursor has 4x10x4 bytes).
+
+History
+=======
+
+LibVNCServer is based on Tridia VNC and OSXvnc, which in turn are based on
+the original code from ORL/AT&T.
+
+When I began hacking with computers, my first interest was speed. So, when I
+got around assembler, I programmed the floppy to do much of the work, because
+its clock rate was higher than that of my C64. This was my first experience
+with client/server techniques.
+
+When I came around Xwindows (much later), I was at once intrigued by the
+elegance of such connectedness between the different computers. I used it
+a lot - not the least priority lay on games. However, when I tried it over
+modem from home, it was no longer that much fun.
+
+When I started working with ASP (Application Service Provider) programs, I
+tumbled across Tarantella and Citrix. Being a security fanatic, the idea of
+running a server on windows didn't appeal to me, so Citrix went down the
+basket. However, Tarantella has its own problems (security as well as the
+high price). But at the same time somebody told me about this "great little
+administrator's tool" named VNC. Being used to windows programs' sizes, the
+surprise was reciprocal inverse to the size of VNC!
+
+At the same time, the program "rdesktop" (a native Linux client for the
+Terminal Services of Windows servers) came to my attention. There where even
+works under way to make a protocol converter "rdp2vnc" out of this. However,
+my primary goal was a slow connection and rdp2vnc could only speak RRE
+encoding, which is not that funny with just 5kB/s. Tim Edmonds, the original
+author of rdp2vnc, suggested that I adapt it to Hextile Encoding, which is
+better. I first tried that, but had no success at all (crunchy pictures).
+
+Also, I liked the idea of an HTTP server included and possibly other
+encodings like the Tight Encodings from Const Kaplinsky. So I started looking
+for libraries implementing a VNC server where I could steal what I can't make.
+I found some programs based on the demo server from AT&T, which was also the
+basis for rdp2vnc (can only speak Raw and RRE encoding). There were some
+rumors that GGI has a VNC backend, but I didn't find any code, so probably
+there wasn't a working version anyway.
+
+All of a sudden, everything changed: I read on freshmeat that "OSXvnc" was
+released. I looked at the code and it was not much of a problem to work out
+a simple server - using every functionality there is in Xvnc. It became clear
+to me that I *had* to build a library out of it, so everybody can use it.
+Every change, every new feature can propagate to every user of it.
+
+It also makes everything easier:
+ You don't care about the cursor, once set (or use the standard cursor).
+You don't care about those sockets. You don't care about encodings.
+You just change your frame buffer and inform the library about it. Every once
+in a while you call rfbProcessEvents and that's it.
+
+Basics
+======
+
+VNC (Virtual network computing) works like this: You set up a server and can
+connect to it via vncviewers. The communication uses a protocol named RFB
+(Remote Frame Buffer). If the server supports HTTP, you can also connect
+using a java enabled browser. In this case, the server sends back a
+vncviewer applet with the correct settings.
+
+There exist several encodings for VNC, which are used to compress the regions
+which have changed before they are sent to the client. A client need not be
+able to understand every encoding, but at least Raw encoding. Which encoding
+it understands is negotiated by the RFB protocol.
+
+The following encodings are known to me:
+Raw, RRE, CoRRE, Hextile, CopyRect from the original AT&T code and
+Tight, ZLib, LastRect, XCursor, RichCursor from Const Kaplinsky et al.
+
+If you are using a modem, you want to try the "new" encodings. Especially
+with my 56k modem I like ZLib or Tight with Quality 0. In my tests, it even
+beats Tarantella.
+
+There is the possibility to set a password, which is also negotiated by the
+RFB protocol, but IT IS NOT SECURE. Anybody sniffing your net can get the
+password. You really should tunnel through SSH.
+
+Windows or: why do you do that to me?
+=====================================
+
+If you love products from Redmod, you better skip this paragraph.
+I am always amazed how people react whenever Microsoft(tm) puts in some
+features into their products which were around for a long time. Especially
+reporters seem to not know dick about what they are reporting about! But
+what is every time annoying again, is that they don't do it right. Every
+concept has its new name (remember what enumerators used to be until
+Mickeysoft(tm) claimed that enumerators are what we thought were iterators.
+Yeah right, enumerators are also containers. They are not separated. Muddy.)
+
+There are three packages you want to get hold of: zlib, jpeg and pthreads.
+The latter is not strictly necessary, but when you put something like this
+into your source:
+
+```
+#define MUTEX(s)
+ struct {
+ int something;
+ MUTEX(latex);
+ }
+```
+
+Microsoft's C++ compiler doesn't do it. It complains that this is an error.
+This, however, is how I implemented mutexes in case you don't need pthreads,
+and so don't need the mutex.
+
+You can find the packages at
+http://www.gimp.org/win32/extralibs-dev-20001007.zip
+
+Thanks go to all the GIMP team!
+
+What are those other targets in the Makefile?
+=============================================
+
+OSXvnc-server is the original OSXvnc adapted to use the library, which was in
+turn adapted from OSXvnc. As you easily can see, the OSX dependend part is
+minimal.
+
+storepasswd is the original program to save a vnc style password in a file.
+Unfortunately, authentication as every vncviewer speaks it means the server
+has to know the plain password. You really should tunnel via ssh or use
+your own PasswordCheck to build a PIN/TAN system.
+
+sratest is a test unit. Run it to assert correct behaviour of sraRegion. I
+wrote this to test my iterator implementation.
+
+blooptest is a test of pthreads. It is just the example, but with a background
+loop to hunt down thread lockups.
+
+pnmshow24 is like pnmshow, but it uses 3 bytes/pixel internally, which is not
+as efficient as 4 bytes/pixel for translation, because there is no native data
+type of that size, so you have to memcpy pixels and be real cautious with
+endianness. Anyway, it works.
+
+fontsel is a test for rfbSelectBox and rfbLoadConsoleFont. If you have Linux
+console fonts, you can browse them via VNC. Directory browsing not implemented
+yet :-(
+
+Why I don't feel bad about GPL
+==============================
+
+At the beginning of this projects I would have liked to make it a BSD
+license. However, it is based on plenty of GPL'ed code, so it has to be
+a GPL. I hear BeeGee complaining: "but that's invasive, every derivative
+work, even just linking, makes my software GPL!"
+
+Yeah. That's right. It is because there are nasty jarheads out there who
+would take anybody's work and claim it their own, selling it for much too
+much money, stealing freedom and innovation from others, saying they were
+the maintainers of innovation, lying, making money with that.
+
+The people at AT&T worked really well to produce something as clean and lean
+as VNC. The managers decided that for their fame, they would release the
+program for free. But not only that! They realized that by releasing also
+the code for free, VNC would become an evolving little child, conquering
+new worlds, making its parents very proud. As well they can be! To protect
+this innovation, they decided to make it GPL, not BSD. The principal
+difference is: You can make closed source programs deriving from BSD, not
+from GPL. You have to give proper credit with both.
+
+Now, why not BSD? Well, imagine your child being some famous actor. Along
+comes a manager who exploits your child exclusively, that is: nobody else
+can profit from the child, it itself included. Got it?
+
+What reason do you have now to use this library commercially?
+
+Several: You don't have to give away your product. Then you have effectively
+circumvented the GPL, because you have the benefits of other's work and you
+don't give back anything and you will be in hell for that. In fact, this
+library, as my other projects, is a payback for all the free software I can
+use (and sometimes, make better). For example, just now, I am using XEmacs
+on top of XFree86, all running under Linux.
+
+Better: Use a concept like MySQL. This is free software, however, they make
+money with it. If you want something implemented, you have the choice:
+Ask them to do it (and pay a fair price), or do it yourself, normally giving
+back your enhancements to the free world of computing.
+
+Learn from it: If you like the style this is written, learn how to imitate
+it. If you don't like the style, learn how to avoid those things you don't
+like. I learnt so much, just from looking at code like Linux, XEmacs,
+LilyPond, STL, etc.
+
+License
+-------
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.dfdf
+
+Contact
+=======
+
+To contact me, mail me: Johannes dot Schindelin at gmx dot de
+
diff --git a/TODO b/TODO
index 3139f35..285d9ce 100644
--- a/TODO
+++ b/TODO
@@ -1,8 +1,18 @@
-immediate:
+high-prio:
----------
- Add sources for the java stuff.
- Implement encryption in libvncserver.
-- Add a libvncclient-config script.
+- Get rid of compat dir
+- Fix encodingstest
+
+
+maybe-later:
+------------
+
+selectbox: scroll bars
+authentification schemes (secure vnc)
+ IO function ptr exists; now explain how to tunnel and implement a
+ client address restriction scheme.
make SDLvncviewer more versatile
- test for missing keys (especially "[]{}" with ./examples/mac),
@@ -18,12 +28,3 @@ make corre work again (libvncclient or libvncserver?)
teach SDLvncviewer about CopyRect...
implement "-record" in libvncclient
implement QoS for Windows in libvncclient
-
-later:
-------
-
-selectbox: scroll bars
-authentification schemes (secure vnc)
- IO function ptr exists; now explain how to tunnel and implement a
- client address restriction scheme.
-VisualNaCro testing
diff --git a/autogen.sh b/autogen.sh
deleted file mode 100755
index 2437158..0000000
--- a/autogen.sh
+++ /dev/null
@@ -1,4 +0,0 @@
-#!/bin/sh
-
-autoreconf -fiv &&
-./configure "$@"
diff --git a/client_examples/Makefile.am b/client_examples/Makefile.am
deleted file mode 100644
index 9cb2c32..0000000
--- a/client_examples/Makefile.am
+++ /dev/null
@@ -1,38 +0,0 @@
-AM_CPPFLAGS = -I$(top_srcdir)
-LDADD = ../libvncclient/libvncclient.la @WSOCKLIB@
-
-if WITH_FFMPEG
-FFMPEG_HOME=@with_ffmpeg@
-
-if HAVE_MP3LAME
-MP3LAME_LIB=-lmp3lame
-endif
-
-vnc2mpg_CFLAGS=-I$(FFMPEG_HOME)/libavformat -I$(FFMPEG_HOME)/libavcodec -I$(FFMPEG_HOME)/libavutil
-vnc2mpg_LDADD=$(LDADD) $(FFMPEG_HOME)/libavformat/libavformat.a $(FFMPEG_HOME)/libavcodec/libavcodec.a $(MP3LAME_LIB) -lm
-
-FFMPEG_CLIENT=vnc2mpg
-endif
-
-if HAVE_LIBSDL
-SDLVIEWER=SDLvncviewer
-
-SDLvncviewer_CFLAGS=$(SDL_CFLAGS)
-SDLvncviewer_SOURCES=SDLvncviewer.c scrap.c scrap.h
-
-# thanks to autoconf, this looks ugly
-SDLvncviewer_LDADD=$(LDADD) $(SDL_LIBS)
-endif
-
-if HAVE_LIBGTK
-GTKVIEWER=gtkvncviewer
-gtkvncviewer_SOURCES=gtkvncviewer.c
-gtkvncviewer_CFLAGS=$(GTK_CFLAGS)
-gtkvncviewer_LDADD=$(LDADD) $(GTK_LIBS)
-endif
-
-
-noinst_PROGRAMS=ppmtest $(SDLVIEWER) $(GTKVIEWER) $(FFMPEG_CLIENT) backchannel
-
-
-
diff --git a/client_examples/SDLvncviewer.c b/client_examples/SDLvncviewer.c
index 8fe6f57..d17b74e 100644
--- a/client_examples/SDLvncviewer.c
+++ b/client_examples/SDLvncviewer.c
@@ -5,7 +5,6 @@
#include <SDL.h>
#include <signal.h>
#include <rfb/rfbclient.h>
-#include "scrap.h"
struct { int sdl; int rfb; } buttonMapping[]={
{1, rfbButton1Mask},
@@ -16,14 +15,22 @@ struct { int sdl; int rfb; } buttonMapping[]={
{0,0}
};
+struct { char mask; int bits_stored; } utf8Mapping[]= {
+ {0b00111111, 6},
+ {0b01111111, 7},
+ {0b00011111, 5},
+ {0b00001111, 4},
+ {0b00000111, 3},
+ {0,0}
+};
+
static int enableResizable = 1, viewOnly, listenLoop, buttonMask;
-#ifdef SDL_ASYNCBLIT
- int sdlFlags = SDL_HWSURFACE | SDL_ASYNCBLIT | SDL_HWACCEL;
-#else
- int sdlFlags = SDL_HWSURFACE | SDL_HWACCEL;
-#endif
-static int realWidth, realHeight, bytesPerPixel, rowStride;
-static char *sdlPixels;
+int sdlFlags;
+SDL_Texture *sdlTexture;
+SDL_Renderer *sdlRenderer;
+SDL_Window *sdlWindow;
+/* client's pointer position */
+int x,y;
static int rightAltKeyDown, leftAltKeyDown;
@@ -32,53 +39,72 @@ static rfbBool resize(rfbClient* client) {
depth=client->format.bitsPerPixel;
if (enableResizable)
- sdlFlags |= SDL_RESIZABLE;
+ sdlFlags |= SDL_WINDOW_RESIZABLE;
client->updateRect.x = client->updateRect.y = 0;
client->updateRect.w = width; client->updateRect.h = height;
- rfbBool okay=SDL_VideoModeOK(width,height,depth,sdlFlags);
- if(!okay)
- for(depth=24;!okay && depth>4;depth/=2)
- okay=SDL_VideoModeOK(width,height,depth,sdlFlags);
- if(okay) {
- SDL_Surface* sdl=SDL_SetVideoMode(width,height,depth,sdlFlags);
- rfbClientSetClientData(client, SDL_Init, sdl);
- client->width = sdl->pitch / (depth / 8);
- if (sdlPixels) {
- free(client->frameBuffer);
- sdlPixels = NULL;
- }
- client->frameBuffer=sdl->pixels;
-
- client->format.bitsPerPixel=depth;
- client->format.redShift=sdl->format->Rshift;
- client->format.greenShift=sdl->format->Gshift;
- client->format.blueShift=sdl->format->Bshift;
- client->format.redMax=sdl->format->Rmask>>client->format.redShift;
- client->format.greenMax=sdl->format->Gmask>>client->format.greenShift;
- client->format.blueMax=sdl->format->Bmask>>client->format.blueShift;
- SetFormatAndEncodings(client);
+ /* (re)create the surface used as the client's framebuffer */
+ SDL_FreeSurface(rfbClientGetClientData(client, SDL_Init));
+ SDL_Surface* sdl=SDL_CreateRGBSurface(0,
+ width,
+ height,
+ depth,
+ 0,0,0,0);
+ if(!sdl)
+ rfbClientErr("resize: error creating surface: %s\n", SDL_GetError());
+
+ rfbClientSetClientData(client, SDL_Init, sdl);
+ client->width = sdl->pitch / (depth / 8);
+ client->frameBuffer=sdl->pixels;
+
+ client->format.bitsPerPixel=depth;
+ client->format.redShift=sdl->format->Rshift;
+ client->format.greenShift=sdl->format->Gshift;
+ client->format.blueShift=sdl->format->Bshift;
+ client->format.redMax=sdl->format->Rmask>>client->format.redShift;
+ client->format.greenMax=sdl->format->Gmask>>client->format.greenShift;
+ client->format.blueMax=sdl->format->Bmask>>client->format.blueShift;
+ SetFormatAndEncodings(client);
+
+ /* create or resize the window */
+ if(!sdlWindow) {
+ sdlWindow = SDL_CreateWindow(client->desktopName,
+ SDL_WINDOWPOS_UNDEFINED,
+ SDL_WINDOWPOS_UNDEFINED,
+ width,
+ height,
+ sdlFlags);
+ if(!sdlWindow)
+ rfbClientErr("resize: error creating window: %s\n", SDL_GetError());
} else {
- SDL_Surface* sdl=rfbClientGetClientData(client, SDL_Init);
- rfbClientLog("Could not set resolution %dx%d!\n",
- client->width,client->height);
- if(sdl) {
- client->width=sdl->pitch / (depth / 8);
- client->height=sdl->h;
- } else {
- client->width=0;
- client->height=0;
- }
- return FALSE;
+ SDL_SetWindowSize(sdlWindow, width, height);
+ }
+
+ /* create the renderer if it does not already exist */
+ if(!sdlRenderer) {
+ sdlRenderer = SDL_CreateRenderer(sdlWindow, -1, 0);
+ if(!sdlRenderer)
+ rfbClientErr("resize: error creating renderer: %s\n", SDL_GetError());
+ SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "linear"); /* make the scaled rendering look smoother. */
}
- SDL_WM_SetCaption(client->desktopName, "SDL");
+ SDL_RenderSetLogicalSize(sdlRenderer, width, height); /* this is a departure from the SDL1.2-based version, but more in the sense of a VNC viewer in keeeping aspect ratio */
+
+ /* (re)create the texture that sits in between the surface->pixels and the renderer */
+ if(sdlTexture)
+ SDL_DestroyTexture(sdlTexture);
+ sdlTexture = SDL_CreateTexture(sdlRenderer,
+ SDL_PIXELFORMAT_ARGB8888,
+ SDL_TEXTUREACCESS_STREAMING,
+ width, height);
+ if(!sdlTexture)
+ rfbClientErr("resize: error creating texture: %s\n", SDL_GetError());
return TRUE;
}
static rfbKeySym SDL_key2rfbKeySym(SDL_KeyboardEvent* e) {
rfbKeySym k = 0;
- SDLKey sym = e->keysym.sym;
+ SDL_Keycode sym = e->keysym.sym;
switch (sym) {
case SDLK_BACKSPACE: k = XK_BackSpace; break;
@@ -87,18 +113,17 @@ static rfbKeySym SDL_key2rfbKeySym(SDL_KeyboardEvent* e) {
case SDLK_RETURN: k = XK_Return; break;
case SDLK_PAUSE: k = XK_Pause; break;
case SDLK_ESCAPE: k = XK_Escape; break;
- case SDLK_SPACE: k = XK_space; break;
case SDLK_DELETE: k = XK_Delete; break;
- case SDLK_KP0: k = XK_KP_0; break;
- case SDLK_KP1: k = XK_KP_1; break;
- case SDLK_KP2: k = XK_KP_2; break;
- case SDLK_KP3: k = XK_KP_3; break;
- case SDLK_KP4: k = XK_KP_4; break;
- case SDLK_KP5: k = XK_KP_5; break;
- case SDLK_KP6: k = XK_KP_6; break;
- case SDLK_KP7: k = XK_KP_7; break;
- case SDLK_KP8: k = XK_KP_8; break;
- case SDLK_KP9: k = XK_KP_9; break;
+ case SDLK_KP_0: k = XK_KP_0; break;
+ case SDLK_KP_1: k = XK_KP_1; break;
+ case SDLK_KP_2: k = XK_KP_2; break;
+ case SDLK_KP_3: k = XK_KP_3; break;
+ case SDLK_KP_4: k = XK_KP_4; break;
+ case SDLK_KP_5: k = XK_KP_5; break;
+ case SDLK_KP_6: k = XK_KP_6; break;
+ case SDLK_KP_7: k = XK_KP_7; break;
+ case SDLK_KP_8: k = XK_KP_8; break;
+ case SDLK_KP_9: k = XK_KP_9; break;
case SDLK_KP_PERIOD: k = XK_KP_Decimal; break;
case SDLK_KP_DIVIDE: k = XK_KP_Divide; break;
case SDLK_KP_MULTIPLY: k = XK_KP_Multiply; break;
@@ -130,165 +155,58 @@ static rfbKeySym SDL_key2rfbKeySym(SDL_KeyboardEvent* e) {
case SDLK_F13: k = XK_F13; break;
case SDLK_F14: k = XK_F14; break;
case SDLK_F15: k = XK_F15; break;
- case SDLK_NUMLOCK: k = XK_Num_Lock; break;
+ case SDLK_NUMLOCKCLEAR: k = XK_Num_Lock; break;
case SDLK_CAPSLOCK: k = XK_Caps_Lock; break;
- case SDLK_SCROLLOCK: k = XK_Scroll_Lock; break;
+ case SDLK_SCROLLLOCK: k = XK_Scroll_Lock; break;
case SDLK_RSHIFT: k = XK_Shift_R; break;
case SDLK_LSHIFT: k = XK_Shift_L; break;
case SDLK_RCTRL: k = XK_Control_R; break;
case SDLK_LCTRL: k = XK_Control_L; break;
case SDLK_RALT: k = XK_Alt_R; break;
case SDLK_LALT: k = XK_Alt_L; break;
- case SDLK_RMETA: k = XK_Meta_R; break;
- case SDLK_LMETA: k = XK_Meta_L; break;
- case SDLK_LSUPER: k = XK_Super_L; break;
- case SDLK_RSUPER: k = XK_Super_R; break;
+ case SDLK_LGUI: k = XK_Super_L; break;
+ case SDLK_RGUI: k = XK_Super_R; break;
#if 0
case SDLK_COMPOSE: k = XK_Compose; break;
#endif
case SDLK_MODE: k = XK_Mode_switch; break;
case SDLK_HELP: k = XK_Help; break;
- case SDLK_PRINT: k = XK_Print; break;
+ case SDLK_PRINTSCREEN: k = XK_Print; break;
case SDLK_SYSREQ: k = XK_Sys_Req; break;
- case SDLK_BREAK: k = XK_Break; break;
default: break;
}
- /* both SDL and X11 keysyms match ASCII in the range 0x01-0x7f */
- if (k == 0 && sym > 0x0 && sym < 0x100) {
- k = sym;
- if (e->keysym.mod & (KMOD_LSHIFT | KMOD_RSHIFT)) {
- if (k >= '1' && k <= '9')
- k &= ~0x10;
- else if (k >= 'a' && k <= 'f')
- k &= ~0x20;
- }
- }
- if (k == 0) {
- if (e->keysym.unicode < 0x100)
- k = e->keysym.unicode;
- else
- rfbClientLog("Unknown keysym: %d\n", sym);
- }
+ /* SDL_TEXTINPUT does not generate characters if ctrl is down, so handle those here */
+ if (k == 0 && sym > 0x0 && sym < 0x100 && e->keysym.mod & KMOD_CTRL)
+ k = sym;
return k;
}
-static uint32_t get(rfbClient *cl, int x, int y)
-{
- switch (bytesPerPixel) {
- case 1: return ((uint8_t *)cl->frameBuffer)[x + y * cl->width];
- case 2: return ((uint16_t *)cl->frameBuffer)[x + y * cl->width];
- case 4: return ((uint32_t *)cl->frameBuffer)[x + y * cl->width];
- default:
- rfbClientErr("Unknown bytes/pixel: %d", bytesPerPixel);
- exit(1);
+/* UTF-8 decoding is from https://rosettacode.org/wiki/UTF-8_encode_and_decode which is under GFDL 1.2 */
+static rfbKeySym utf8char2rfbKeySym(const char chr[4]) {
+ int bytes = strlen(chr);
+ int shift = utf8Mapping[0].bits_stored * (bytes - 1);
+ rfbKeySym codep = (*chr++ & utf8Mapping[bytes].mask) << shift;
+ int i;
+ for(i = 1; i < bytes; ++i, ++chr) {
+ shift -= utf8Mapping[0].bits_stored;
+ codep |= ((char)*chr & utf8Mapping[0].mask) << shift;
}
-}
-
-static void put(int x, int y, uint32_t v)
-{
- switch (bytesPerPixel) {
- case 1: ((uint8_t *)sdlPixels)[x + y * rowStride] = v; break;
- case 2: ((uint16_t *)sdlPixels)[x + y * rowStride] = v; break;
- case 4: ((uint32_t *)sdlPixels)[x + y * rowStride] = v; break;
- default:
- rfbClientErr("Unknown bytes/pixel: %d", bytesPerPixel);
- exit(1);
- }
-}
-
-static void resizeRectangleToReal(rfbClient *cl, int x, int y, int w, int h)
-{
- int i0 = x * realWidth / cl->width;
- int i1 = ((x + w) * realWidth - 1) / cl->width + 1;
- int j0 = y * realHeight / cl->height;
- int j1 = ((y + h) * realHeight - 1) / cl->height + 1;
- int i, j;
-
- for (j = j0; j < j1; j++)
- for (i = i0; i < i1; i++) {
- int x0 = i * cl->width / realWidth;
- int x1 = ((i + 1) * cl->width - 1) / realWidth + 1;
- int y0 = j * cl->height / realHeight;
- int y1 = ((j + 1) * cl->height - 1) / realHeight + 1;
- uint32_t r = 0, g = 0, b = 0;
-
- for (y = y0; y < y1; y++)
- for (x = x0; x < x1; x++) {
- uint32_t v = get(cl, x, y);
-#define REDSHIFT cl->format.redShift
-#define REDMAX cl->format.redMax
-#define GREENSHIFT cl->format.greenShift
-#define GREENMAX cl->format.greenMax
-#define BLUESHIFT cl->format.blueShift
-#define BLUEMAX cl->format.blueMax
- r += (v >> REDSHIFT) & REDMAX;
- g += (v >> GREENSHIFT) & GREENMAX;
- b += (v >> BLUESHIFT) & BLUEMAX;
- }
- r /= (x1 - x0) * (y1 - y0);
- g /= (x1 - x0) * (y1 - y0);
- b /= (x1 - x0) * (y1 - y0);
-
- put(i, j, (r << REDSHIFT) | (g << GREENSHIFT) |
- (b << BLUESHIFT));
- }
+ return codep;
}
static void update(rfbClient* cl,int x,int y,int w,int h) {
- if (sdlPixels) {
- resizeRectangleToReal(cl, x, y, w, h);
- w = ((x + w) * realWidth - 1) / cl->width + 1;
- h = ((y + h) * realHeight - 1) / cl->height + 1;
- x = x * realWidth / cl->width;
- y = y * realHeight / cl->height;
- w -= x;
- h -= y;
- }
- SDL_UpdateRect(rfbClientGetClientData(cl, SDL_Init), x, y, w, h);
-}
-
-static void setRealDimension(rfbClient *client, int w, int h)
-{
- SDL_Surface* sdl;
-
- if (w < 0) {
- const SDL_VideoInfo *info = SDL_GetVideoInfo();
- w = info->current_h;
- h = info->current_w;
- }
-
- if (w == realWidth && h == realHeight)
- return;
-
- if (!sdlPixels) {
- int size;
-
- sdlPixels = (char *)client->frameBuffer;
- rowStride = client->width;
-
- bytesPerPixel = client->format.bitsPerPixel / 8;
- size = client->width * bytesPerPixel * client->height;
- client->frameBuffer = malloc(size);
- if (!client->frameBuffer) {
- rfbClientErr("Could not allocate %d bytes", size);
- exit(1);
- }
- memcpy(client->frameBuffer, sdlPixels, size);
- }
-
- sdl = rfbClientGetClientData(client, SDL_Init);
- if (sdl->w != w || sdl->h != h) {
- int depth = sdl->format->BitsPerPixel;
- sdl = SDL_SetVideoMode(w, h, depth, sdlFlags);
- rfbClientSetClientData(client, SDL_Init, sdl);
- sdlPixels = sdl->pixels;
- rowStride = sdl->pitch / (depth / 8);
- }
-
- realWidth = w;
- realHeight = h;
- update(client, 0, 0, client->width, client->height);
+ SDL_Surface *sdl = rfbClientGetClientData(cl, SDL_Init);
+ /* update texture from surface->pixels */
+ SDL_Rect r = {x,y,w,h};
+ if(SDL_UpdateTexture(sdlTexture, &r, sdl->pixels + y*sdl->pitch + x*4, sdl->pitch) < 0)
+ rfbClientErr("update: failed to update texture: %s\n", SDL_GetError());
+ /* copy texture to renderer and show */
+ if(SDL_RenderClear(sdlRenderer) < 0)
+ rfbClientErr("update: failed to clear renderer: %s\n", SDL_GetError());
+ if(SDL_RenderCopy(sdlRenderer, sdlTexture, NULL, NULL) < 0)
+ rfbClientErr("update: failed to copy texture to renderer: %s\n", SDL_GetError());
+ SDL_RenderPresent(sdlRenderer);
}
static void kbd_leds(rfbClient* cl, int value, int pad) {
@@ -374,17 +292,69 @@ static void cleanup(rfbClient* cl)
static rfbBool handleSDLEvent(rfbClient *cl, SDL_Event *e)
{
switch(e->type) {
-#if SDL_MAJOR_VERSION > 1 || SDL_MINOR_VERSION >= 2
- case SDL_VIDEOEXPOSE:
+ case SDL_WINDOWEVENT:
+ switch (e->window.event) {
+ case SDL_WINDOWEVENT_EXPOSED:
SendFramebufferUpdateRequest(cl, 0, 0,
cl->width, cl->height, FALSE);
break;
-#endif
+ case SDL_WINDOWEVENT_FOCUS_GAINED:
+ if (SDL_HasClipboardText()) {
+ char *text = SDL_GetClipboardText();
+ if(text) {
+ rfbClientLog("sending clipboard text '%s'\n", text);
+ SendClientCutText(cl, text, strlen(text));
+ }
+ }
+
+ break;
+ case SDL_WINDOWEVENT_FOCUS_LOST:
+ if (rightAltKeyDown) {
+ SendKeyEvent(cl, XK_Alt_R, FALSE);
+ rightAltKeyDown = FALSE;
+ rfbClientLog("released right Alt key\n");
+ }
+ if (leftAltKeyDown) {
+ SendKeyEvent(cl, XK_Alt_L, FALSE);
+ leftAltKeyDown = FALSE;
+ rfbClientLog("released left Alt key\n");
+ }
+ break;
+ }
+ break;
+ case SDL_MOUSEWHEEL:
+ {
+ int steps;
+ if (viewOnly)
+ break;
+
+ if(e->wheel.y > 0)
+ for(steps = 0; steps < e->wheel.y; ++steps) {
+ SendPointerEvent(cl, x, y, rfbButton4Mask);
+ SendPointerEvent(cl, x, y, 0);
+ }
+ if(e->wheel.y < 0)
+ for(steps = 0; steps > e->wheel.y; --steps) {
+ SendPointerEvent(cl, x, y, rfbButton5Mask);
+ SendPointerEvent(cl, x, y, 0);
+ }
+ if(e->wheel.x > 0)
+ for(steps = 0; steps < e->wheel.x; ++steps) {
+ SendPointerEvent(cl, x, y, 0b01000000);
+ SendPointerEvent(cl, x, y, 0);
+ }
+ if(e->wheel.x < 0)
+ for(steps = 0; steps > e->wheel.x; --steps) {
+ SendPointerEvent(cl, x, y, 0b00100000);
+ SendPointerEvent(cl, x, y, 0);
+ }
+ break;
+ }
case SDL_MOUSEBUTTONUP:
case SDL_MOUSEBUTTONDOWN:
case SDL_MOUSEMOTION:
{
- int x, y, state, i;
+ int state, i;
if (viewOnly)
break;
@@ -407,10 +377,6 @@ static rfbBool handleSDLEvent(rfbClient *cl, SDL_Event *e)
break;
}
}
- if (sdlPixels) {
- x = x * cl->width / realWidth;
- y = y * cl->height / realHeight;
- }
SendPointerEvent(cl, x, y, buttonMask);
buttonMask &= ~(rfbButton4Mask | rfbButton5Mask);
break;
@@ -426,6 +392,13 @@ static rfbBool handleSDLEvent(rfbClient *cl, SDL_Event *e)
if (e->key.keysym.sym == SDLK_LALT)
leftAltKeyDown = e->type == SDL_KEYDOWN;
break;
+ case SDL_TEXTINPUT:
+ if (viewOnly)
+ break;
+ rfbKeySym sym = utf8char2rfbKeySym(e->text.text);
+ SendKeyEvent(cl, sym, TRUE);
+ SendKeyEvent(cl, sym, FALSE);
+ break;
case SDL_QUIT:
if(listenLoop)
{
@@ -437,32 +410,6 @@ static rfbBool handleSDLEvent(rfbClient *cl, SDL_Event *e)
rfbClientCleanup(cl);
exit(0);
}
- case SDL_ACTIVEEVENT:
- if (!e->active.gain && rightAltKeyDown) {
- SendKeyEvent(cl, XK_Alt_R, FALSE);
- rightAltKeyDown = FALSE;
- rfbClientLog("released right Alt key\n");
- }
- if (!e->active.gain && leftAltKeyDown) {
- SendKeyEvent(cl, XK_Alt_L, FALSE);
- leftAltKeyDown = FALSE;
- rfbClientLog("released left Alt key\n");
- }
-
- if (e->active.gain && lost_scrap()) {
- static char *data = NULL;
- static int len = 0;
- get_scrap(T('T', 'E', 'X', 'T'), &len, &data);
- if (len)
- SendClientCutText(cl, data, len);
- }
- break;
- case SDL_SYSWMEVENT:
- clipboard_filter(e);
- break;
- case SDL_VIDEORESIZE:
- setRealDimension(cl, e->resize.w, e->resize.h);
- break;
default:
rfbClientLog("ignore SDL event: 0x%x\n", e->type);
}
@@ -471,7 +418,33 @@ static rfbBool handleSDLEvent(rfbClient *cl, SDL_Event *e)
static void got_selection(rfbClient *cl, const char *text, int len)
{
- put_scrap(T('T', 'E', 'X', 'T'), len, text);
+ rfbClientLog("received clipboard text '%s'\n", text);
+ if(SDL_SetClipboardText(text) != 0)
+ rfbClientErr("could not set received clipboard text: %s\n", SDL_GetError());
+}
+
+
+static rfbCredential* get_credential(rfbClient* cl, int credentialType){
+ rfbCredential *c = malloc(sizeof(rfbCredential));
+ c->userCredential.username = malloc(RFB_BUF_SIZE);
+ c->userCredential.password = malloc(RFB_BUF_SIZE);
+
+ if(credentialType != rfbCredentialTypeUser) {
+ rfbClientErr("something else than username and password required for authentication\n");
+ return NULL;
+ }
+
+ rfbClientLog("username and password required for authentication!\n");
+ printf("user: ");
+ fgets(c->userCredential.username, RFB_BUF_SIZE, stdin);
+ printf("pass: ");
+ fgets(c->userCredential.password, RFB_BUF_SIZE, stdin);
+
+ /* remove trailing newlines */
+ c->userCredential.username[strcspn(c->userCredential.username, "\n")] = 0;
+ c->userCredential.password[strcspn(c->userCredential.password, "\n")] = 0;
+
+ return c;
}
@@ -508,9 +481,6 @@ int main(int argc,char** argv) {
argc = j;
SDL_Init(SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE);
- SDL_EnableUNICODE(1);
- SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY,
- SDL_DEFAULT_REPEAT_INTERVAL);
atexit(SDL_Quit);
signal(SIGINT, exit);
@@ -523,6 +493,7 @@ int main(int argc,char** argv) {
cl->HandleKeyboardLedState=kbd_leds;
cl->HandleTextChat=text_chat;
cl->GotXCutText = got_selection;
+ cl->GetCredential = get_credential;
cl->listenPort = LISTEN_PORT_OFFSET;
cl->listen6Port = LISTEN_PORT_OFFSET;
if(!rfbInitClient(cl,&argc,argv))
@@ -532,8 +503,6 @@ int main(int argc,char** argv) {
break;
}
- init_scrap();
-
while(1) {
if(SDL_PollEvent(&e)) {
/*
diff --git a/client_examples/backchannel.c b/client_examples/backchannel.c
index 04d154e..a7db9a0 100644
--- a/client_examples/backchannel.c
+++ b/client_examples/backchannel.c
@@ -71,7 +71,9 @@ static rfbClientProtocolExtension backChannel = {
backChannelEncodings, /* encodings */
NULL, /* handleEncoding */
handleBackChannelMessage, /* handleMessage */
- NULL /* next extension */
+ NULL, /* next extension */
+ NULL, /* securityTypes */
+ NULL /* handleAuthentication */
};
int
diff --git a/client_examples/ppmtest.c b/client_examples/ppmtest.c
index b8602f0..99ee595 100644
--- a/client_examples/ppmtest.c
+++ b/client_examples/ppmtest.c
@@ -58,12 +58,27 @@ static void SaveFramebufferAsPPM(rfbClient* client, int x, int y, int w, int h)
fclose(f);
}
+char * getuser(rfbClient *client)
+{
+return strdup("testuser@test");
+}
+
+char * getpassword(rfbClient *client)
+{
+return strdup("Password");
+}
+
int
main(int argc, char **argv)
{
rfbClient* client = rfbGetClient(8,3,4);
time_t t=time(NULL);
+#ifdef LIBVNCSERVER_HAVE_SASL
+ client->GetUser = getuser;
+ client->GetPassword = getpassword;
+#endif
+
if(argc>1 && !strcmp("-print",argv[1])) {
client->GotFrameBufferUpdate = PrintRect;
argv[1]=argv[0]; argv++; argc--;
diff --git a/client_examples/scrap.c b/client_examples/scrap.c
deleted file mode 100644
index c28800c..0000000
--- a/client_examples/scrap.c
+++ /dev/null
@@ -1,558 +0,0 @@
-/* Handle clipboard text and data in arbitrary formats */
-
-#include <stdio.h>
-#include <limits.h>
-
-#ifdef WIN32
-#include <SDL.h>
-#include <SDL_syswm.h>
-#else
-#include <SDL/SDL.h>
-#include <SDL/SDL_syswm.h>
-#endif
-#include "scrap.h"
-#include "rfb/rfbconfig.h"
-
-/* Determine what type of clipboard we are using */
-#if defined(__unix__) && !defined(__QNXNTO__) && defined(LIBVNCSERVER_HAVE_X11)
-#define X11_SCRAP
-#elif defined(__WIN32__)
-#define WIN_SCRAP
-#elif defined(__QNXNTO__)
-#define QNX_SCRAP
-#else
-#warning Unknown window manager for clipboard handling
-#endif /* scrap type */
-
-/* System dependent data types */
-#if defined(X11_SCRAP)
-typedef Atom scrap_type;
-static Atom XA_TARGETS, XA_TEXT, XA_COMPOUND_TEXT, XA_UTF8_STRING;
-#elif defined(WIN_SCRAP)
-typedef UINT scrap_type;
-#elif defined(QNX_SCRAP)
-typedef uint32_t scrap_type;
-#define Ph_CL_TEXT T('T', 'E', 'X', 'T')
-#else
-typedef int scrap_type;
-#endif /* scrap type */
-
-/* System dependent variables */
-#if defined(X11_SCRAP)
-static Display *SDL_Display;
-static Window SDL_Window;
-static void (*Lock_Display)(void);
-static void (*Unlock_Display)(void);
-static Atom XA_UTF8_STRING;
-#elif defined(WIN_SCRAP)
-static HWND SDL_Window;
-#elif defined(QNX_SCRAP)
-static unsigned short InputGroup;
-#endif /* scrap type */
-
-#define FORMAT_PREFIX "SDL_scrap_0x"
-
-static scrap_type convert_format(int type)
-{
- switch (type) {
- case T('T', 'E', 'X', 'T'):
-#if defined(X11_SCRAP)
- return XA_UTF8_STRING ? XA_UTF8_STRING : XA_STRING;
-#elif defined(WIN_SCRAP)
- return CF_TEXT;
-#elif defined(QNX_SCRAP)
- return Ph_CL_TEXT;
-#endif /* scrap type */
- default:
- {
- char format[sizeof(FORMAT_PREFIX)+8+1];
-
- sprintf(format, "%s%08lx", FORMAT_PREFIX,
- (unsigned long)type);
-#if defined(X11_SCRAP)
- return XInternAtom(SDL_Display, format, False);
-#elif defined(WIN_SCRAP)
- return RegisterClipboardFormat(format);
-#endif /* scrap type */
- }
- }
-}
-
-/* Convert internal data to scrap format */
-static int convert_data(int type, char *dst, const char *src, int srclen)
-{
- int dstlen;
-
- dstlen = 0;
- switch (type) {
- case T('T', 'E', 'X', 'T'):
- if (dst) {
- while (--srclen >= 0) {
-#if defined(__unix__)
- if (*src == '\r') {
- *dst++ = '\n';
- ++dstlen;
- }
- else
-#elif defined(__WIN32__)
- if (*src == '\r') {
- *dst++ = '\r';
- ++dstlen;
- *dst++ = '\n';
- ++dstlen;
- }
- else
-#endif
- {
- *dst++ = *src;
- ++dstlen;
- }
- ++src;
- }
- *dst = '\0';
- ++dstlen;
- }
- else {
- while (--srclen >= 0) {
-#if defined(__unix__)
- if (*src == '\r')
- ++dstlen;
- else
-#elif defined(__WIN32__)
- if (*src == '\r') {
- ++dstlen;
- ++dstlen;
- }
- else
-#endif
- {
- ++dstlen;
- }
- ++src;
- }
- ++dstlen;
- }
- break;
- default:
- if (dst) {
- *(int *)dst = srclen;
- dst += sizeof(int);
- memcpy(dst, src, srclen);
- }
- dstlen = sizeof(int)+srclen;
- break;
- }
- return(dstlen);
-}
-
-/* Convert scrap data to internal format */
-static int convert_scrap(int type, char *dst, char *src, int srclen)
-{
- int dstlen;
-
- dstlen = 0;
- switch (type) {
- case T('T', 'E', 'X', 'T'):
- {
- if (srclen == 0)
- srclen = strlen(src);
- if (dst) {
- while (--srclen >= 0) {
-#if defined(__WIN32__)
- if (*src == '\r')
- /* drop extraneous '\r' */;
- else
-#endif
- if (*src == '\n') {
- *dst++ = '\r';
- ++dstlen;
- }
- else {
- *dst++ = *src;
- ++dstlen;
- }
- ++src;
- }
- *dst = '\0';
- ++dstlen;
- }
- else {
- while (--srclen >= 0) {
-#if defined(__WIN32__)
- /* drop extraneous '\r' */;
- if (*src != '\r')
-#endif
- ++dstlen;
- ++src;
- }
- ++dstlen;
- }
- break;
- }
- default:
- dstlen = *(int *)src;
- if (dst)
- memcpy(dst, src + sizeof(int),
- srclen ? srclen - sizeof(int) : dstlen);
- break;
- }
- return dstlen;
-}
-
-int init_scrap(void)
-{
- SDL_SysWMinfo info;
- int retval;
-
- /* Grab the window manager specific information */
- retval = -1;
- SDL_SetError("SDL is not running on known window manager");
-
- SDL_VERSION(&info.version);
- if (SDL_GetWMInfo(&info)) {
- /* Save the information for later use */
-#if defined(X11_SCRAP)
- if (info.subsystem == SDL_SYSWM_X11) {
- SDL_Display = info.info.x11.display;
- SDL_Window = info.info.x11.window;
- Lock_Display = info.info.x11.lock_func;
- Unlock_Display = info.info.x11.unlock_func;
-
- /* Enable the special window hook events */
- SDL_EventState(SDL_SYSWMEVENT, SDL_ENABLE);
- SDL_SetEventFilter(clipboard_filter);
-
- XA_TARGETS = XInternAtom(SDL_Display, "TARGETS", False);
- XA_TEXT = XInternAtom(SDL_Display, "TEXT", False);
- XA_COMPOUND_TEXT = XInternAtom(SDL_Display,
- "COMPOUND_TEXT", False);
- XA_UTF8_STRING = XInternAtom(SDL_Display,
- "UTF8_STRING", False);
-
- retval = 0;
- }
- else
- SDL_SetError("SDL is not running on X11");
-#elif defined(WIN_SCRAP)
- SDL_Window = info.window;
- retval = 0;
-#elif defined(QNX_SCRAP)
- InputGroup = PhInputGroup(NULL);
- retval = 0;
-#endif /* scrap type */
- }
- return(retval);
-}
-
-int lost_scrap(void)
-{
- int retval;
-
-#if defined(X11_SCRAP)
- if (Lock_Display)
- Lock_Display();
- retval = (XGetSelectionOwner(SDL_Display, XA_PRIMARY) != SDL_Window);
- if (Unlock_Display)
- Unlock_Display();
-#elif defined(WIN_SCRAP)
- retval = (GetClipboardOwner() != SDL_Window);
-#elif defined(QNX_SCRAP)
- retval = (PhInputGroup(NULL) != InputGroup);
-#endif /* scrap type */
-
- return(retval);
-}
-
-void put_scrap(int type, int srclen, const char *src)
-{
- scrap_type format;
- int dstlen;
- char *dst;
-
- format = convert_format(type);
- dstlen = convert_data(type, NULL, src, srclen);
-
-#if defined(X11_SCRAP)
- dst = (char *)malloc(dstlen);
- if (dst != NULL) {
- if (Lock_Display)
- Lock_Display();
- convert_data(type, dst, src, srclen);
- XChangeProperty(SDL_Display, DefaultRootWindow(SDL_Display),
- XA_CUT_BUFFER0, format, 8, PropModeReplace,
- (unsigned char *)dst, dstlen);
- free(dst);
- if (lost_scrap())
- XSetSelectionOwner(SDL_Display, XA_PRIMARY,
- SDL_Window, CurrentTime);
- if (Unlock_Display)
- Unlock_Display();
- }
-#elif defined(WIN_SCRAP)
- if (OpenClipboard(SDL_Window)) {
- HANDLE hMem;
-
- hMem = GlobalAlloc((GMEM_MOVEABLE|GMEM_DDESHARE), dstlen);
- if (hMem != NULL) {
- dst = (char *)GlobalLock(hMem);
- convert_data(type, dst, src, srclen);
- GlobalUnlock(hMem);
- EmptyClipboard();
- SetClipboardData(format, hMem);
- }
- CloseClipboard();
- }
-#elif defined(QNX_SCRAP)
-#if (_NTO_VERSION < 620) /* before 6.2.0 releases */
-#define PhClipboardHdr PhClipHeader
-#endif
- {
- PhClipboardHdr clheader = { Ph_CLIPBOARD_TYPE_TEXT, 0, NULL };
- int* cldata;
- int status;
-
- dst = (char *)malloc(dstlen+4);
- if (dst != NULL) {
- cldata = (int*)dst;
- *cldata = type;
- convert_data(type, dst+4, src, srclen);
- clheader.data = dst;
-#if (_NTO_VERSION < 620) /* before 6.2.0 releases */
- if (dstlen > 65535)
- /* maximum photon clipboard size :(*/
- clheader.length = 65535;
- else
-#endif
- clheader.length = dstlen+4;
- status = PhClipboardCopy(InputGroup, 1, &clheader);
- if (status == -1)
- fprintf(stderr,
- "Photon: copy to clipboard failed!\n");
- free(dst);
- }
- }
-#endif /* scrap type */
-}
-
-void get_scrap(int type, int *dstlen, char **dst)
-{
- scrap_type format;
-
- *dstlen = 0;
- format = convert_format(type);
-
-#if defined(X11_SCRAP)
- {
- Window owner;
- Atom selection;
- Atom seln_type;
- int seln_format;
- unsigned long nbytes;
- unsigned long overflow;
- char *src;
-
- if (Lock_Display)
- Lock_Display();
- owner = XGetSelectionOwner(SDL_Display, XA_PRIMARY);
- if (Unlock_Display)
- Unlock_Display();
- if ((owner == None) || (owner == SDL_Window)) {
- owner = DefaultRootWindow(SDL_Display);
- selection = XA_CUT_BUFFER0;
- }
- else {
- int selection_response = 0;
- SDL_Event event;
-
- owner = SDL_Window;
- if (Lock_Display)
- Lock_Display();
- selection = XInternAtom(SDL_Display, "SDL_SELECTION",
- False);
- XConvertSelection(SDL_Display, XA_PRIMARY, format,
- selection, owner, CurrentTime);
- if (Unlock_Display)
- Unlock_Display();
- while (!selection_response) {
- SDL_WaitEvent(&event);
- if (event.type == SDL_SYSWMEVENT) {
- XEvent xevent =
- event.syswm.msg->event.xevent;
-
- if ((xevent.type == SelectionNotify) &&
- (xevent.xselection.requestor
- == owner))
- selection_response = 1;
- }
- }
- }
- if (Lock_Display)
- Lock_Display();
- if (XGetWindowProperty(SDL_Display, owner, selection,
- 0, INT_MAX/4, False, format, &seln_type,
- &seln_format, &nbytes, &overflow,
- (unsigned char **)&src) == Success) {
- if (seln_type == format) {
- *dstlen = convert_scrap(type, NULL,
- src, nbytes);
- *dst = (char *)realloc(*dst, *dstlen);
- if (*dst == NULL)
- *dstlen = 0;
- else
- convert_scrap(type, *dst, src, nbytes);
- }
- XFree(src);
- }
- }
- if (Unlock_Display)
- Unlock_Display();
-#elif defined(WIN_SCRAP)
- if (IsClipboardFormatAvailable(format) && OpenClipboard(SDL_Window)) {
- HANDLE hMem;
- char *src;
-
- hMem = GetClipboardData(format);
- if (hMem != NULL) {
- src = (char *)GlobalLock(hMem);
- *dstlen = convert_scrap(type, NULL, src, 0);
- *dst = (char *)realloc(*dst, *dstlen);
- if (*dst == NULL)
- *dstlen = 0;
- else
- convert_scrap(type, *dst, src, 0);
- GlobalUnlock(hMem);
- }
- CloseClipboard();
- }
-#elif defined(QNX_SCRAP)
-#if (_NTO_VERSION < 620) /* before 6.2.0 releases */
- {
- void* clhandle;
- PhClipHeader* clheader;
- int* cldata;
-
- clhandle = PhClipboardPasteStart(InputGroup);
- if (clhandle != NULL) {
- clheader = PhClipboardPasteType(clhandle,
- Ph_CLIPBOARD_TYPE_TEXT);
- if (clheader != NULL) {
- cldata = clheader->data;
- if ((clheader->length>4) && (*cldata == type)) {
- *dstlen = convert_scrap(type, NULL,
- (char*)clheader->data+4,
- clheader->length-4);
- *dst = (char *)realloc(*dst, *dstlen);
- if (*dst == NULL)
- *dstlen = 0;
- else
- convert_scrap(type, *dst,
- (char*)clheader->data+4,
- clheader->length-4);
- }
- }
- PhClipboardPasteFinish(clhandle);
- }
- }
-#else /* 6.2.0 and 6.2.1 and future releases */
- {
- void* clhandle;
- PhClipboardHdr* clheader;
- int* cldata;
-
- clheader=PhClipboardRead(InputGroup, Ph_CLIPBOARD_TYPE_TEXT);
- if (clheader!=NULL) {
- cldata=clheader->data;
- if ((clheader->length>4) && (*cldata==type)) {
- *dstlen = convert_scrap(type, NULL,
- (char*)clheader->data+4,
- clheader->length-4);
- *dst = (char *)realloc(*dst, *dstlen);
- if (*dst == NULL)
- *dstlen = 0;
- else
- convert_scrap(type, *dst,
- (char*)clheader->data+4,
- clheader->length-4);
- }
- }
- }
-#endif
-#endif /* scrap type */
-}
-
-int clipboard_filter(const SDL_Event *event)
-{
-#if defined(X11_SCRAP)
- /* Post all non-window manager specific events */
- if (event->type != SDL_SYSWMEVENT)
- return(1);
-
- /* Handle window-manager specific clipboard events */
- switch (event->syswm.msg->event.xevent.type) {
- /* Copy the selection from XA_CUT_BUFFER0 to the requested property */
- case SelectionRequest: {
- XSelectionRequestEvent *req;
- XEvent sevent;
- int seln_format;
- unsigned long nbytes;
- unsigned long overflow;
- unsigned char *seln_data;
-
- req = &event->syswm.msg->event.xevent.xselectionrequest;
- if (req->target == XA_TARGETS) {
- Atom supported[] = {
- XA_TEXT, XA_COMPOUND_TEXT, XA_UTF8_STRING,
- XA_TARGETS, XA_STRING
- };
- XEvent response;
-
- XChangeProperty(SDL_Display, req->requestor,
- req->property, req->target, 32, PropModeReplace,
- (unsigned char*)supported,
- sizeof(supported) / sizeof(supported[0]));
- response.xselection.property=None;
- response.xselection.type= SelectionNotify;
- response.xselection.display= req->display;
- response.xselection.requestor= req->requestor;
- response.xselection.selection=req->selection;
- response.xselection.target= req->target;
- response.xselection.time = req->time;
- XSendEvent (SDL_Display, req->requestor,0,0,&response);
- XFlush (SDL_Display);
- return 1;
- }
-
- sevent.xselection.type = SelectionNotify;
- sevent.xselection.display = req->display;
- sevent.xselection.selection = req->selection;
- sevent.xselection.target = None;
- sevent.xselection.property = req->property;
- sevent.xselection.requestor = req->requestor;
- sevent.xselection.time = req->time;
- if (XGetWindowProperty(SDL_Display,
- DefaultRootWindow(SDL_Display), XA_CUT_BUFFER0,
- 0, INT_MAX/4, False, req->target,
- &sevent.xselection.target, &seln_format,
- &nbytes, &overflow, &seln_data) == Success) {
- if (sevent.xselection.target == req->target) {
- if (sevent.xselection.target == XA_STRING &&
- nbytes > 0 &&
- seln_data[nbytes-1] == '\0')
- --nbytes;
- XChangeProperty(SDL_Display, req->requestor,
- req->property, sevent.xselection.target,
- seln_format, PropModeReplace,
- seln_data, nbytes);
- sevent.xselection.property = req->property;
- }
- XFree(seln_data);
- }
- XSendEvent(SDL_Display,req->requestor,False,0,&sevent);
- XSync(SDL_Display, False);
- break;
- }
- }
- /* Post the event for X11 clipboard reading above */
-#endif /* X11_SCRAP */
- return(1);
-}
diff --git a/client_examples/scrap.h b/client_examples/scrap.h
deleted file mode 100644
index 647bd74..0000000
--- a/client_examples/scrap.h
+++ /dev/null
@@ -1,18 +0,0 @@
-/* Handle clipboard text and data in arbitrary formats */
-
-/* Miscellaneous defines */
-#define T(A, B, C, D) (int)((A<<24)|(B<<16)|(C<<8)|(D<<0))
-
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-
-extern int init_scrap(void);
-extern int lost_scrap(void);
-extern void put_scrap(int type, int srclen, const char *src);
-extern void get_scrap(int type, int *dstlen, char **dst);
-extern int clipboard_filter(const SDL_Event *event);
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
diff --git a/client_examples/vnc2mpg.c b/client_examples/vnc2mpg.c
index af4a73a..a7438af 100644
--- a/client_examples/vnc2mpg.c
+++ b/client_examples/vnc2mpg.c
@@ -3,6 +3,7 @@
* Simple movie writer for vnc; based on Libavformat API example from FFMPEG
*
* Copyright (c) 2003 Fabrice Bellard, 2004 Johannes E. Schindelin
+ * Updates copyright (c) 2017 Tyrel M. McQueen
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -25,412 +26,451 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
-#include <signal.h>
#include <math.h>
-
-#ifndef M_PI
-#define M_PI 3.1415926535897931
-#endif
-
-#include "avformat.h"
+#include <signal.h>
+#include <sys/time.h>
+#include <libavformat/avformat.h>
+#include <libswscale/swscale.h>
#include <rfb/rfbclient.h>
-#define STREAM_FRAME_RATE 25 /* 25 images/s */
+#define VNC_PIX_FMT AV_PIX_FMT_RGB565 /* pixel format generated by VNC client */
+#define OUTPUT_PIX_FMT AV_PIX_FMT_YUV420P /* default pix_fmt */
-/**************************************************************/
-/* video output */
+static int write_packet(AVFormatContext *oc, const AVRational *time_base, AVStream *st, AVPacket *pkt)
+{
+ /* rescale output packet timestamp values from codec to stream timebase */
+ av_packet_rescale_ts(pkt, *time_base, st->time_base);
+ pkt->stream_index = st->index;
+ /* Write the compressed frame to the media file. */
+ return av_interleaved_write_frame(oc, pkt);
+}
-AVFrame *picture, *tmp_picture;
-uint8_t *video_outbuf;
-int frame_count, video_outbuf_size;
+/*************************************************/
+/* video functions */
-/* add a video output stream */
-AVStream *add_video_stream(AVFormatContext *oc, int codec_id, int w, int h)
-{
- AVCodecContext *c;
+/* a wrapper around a single output video stream */
+typedef struct {
AVStream *st;
+ AVCodec *codec;
+ AVCodecContext *enc;
+ int64_t pts;
+ AVFrame *frame;
+ AVFrame *tmp_frame;
+ struct SwsContext *sws;
+} VideoOutputStream;
+
+/* Add an output video stream. */
+int add_video_stream(VideoOutputStream *ost, AVFormatContext *oc,
+ enum AVCodecID codec_id, int64_t br, int sr, int w, int h)
+{
+ int i;
- st = av_new_stream(oc, 0);
- if (!st) {
- fprintf(stderr, "Could not alloc stream\n");
- exit(1);
- }
-
-#if LIBAVFORMAT_BUILD<4629
- c = &st->codec;
-#else
- c = st->codec;
-#endif
- c->codec_id = codec_id;
- c->codec_type = CODEC_TYPE_VIDEO;
-
- /* put sample parameters */
- c->bit_rate = 800000;
- /* resolution must be a multiple of two */
- c->width = w;
- c->height = h;
- /* frames per second */
-#if LIBAVCODEC_BUILD<4754
- c->frame_rate = STREAM_FRAME_RATE;
- c->frame_rate_base = 1;
-#else
- c->time_base.den = STREAM_FRAME_RATE;
- c->time_base.num = 1;
- c->pix_fmt = PIX_FMT_YUV420P;
-#endif
- c->gop_size = 12; /* emit one intra frame every twelve frames at most */
- if (c->codec_id == CODEC_ID_MPEG2VIDEO) {
- /* just for testing, we also add B frames */
- c->max_b_frames = 2;
+ /* find the encoder */
+ ost->codec = avcodec_find_encoder(codec_id);
+ if (!(ost->codec)) {
+ fprintf(stderr, "Could not find encoder for '%s'\n",
+ avcodec_get_name(codec_id));
+ return -1;
+ } // no extra memory allocation from this call
+ if (ost->codec->type != AVMEDIA_TYPE_VIDEO) {
+ fprintf(stderr, "Encoder for '%s' does not seem to be for video.\n",
+ avcodec_get_name(codec_id));
+ return -2;
}
- if (c->codec_id == CODEC_ID_MPEG1VIDEO){
- /* needed to avoid using macroblocks in which some coeffs overflow
- this doesn't happen with normal video, it just happens here as the
- motion of the chroma plane doesn't match the luma plane */
- c->mb_decision=2;
+ ost->enc = avcodec_alloc_context3(ost->codec);
+ if (!(ost->enc)) {
+ fprintf(stderr, "Could not alloc an encoding context\n");
+ return -3;
+ } // from now on need to call avcodec_free_context(&(ost->enc)) on error
+
+ /* Set codec parameters */
+ ost->enc->codec_id = codec_id;
+ ost->enc->bit_rate = br;
+ /* Resolution must be a multiple of two (round up to avoid buffer overflow). */
+ ost->enc->width = w + (w % 2);
+ ost->enc->height = h + (h % 2);
+ /* timebase: This is the fundamental unit of time (in seconds) in terms
+ * of which frame timestamps are represented. For fixed-fps content,
+ * timebase should be 1/framerate and timestamp increments should be
+ * identical to 1. */
+ ost->enc->time_base = (AVRational){ 1, sr };
+ ost->enc->gop_size = 12; /* emit one intra frame every twelve frames at most */
+ ost->enc->pix_fmt = OUTPUT_PIX_FMT;
+ if (ost->enc->codec_id == AV_CODEC_ID_MPEG1VIDEO) {
+ /* Needed to avoid using macroblocks in which some coeffs overflow.
+ * This does not happen with normal video, it just happens here as
+ * the motion of the chroma plane does not match the luma plane. */
+ ost->enc->mb_decision = 2;
}
- /* some formats want stream headers to be separate */
- if(!strcmp(oc->oformat->name, "mp4") || !strcmp(oc->oformat->name, "mov") || !strcmp(oc->oformat->name, "3gp"))
- c->flags |= CODEC_FLAG_GLOBAL_HEADER;
-
- return st;
+
+ ost->st = avformat_new_stream(oc, ost->codec);
+ if (!ost->st) {
+ fprintf(stderr, "Could not allocate stream\n");
+ avcodec_free_context(&(ost->enc));
+ return -4;
+ } // stream memory cleared up when oc is freed, so no need to do so later in this function on error
+ ost->st->id = oc->nb_streams-1;
+ ost->st->time_base = ost->enc->time_base;
+ ost->pts = 0;
+
+ /* Some formats want stream headers to be separate. */
+ if (oc->oformat->flags & AVFMT_GLOBALHEADER)
+ ost->enc->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;
+
+ // must wait to allocate frame buffers until codec is opened (in case codec changes the PIX_FMT)
+ return 0;
}
-AVFrame *alloc_picture(int pix_fmt, int width, int height)
+AVFrame *alloc_picture(enum AVPixelFormat pix_fmt, int width, int height)
{
AVFrame *picture;
- uint8_t *picture_buf;
- int size;
-
- picture = avcodec_alloc_frame();
+ int ret;
+ picture = av_frame_alloc();
if (!picture)
return NULL;
- size = avpicture_get_size(pix_fmt, width, height);
- picture_buf = malloc(size);
- if (!picture_buf) {
- av_free(picture);
+ // from now on need to call av_frame_free(&picture) on error
+ picture->format = pix_fmt;
+ picture->width = width;
+ picture->height = height;
+ /* allocate the buffers for the frame data */
+ ret = av_frame_get_buffer(picture, 64);
+ if (ret < 0) {
+ fprintf(stderr, "Could not allocate frame data.\n");
+ av_frame_free(&picture);
return NULL;
}
- avpicture_fill((AVPicture *)picture, picture_buf,
- pix_fmt, width, height);
return picture;
-}
-
-void open_video(AVFormatContext *oc, AVStream *st)
-{
- AVCodec *codec;
- AVCodecContext *c;
-
-#if LIBAVFORMAT_BUILD<4629
- c = &st->codec;
-#else
- c = st->codec;
-#endif
-
- /* find the video encoder */
- codec = avcodec_find_encoder(c->codec_id);
- if (!codec) {
- fprintf(stderr, "codec not found\n");
- exit(1);
- }
+} // use av_frame_free(&picture) to free memory from this call
+int open_video(AVFormatContext *oc, VideoOutputStream *ost)
+{
+ int ret;
/* open the codec */
- if (avcodec_open(c, codec) < 0) {
- fprintf(stderr, "could not open codec\n");
- exit(1);
+ ret = avcodec_open2(ost->enc, ost->codec, NULL);
+ if (ret < 0) {
+ fprintf(stderr, "Could not open video codec: %s\n", av_err2str(ret));
+ return ret;
+ } // memory from this call freed when oc is freed, no need to do it on error in this call
+ /* copy the stream parameters to the muxer */
+ ret = avcodec_parameters_from_context(ost->st->codecpar, ost->enc);
+ if (ret < 0) {
+ fprintf(stderr, "Could not copy the stream parameters.\n");
+ return ret;
+ } // memory from this call is freed when oc (parent of ost->st) is freed, no need to do it on error in this call
+ /* allocate and init a re-usable frame */
+ ost->frame = alloc_picture(ost->enc->pix_fmt, ost->enc->width, ost->enc->height);
+ if (!(ost->frame)) {
+ fprintf(stderr, "Could not allocate video frame\n");
+ return -1;
+ } // from now on need to call av_frame_free(&(ost->frame)) on error
+ /* If the output format is not the same as the VNC format, then a temporary VNC format
+ * picture is needed too. It is then converted to the required
+ * output format. */
+ ost->tmp_frame = NULL;
+ ost->sws = NULL;
+ if (ost->enc->pix_fmt != VNC_PIX_FMT) {
+ ost->tmp_frame = alloc_picture(VNC_PIX_FMT, ost->enc->width, ost->enc->height);
+ if (!(ost->tmp_frame)) {
+ fprintf(stderr, "Could not allocate temporary picture\n");
+ av_frame_free(&(ost->frame));
+ return -2;
+ } // from now on need to call av_frame_free(&(ost->tmp_frame)) on error
+ ost->sws = sws_getCachedContext(ost->sws, ost->enc->width, ost->enc->height, VNC_PIX_FMT, ost->enc->width, ost->enc->height, ost->enc->pix_fmt, 0, NULL, NULL, NULL);
+ if (!(ost->sws)) {
+ fprintf(stderr, "Could not get sws context\n");
+ av_frame_free(&(ost->frame));
+ av_frame_free(&(ost->tmp_frame));
+ return -3;
+ } // from now on need to call sws_freeContext(ost->sws); ost->sws = NULL; on error
}
- video_outbuf = NULL;
- if (!(oc->oformat->flags & AVFMT_RAWPICTURE)) {
- /* allocate output buffer */
- /* XXX: API change will be done */
- video_outbuf_size = 200000;
- video_outbuf = malloc(video_outbuf_size);
- }
+ return 0;
+}
- /* allocate the encoded raw picture */
- picture = alloc_picture(c->pix_fmt, c->width, c->height);
- if (!picture) {
- fprintf(stderr, "Could not allocate picture\n");
- exit(1);
+/*
+ * encode current video frame and send it to the muxer
+ * return 0 on success, negative on error
+ */
+int write_video_frame(AVFormatContext *oc, VideoOutputStream *ost, int64_t pts)
+{
+ int ret, ret2;
+ AVPacket pkt = { 0 };
+ if (pts <= ost->pts) return 0; // nothing to do
+ /* convert format if needed */
+ if (ost->tmp_frame) {
+ sws_scale(ost->sws, (const uint8_t * const *)ost->tmp_frame->data,
+ ost->tmp_frame->linesize, 0, ost->enc->height, ost->frame->data, ost->frame->linesize);
}
- /* if the output format is not RGB565, then a temporary RGB565
- picture is needed too. It is then converted to the required
- output format */
- tmp_picture = NULL;
- if (c->pix_fmt != PIX_FMT_RGB565) {
- tmp_picture = alloc_picture(PIX_FMT_RGB565, c->width, c->height);
- if (!tmp_picture) {
- fprintf(stderr, "Could not allocate temporary picture\n");
- exit(1);
+ /* send the imager to encoder */
+ ost->pts = pts;
+ ost->frame->pts = ost->pts;
+ ret = avcodec_send_frame(ost->enc, ost->frame);
+ if (ret < 0) {
+ fprintf(stderr, "Error sending video frame to encoder: %s\n", av_err2str(ret));
+ return ret;
+ }
+ /* read all available packets */
+ ret2 = 0;
+ for (ret = avcodec_receive_packet(ost->enc, &pkt); ret == 0; ret = avcodec_receive_packet(ost->enc, &pkt)) {
+ ret2 = write_packet(oc, &(ost->enc->time_base), ost->st, &pkt);
+ if (ret2 < 0) {
+ fprintf(stderr, "Error while writing video frame: %s\n", av_err2str(ret2));
+ /* continue on this error to not gum up encoder */
}
}
+ if (ret2 < 0) return ret2;
+ if (!(ret == AVERROR(EAGAIN))) return ret; // if AVERROR(EAGAIN), means all available packets output, need more frames (i.e. success)
+ return 0;
}
-void write_video_frame(AVFormatContext *oc, AVStream *st)
+/*
+ * Write final video frame (i.e. drain codec).
+ */
+int write_final_video_frame(AVFormatContext *oc, VideoOutputStream *ost)
{
- int out_size, ret;
- AVCodecContext *c;
- AVFrame *picture_ptr;
-
-#if LIBAVFORMAT_BUILD<4629
- c = &st->codec;
-#else
- c = st->codec;
-#endif
-
- if (c->pix_fmt != PIX_FMT_RGB565) {
- /* as we only generate a RGB565 picture, we must convert it
- to the codec pixel format if needed */
- img_convert((AVPicture *)picture, c->pix_fmt,
- (AVPicture *)tmp_picture, PIX_FMT_RGB565,
- c->width, c->height);
- }
- picture_ptr = picture;
-
-
- if (oc->oformat->flags & AVFMT_RAWPICTURE) {
- /* raw video case. The API will change slightly in the near
- futur for that */
- AVPacket pkt;
- av_init_packet(&pkt);
-
- pkt.flags |= PKT_FLAG_KEY;
- pkt.stream_index= st->index;
- pkt.data= (uint8_t *)picture_ptr;
- pkt.size= sizeof(AVPicture);
-
- ret = av_write_frame(oc, &pkt);
- } else {
- /* encode the image */
- out_size = avcodec_encode_video(c, video_outbuf, video_outbuf_size, picture_ptr);
- /* if zero size, it means the image was buffered */
- if (out_size != 0) {
- AVPacket pkt;
- av_init_packet(&pkt);
-
- pkt.pts= c->coded_frame->pts;
- if(c->coded_frame->key_frame)
- pkt.flags |= PKT_FLAG_KEY;
- pkt.stream_index= st->index;
- pkt.data= video_outbuf;
- pkt.size= out_size;
-
- /* write the compressed frame in the media file */
- ret = av_write_frame(oc, &pkt);
- } else {
- ret = 0;
- }
+ int ret, ret2;
+ AVPacket pkt = { 0 };
+
+ /* send NULL image to encoder */
+ ret = avcodec_send_frame(ost->enc, NULL);
+ if (ret < 0) {
+ fprintf(stderr, "Error sending final video frame to encoder: %s\n", av_err2str(ret));
+ return ret;
}
- if (ret != 0) {
- fprintf(stderr, "Error while writing video frame\n");
- exit(1);
+ /* read all available packets */
+ ret2 = 0;
+ for (ret = avcodec_receive_packet(ost->enc, &pkt); ret == 0; ret = avcodec_receive_packet(ost->enc, &pkt)) {
+ ret2 = write_packet(oc, &(ost->enc->time_base), ost->st, &pkt);
+ if (ret2 < 0) {
+ fprintf(stderr, "Error while writing final video frame: %s\n", av_err2str(ret2));
+ /* continue on this error to not gum up encoder */
+ }
}
- frame_count++;
+ if (ret2 < 0) return ret2;
+ if (!(ret == AVERROR(EOF))) return ret;
+ return 0;
}
-void close_video(AVFormatContext *oc, AVStream *st)
+void close_video_stream(VideoOutputStream *ost)
{
- avcodec_close(st->codec);
- av_free(picture->data[0]);
- av_free(picture);
- if (tmp_picture) {
- av_free(tmp_picture->data[0]);
- av_free(tmp_picture);
- }
- av_free(video_outbuf);
+ avcodec_free_context(&(ost->enc));
+ av_frame_free(&(ost->frame));
+ av_frame_free(&(ost->tmp_frame));
+ sws_freeContext(ost->sws); ost->sws = NULL;
+ ost->codec = NULL; /* codec not an allocated item */
+ ost->st = NULL; /* freeing parent oc will free this memory */
}
-static const char *filename;
-static AVOutputFormat *fmt;
-static AVFormatContext *oc;
-static AVStream *video_st;
-static double video_pts;
-
-static int movie_open(int w, int h) {
- if (fmt->video_codec != CODEC_ID_NONE) {
- video_st = add_video_stream(oc, fmt->video_codec, w, h);
- } else
- return 1;
-
- /* set the output parameters (must be done even if no
- parameters). */
- if (av_set_parameters(oc, NULL) < 0) {
- fprintf(stderr, "Invalid output format parameters\n");
- return 2;
+/**************************************************************/
+/* Output movie handling */
+AVFormatContext *movie_open(char *filename, VideoOutputStream *video_st, int br, int fr, int w, int h) {
+ int ret;
+ AVFormatContext *oc;
+
+ /* allocate the output media context. */
+ ret = avformat_alloc_output_context2(&oc, NULL, NULL, filename);
+ if (ret < 0) {
+ fprintf(stderr, "Warning: Could not deduce output format from file extension: using MP4.\n");
+ ret = avformat_alloc_output_context2(&oc, NULL, "mp4", filename);
}
+ if (ret < 0) {
+ fprintf(stderr, "Error: Could not allocate media context: %s.\n", av_err2str(ret));
+ return NULL;
+ } // from now on, need to call avformat_free_context(oc); oc=NULL; to free memory on error
- dump_format(oc, 0, filename, 1);
-
- /* now that all the parameters are set, we can open the audio and
- video codecs and allocate the necessary encode buffers */
- if (video_st)
- open_video(oc, video_st);
+ /* Add the video stream using the default format codec and initialize the codec. */
+ if (oc->oformat->video_codec != AV_CODEC_ID_NONE) {
+ ret = add_video_stream(video_st, oc, oc->oformat->video_codec, br, fr, w, h);
+ } else {
+ ret = -1;
+ }
+ if (ret < 0) {
+ fprintf(stderr, "Error: chosen output format does not have a video codec, or error %i\n", ret);
+ avformat_free_context(oc); oc = NULL;
+ return NULL;
+ } // from now on, need to call close_video_stream(video_st) to free memory on error
+
+ /* Now that all the parameters are set, we can open the codecs and allocate the necessary encode buffers. */
+ ret = open_video(oc, video_st);
+ if (ret < 0) {
+ fprintf(stderr, "Error: error opening video codec, error %i\n", ret);
+ close_video_stream(video_st);
+ avformat_free_context(oc); oc = NULL;
+ return NULL;
+ } // no additional calls required to free memory, as close_video_stream(video_st) will do it
/* open the output file, if needed */
- if (!(fmt->flags & AVFMT_NOFILE)) {
- if (url_fopen(&oc->pb, filename, URL_WRONLY) < 0) {
- fprintf(stderr, "Could not open '%s'\n", filename);
- return 3;
+ if (!(oc->oformat->flags & AVFMT_NOFILE)) {
+ ret = avio_open(&oc->pb, filename, AVIO_FLAG_WRITE);
+ if (ret < 0) {
+ fprintf(stderr, "Could not open '%s': %s\n", filename,
+ av_err2str(ret));
+ close_video_stream(video_st);
+ avformat_free_context(oc); oc = NULL;
+ return NULL;
}
- }
-
- /* write the stream header, if any */
- av_write_header(oc);
-
- return 0;
+ } // will need to call avio_closep(&oc->pb) to free file handle on error
+
+ /* Write the stream header, if any. */
+ ret = avformat_write_header(oc, NULL);
+ if (ret < 0) {
+ fprintf(stderr, "Error occurred when writing to output file: %s\n",
+ av_err2str(ret));
+ if (!(oc->oformat->flags & AVFMT_NOFILE))
+ avio_closep(&oc->pb);
+ close_video_stream(video_st);
+ avformat_free_context(oc); oc = NULL;
+ } // no additional items to free
+
+ return oc;
}
-static int movie_close() {
- int i;
+void movie_close(AVFormatContext **ocp, VideoOutputStream *video_st) {
+ AVFormatContext *oc = *ocp;
+ /* Write the trailer, if any. The trailer must be written before you
+ * close the CodecContexts open when you wrote the header; otherwise
+ * av_write_trailer() may try to use memory that was freed on
+ * av_codec_close(). */
+ if (oc) {
+ if (video_st)
+ write_final_video_frame(oc, video_st);
- /* close each codec */
- close_video(oc, video_st);
+ av_write_trailer(oc);
- /* write the trailer, if any */
- av_write_trailer(oc);
-
- /* free the streams */
- for(i = 0; i < oc->nb_streams; i++) {
- av_freep(&oc->streams[i]);
- }
+ /* Close the video codec. */
+ close_video_stream(video_st);
- if (!(fmt->flags & AVFMT_NOFILE)) {
- /* close the output file */
- url_fclose(&oc->pb);
- }
+ if (!(oc->oformat->flags & AVFMT_NOFILE))
+ /* Close the output file. */
+ avio_closep(&oc->pb);
- /* free the stream */
- av_free(oc);
+ /* free the stream */
+ avformat_free_context(oc);
+ ocp = NULL;
+ }
+}
+/**************************************************************/
+/* VNC globals */
+VideoOutputStream video_st = { 0 };
+rfbClient *client = NULL;
+rfbBool quit = FALSE;
+char *filename = NULL;
+AVFormatContext *oc = NULL;
+int bitrate = 1000000;
+int framerate = 5;
+long max_time = 0;
+struct timespec start_time, cur_time;
+
+/* Signal handling */
+void signal_handler(int signal) {
+ quit=TRUE;
}
-static rfbBool quit=FALSE;
-static void signal_handler(int signal) {
- fprintf(stderr,"Cleaning up.\n");
- quit=TRUE;
+/* returns time since start in pts units */
+int64_t time_to_pts(int framerate, struct timespec *start_time, struct timespec *cur_time) {
+ time_t ds = cur_time->tv_sec - start_time->tv_sec;
+ long dns = cur_time->tv_nsec - start_time->tv_nsec;
+ /* use usecs */
+ int64_t dt = (int64_t)ds*(int64_t)1000000+(int64_t)dns/(int64_t)1000;
+ /* compute rv in units of frame number (rounding to nearest, not truncating) */
+ int64_t rv = (((int64_t)framerate)*dt + (int64_t)500000) / (int64_t)(1000000);
+
+ return rv;
}
-/**************************************************************/
/* VNC callback functions */
-static rfbBool resize(rfbClient* client) {
- static rfbBool first=TRUE;
- if(!first) {
- movie_close();
- perror("I don't know yet how to change resolutions!\n");
- }
- movie_open(client->width, client->height);
- signal(SIGINT,signal_handler);
- if(tmp_picture)
- client->frameBuffer=tmp_picture->data[0];
- else
- client->frameBuffer=picture->data[0];
- return TRUE;
+rfbBool vnc_malloc_fb(rfbClient* client) {
+ movie_close(&oc, &video_st);
+ oc = movie_open(filename, &video_st, bitrate, framerate, client->width, client->height);
+ if (!oc)
+ return FALSE;
+ signal(SIGINT,signal_handler);
+ signal(SIGTERM,signal_handler);
+ signal(SIGQUIT,signal_handler);
+ signal(SIGABRT,signal_handler);
+ /* These assignments assumes the AVFrame buffer is contigous. This is true in current ffmpeg versions for
+ * most non-HW accelerated bits, but may not be true globally. */
+ if(video_st.tmp_frame)
+ client->frameBuffer=video_st.tmp_frame->data[0];
+ else
+ client->frameBuffer=video_st.frame->data[0];
+ return TRUE;
}
-static void update(rfbClient* client,int x,int y,int w,int h) {
+void vnc_update(rfbClient* client,int x,int y,int w,int h) {
}
/**************************************************************/
/* media file output */
-
int main(int argc, char **argv)
{
- time_t stop=0;
- rfbClient* client;
int i,j;
- /* get a vnc client structure (don't connect yet). */
+ /* Initialize vnc client structure (don't connect yet). */
client = rfbGetClient(5,3,2);
client->format.redShift=11; client->format.redMax=31;
client->format.greenShift=5; client->format.greenMax=63;
client->format.blueShift=0; client->format.blueMax=31;
- /* initialize libavcodec, and register all codecs and formats */
+ /* Initialize libavcodec, and register all codecs and formats. */
av_register_all();
-
- if(!strncmp(argv[argc-1],":",1) ||
- !strncmp(argv[argc-1],"127.0.0.1",9) ||
- !strncmp(argv[argc-1],"localhost",9))
- client->appData.encodingsString="raw";
- filename=0;
+ /* Parse command line. */
for(i=1;i<argc;i++) {
- j=i;
- if(argc>i+1 && !strcmp("-o",argv[i])) {
- filename=argv[2];
- j+=2;
- } else if(argc>i+1 && !strcmp("-t",argv[i])) {
- stop=time(0)+atoi(argv[i+1]);
- j+=2;
- }
- if(j>i) {
- argc-=j-i;
- memmove(argv+i,argv+j,(argc-i)*sizeof(char*));
- i--;
- }
+ j=i;
+ if(argc>i+1 && !strcmp("-o",argv[i])) {
+ filename=argv[i+1];
+ j+=2;
+ } else if(argc>i+1 && !strcmp("-t",argv[i])) {
+ max_time=atol(argv[i+1]);
+ if (max_time < 10 || max_time > 100000000) {
+ fprintf(stderr, "Warning: Nonsensical time-per-file %li, resetting to default.\n", max_time);
+ max_time = 0;
+ }
+ j+=2;
+ }
+ /* This is so that argc/argv are ready for passing to rfbInitClient */
+ if(j>i) {
+ argc-=j-i;
+ memmove(argv+i,argv+j,(argc-i)*sizeof(char*));
+ i--;
+ }
}
-
- /* auto detect the output format from the name. default is
- mpeg. */
- fmt = filename?guess_format(NULL, filename, NULL):0;
- if (!fmt) {
- printf("Could not deduce output format from file extension: using MPEG.\n");
- fmt = guess_format("mpeg", NULL, NULL);
- }
- if (!fmt) {
- fprintf(stderr, "Could not find suitable output format\n");
- exit(1);
+ /* default filename. */
+ if (!filename) {
+ fprintf(stderr, "Warning: No filename specified. Using output.mp4\n");
+ filename = "output.mp4";
}
-
- /* allocate the output media context */
- oc = av_alloc_format_context();
- if (!oc) {
- fprintf(stderr, "Memory error\n");
- exit(1);
- }
- oc->oformat = fmt;
- snprintf(oc->filename, sizeof(oc->filename), "%s", filename);
-
- /* add the audio and video streams using the default format codecs
- and initialize the codecs */
- video_st = NULL;
- /* open VNC connection */
- client->MallocFrameBuffer=resize;
- client->GotFrameBufferUpdate=update;
+ /* open VNC connection. */
+ client->MallocFrameBuffer=vnc_malloc_fb;
+ client->GotFrameBufferUpdate=vnc_update;
if(!rfbInitClient(client,&argc,argv)) {
- printf("usage: %s [-o output_file] [-t seconds] server:port\n"
- "Shoot a movie from a VNC server.\n", argv[0]);
- exit(1);
+ printf("usage: %s [-o output_file] [-t seconds-per-file] server:port\n", argv[0]);
+ return 1;
}
- if(client->serverPort==-1)
- client->vncRec->doNotSleep = TRUE; /* vncrec playback */
-
- /* main loop */
+ /* main loop */
+ clock_gettime(CLOCK_MONOTONIC, &start_time);
while(!quit) {
- int i=WaitForMessage(client,1000000/STREAM_FRAME_RATE);
- if(i<0) {
- movie_close();
- return 0;
+ int i=WaitForMessage(client,10000/framerate); /* useful for timeout to be no more than 10 msec per second (=10000/framerate usec) */
+ if (i>0) {
+ if(!HandleRFBServerMessage(client))
+ quit=TRUE;
+ } else if (i<0) {
+ quit=TRUE;
}
- if(i)
- if(!HandleRFBServerMessage(client))
- quit=TRUE;
- else {
- /* compute current audio and video time */
- video_pts = (double)video_st->pts.val * video_st->time_base.num / video_st->time_base.den;
-
- /* write interleaved audio and video frames */
- write_video_frame(oc, video_st);
- }
- if(stop!=0 && stop<time(0))
- quit=TRUE;
+ if (!quit) {
+ clock_gettime(CLOCK_MONOTONIC, &cur_time);
+ write_video_frame(oc, &video_st, time_to_pts(framerate, &start_time, &cur_time));
+ if ((cur_time.tv_sec - start_time.tv_sec) > max_time && max_time > 0) {
+ quit = TRUE;
+ }
+ }
}
-
- movie_close();
+ movie_close(&oc,&video_st);
return 0;
}
diff --git a/cmake/Modules/FindFFMPEG.cmake b/cmake/Modules/FindFFMPEG.cmake
new file mode 100644
index 0000000..6e61e3d
--- /dev/null
+++ b/cmake/Modules/FindFFMPEG.cmake
@@ -0,0 +1,227 @@
+#.rst:
+# FindFFMPEG
+# ----------
+#
+# Find the native FFMPEG includes and library
+#
+# This module defines::
+#
+# FFMPEG_INCLUDE_DIR, where to find avcodec.h, avformat.h ...
+# FFMPEG_LIBRARIES, the libraries to link against to use FFMPEG.
+# FFMPEG_FOUND, If false, do not try to use FFMPEG.
+#
+# also defined, but not for general use are::
+#
+# FFMPEG_avformat_LIBRARY, where to find the FFMPEG avformat library.
+# FFMPEG_avcodec_LIBRARY, where to find the FFMPEG avcodec library.
+#
+# This is useful to do it this way so that we can always add more libraries
+# if needed to ``FFMPEG_LIBRARIES`` if ffmpeg ever changes...
+
+#=============================================================================
+# Copyright: 1993-2008 Ken Martin, Will Schroeder, Bill Lorensen
+#
+# Distributed under the OSI-approved BSD License (the "License");
+# see accompanying file Copyright.txt for details.
+#
+# This software is distributed WITHOUT ANY WARRANTY; without even the
+# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+# See the License for more information.
+#=============================================================================
+# (To distribute this file outside of YCM, substitute the full
+# License text for the above reference.)
+
+# Originally from VTK project
+
+
+find_path(FFMPEG_INCLUDE_DIR1 avformat.h
+ $ENV{FFMPEG_DIR}
+ $ENV{FFMPEG_DIR}/ffmpeg
+ $ENV{FFMPEG_DIR}/libavformat
+ $ENV{FFMPEG_DIR}/include/libavformat
+ $ENV{FFMPEG_DIR}/include/ffmpeg
+ /usr/local/include/ffmpeg
+ /usr/include/ffmpeg
+ /usr/include/libavformat
+ /usr/include/ffmpeg/libavformat
+ /usr/include/${CMAKE_LIBRARY_ARCHITECTURE}/libavformat
+ /usr/local/include/libavformat
+)
+
+find_path(FFMPEG_INCLUDE_DIR2 avutil.h
+ $ENV{FFMPEG_DIR}
+ $ENV{FFMPEG_DIR}/ffmpeg
+ $ENV{FFMPEG_DIR}/libavutil
+ $ENV{FFMPEG_DIR}/include/libavutil
+ $ENV{FFMPEG_DIR}/include/ffmpeg
+ /usr/local/include/ffmpeg
+ /usr/include/ffmpeg
+ /usr/include/libavutil
+ /usr/include/ffmpeg/libavutil
+ /usr/include/${CMAKE_LIBRARY_ARCHITECTURE}/libavutil
+ /usr/local/include/libavutil
+)
+
+find_path(FFMPEG_INCLUDE_DIR3 avcodec.h
+ $ENV{FFMPEG_DIR}
+ $ENV{FFMPEG_DIR}/ffmpeg
+ $ENV{FFMPEG_DIR}/libavcodec
+ $ENV{FFMPEG_DIR}/include/libavcodec
+ $ENV{FFMPEG_DIR}/include/ffmpeg
+ /usr/local/include/ffmpeg
+ /usr/include/ffmpeg
+ /usr/include/libavcodec
+ /usr/include/ffmpeg/libavcodec
+ /usr/include/${CMAKE_LIBRARY_ARCHITECTURE}/libavcodec
+ /usr/local/include/libavcodec
+)
+
+find_path(FFMPEG_INCLUDE_DIR4 swscale.h
+ $ENV{FFMPEG_DIR}
+ $ENV{FFMPEG_DIR}/ffmpeg
+ $ENV{FFMPEG_DIR}/libswscale
+ $ENV{FFMPEG_DIR}/include/libswscale
+ $ENV{FFMPEG_DIR}/include/ffmpeg
+ /usr/local/include/ffmpeg
+ /usr/include/ffmpeg
+ /usr/include/libswscale
+ /usr/include/ffmpeg/libswscale
+ /usr/include/${CMAKE_LIBRARY_ARCHITECTURE}/libswscale
+ /usr/local/include/libswscale
+)
+
+find_path(FFMPEG_INCLUDE_DIR5 avdevice.h
+ $ENV{FFMPEG_DIR}
+ $ENV{FFMPEG_DIR}/ffmpeg
+ $ENV{FFMPEG_DIR}/libavdevice
+ $ENV{FFMPEG_DIR}/include/libavdevice
+ $ENV{FFMPEG_DIR}/include/ffmpeg
+ /usr/local/include/ffmpeg
+ /usr/include/ffmpeg
+ /usr/include/libavdevice
+ /usr/include/ffmpeg/libavdevice
+ /usr/include/${CMAKE_LIBRARY_ARCHITECTURE}/libavdevice
+ /usr/local/include/libavdevice
+)
+
+if(FFMPEG_INCLUDE_DIR1)
+ if(FFMPEG_INCLUDE_DIR2)
+ if(FFMPEG_INCLUDE_DIR3)
+ set(FFMPEG_INCLUDE_DIR ${FFMPEG_INCLUDE_DIR1}
+ ${FFMPEG_INCLUDE_DIR2}
+ ${FFMPEG_INCLUDE_DIR3})
+ endif()
+ endif()
+endif()
+
+if(FFMPEG_INCLUDE_DIR4)
+ set(FFMPEG_INCLUDE_DIR ${FFMPEG_INCLUDE_DIR}
+ ${FFMPEG_INCLUDE_DIR4})
+endif()
+
+if(FFMPEG_INCLUDE_DIR5)
+ set(FFMPEG_INCLUDE_DIR ${FFMPEG_INCLUDE_DIR}
+ ${FFMPEG_INCLUDE_DIR5}
+ ${FFMPEG_INCLUDE_DIR5}/..)
+endif()
+
+find_library(FFMPEG_avformat_LIBRARY avformat
+ $ENV{FFMPEG_DIR}
+ $ENV{FFMPEG_DIR}/lib
+ $ENV{FFMPEG_DIR}/libavformat
+ /usr/local/lib
+ /usr/lib
+)
+
+find_library(FFMPEG_avcodec_LIBRARY avcodec
+ $ENV{FFMPEG_DIR}
+ $ENV{FFMPEG_DIR}/lib
+ $ENV{FFMPEG_DIR}/libavcodec
+ /usr/local/lib
+ /usr/lib
+)
+
+find_library(FFMPEG_avutil_LIBRARY avutil
+ $ENV{FFMPEG_DIR}
+ $ENV{FFMPEG_DIR}/lib
+ $ENV{FFMPEG_DIR}/libavutil
+ /usr/local/lib
+ /usr/lib
+)
+
+if(NOT DISABLE_SWSCALE)
+ find_library(FFMPEG_swscale_LIBRARY swscale
+ $ENV{FFMPEG_DIR}
+ $ENV{FFMPEG_DIR}/lib
+ $ENV{FFMPEG_DIR}/libswscale
+ /usr/local/lib
+ /usr/lib
+ )
+endif(NOT DISABLE_SWSCALE)
+
+find_library(FFMPEG_avdevice_LIBRARY avdevice
+ $ENV{FFMPEG_DIR}
+ $ENV{FFMPEG_DIR}/lib
+ $ENV{FFMPEG_DIR}/libavdevice
+ /usr/local/lib
+ /usr/lib
+)
+
+find_library(_FFMPEG_z_LIBRARY_ z
+ $ENV{FFMPEG_DIR}
+ $ENV{FFMPEG_DIR}/lib
+ /usr/local/lib
+ /usr/lib
+)
+
+
+
+if(FFMPEG_INCLUDE_DIR)
+ if(FFMPEG_avformat_LIBRARY)
+ if(FFMPEG_avcodec_LIBRARY)
+ if(FFMPEG_avutil_LIBRARY)
+ set(FFMPEG_FOUND "YES")
+ set(FFMPEG_LIBRARIES ${FFMPEG_avformat_LIBRARY}
+ ${FFMPEG_avcodec_LIBRARY}
+ ${FFMPEG_avutil_LIBRARY}
+ )
+ if(FFMPEG_swscale_LIBRARY)
+ set(FFMPEG_LIBRARIES ${FFMPEG_LIBRARIES}
+ ${FFMPEG_swscale_LIBRARY}
+ )
+ endif()
+ if(FFMPEG_avdevice_LIBRARY)
+ set(FFMPEG_LIBRARIES ${FFMPEG_LIBRARIES}
+ ${FFMPEG_avdevice_LIBRARY}
+ )
+ endif()
+ if(_FFMPEG_z_LIBRARY_)
+ set( FFMPEG_LIBRARIES ${FFMPEG_LIBRARIES}
+ ${_FFMPEG_z_LIBRARY_}
+ )
+ endif()
+ endif()
+ endif()
+ endif()
+endif()
+
+mark_as_advanced(
+ FFMPEG_INCLUDE_DIR
+ FFMPEG_INCLUDE_DIR1
+ FFMPEG_INCLUDE_DIR2
+ FFMPEG_INCLUDE_DIR3
+ FFMPEG_INCLUDE_DIR4
+ FFMPEG_INCLUDE_DIR5
+ FFMPEG_avformat_LIBRARY
+ FFMPEG_avcodec_LIBRARY
+ FFMPEG_avutil_LIBRARY
+ FFMPEG_swscale_LIBRARY
+ FFMPEG_avdevice_LIBRARY
+ _FFMPEG_z_LIBRARY_
+ )
+
+# Set package properties if FeatureSummary was included
+if(COMMAND set_package_properties)
+ set_package_properties(FFMPEG PROPERTIES DESCRIPTION "A complete, cross-platform solution to record, convert and stream audio and video")
+ set_package_properties(FFMPEG PROPERTIES URL "http://ffmpeg.org/")
+endif()
diff --git a/cmake/Modules/FindLZO.cmake b/cmake/Modules/FindLZO.cmake
new file mode 100644
index 0000000..d313fae
--- /dev/null
+++ b/cmake/Modules/FindLZO.cmake
@@ -0,0 +1,31 @@
+# Find liblzo2
+# LZO_FOUND - system has the LZO library
+# LZO_INCLUDE_DIR - the LZO include directory
+# LZO_LIBRARIES - The libraries needed to use LZO
+
+if (LZO_INCLUDE_DIR AND LZO_LIBRARIES)
+ # in cache already
+ SET(LZO_FOUND TRUE)
+else (LZO_INCLUDE_DIR AND LZO_LIBRARIES)
+ FIND_PATH(LZO_INCLUDE_DIR NAMES lzo/lzo1x.h)
+
+ FIND_LIBRARY(LZO_LIBRARIES NAMES lzo2)
+
+ if (LZO_INCLUDE_DIR AND LZO_LIBRARIES)
+ set(LZO_FOUND TRUE)
+ endif (LZO_INCLUDE_DIR AND LZO_LIBRARIES)
+
+ if (LZO_FOUND)
+ if (NOT LZO_FIND_QUIETLY)
+ message(STATUS "Found LZO: ${LZO_LIBRARIES}")
+ endif (NOT LZO_FIND_QUIETLY)
+ else (LZO_FOUND)
+ if (LZO_FIND_REQUIRED)
+ message(FATAL_ERROR "Could NOT find LZO")
+ else()
+ message(STATUS "Could NOT find LZO")
+ endif (LZO_FIND_REQUIRED)
+ endif (LZO_FOUND)
+
+# MARK_AS_ADVANCED(LZO_INCLUDE_DIR LZO_LIBRARIES)
+endif (LZO_INCLUDE_DIR AND LZO_LIBRARIES)
diff --git a/cmake/Modules/FindSDL2.cmake b/cmake/Modules/FindSDL2.cmake
new file mode 100644
index 0000000..464ca2d
--- /dev/null
+++ b/cmake/Modules/FindSDL2.cmake
@@ -0,0 +1,173 @@
+
+# This module defines
+# SDL2_LIBRARY, the name of the library to link against
+# SDL2_FOUND, if false, do not try to link to SDL2
+# SDL2_INCLUDE_DIR, where to find SDL.h
+#
+# This module responds to the the flag:
+# SDL2_BUILDING_LIBRARY
+# If this is defined, then no SDL2main will be linked in because
+# only applications need main().
+# Otherwise, it is assumed you are building an application and this
+# module will attempt to locate and set the the proper link flags
+# as part of the returned SDL2_LIBRARY variable.
+#
+# Don't forget to include SDLmain.h and SDLmain.m your project for the
+# OS X framework based version. (Other versions link to -lSDL2main which
+# this module will try to find on your behalf.) Also for OS X, this
+# module will automatically add the -framework Cocoa on your behalf.
+#
+#
+# Additional Note: If you see an empty SDL2_LIBRARY_TEMP in your configuration
+# and no SDL2_LIBRARY, it means CMake did not find your SDL2 library
+# (SDL2.dll, libsdl2.so, SDL2.framework, etc).
+# Set SDL2_LIBRARY_TEMP to point to your SDL2 library, and configure again.
+# Similarly, if you see an empty SDL2MAIN_LIBRARY, you should set this value
+# as appropriate. These values are used to generate the final SDL2_LIBRARY
+# variable, but when these values are unset, SDL2_LIBRARY does not get created.
+#
+#
+# $SDL2DIR is an environment variable that would
+# correspond to the ./configure --prefix=$SDL2DIR
+# used in building SDL2.
+# l.e.galup 9-20-02
+#
+# Modified by Eric Wing.
+# Added code to assist with automated building by using environmental variables
+# and providing a more controlled/consistent search behavior.
+# Added new modifications to recognize OS X frameworks and
+# additional Unix paths (FreeBSD, etc).
+# Also corrected the header search path to follow "proper" SDL guidelines.
+# Added a search for SDL2main which is needed by some platforms.
+# Added a search for threads which is needed by some platforms.
+# Added needed compile switches for MinGW.
+#
+# On OSX, this will prefer the Framework version (if found) over others.
+# People will have to manually change the cache values of
+# SDL2_LIBRARY to override this selection or set the CMake environment
+# CMAKE_INCLUDE_PATH to modify the search paths.
+#
+# Note that the header path has changed from SDL2/SDL.h to just SDL.h
+# This needed to change because "proper" SDL convention
+# is #include "SDL.h", not <SDL2/SDL.h>. This is done for portability
+# reasons because not all systems place things in SDL2/ (see FreeBSD).
+
+#=============================================================================
+# Copyright 2003-2009 Kitware, Inc.
+#
+# Distributed under the OSI-approved BSD License (the "License");
+# see accompanying file Copyright.txt for details.
+#
+# This software is distributed WITHOUT ANY WARRANTY; without even the
+# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+# See the License for more information.
+#=============================================================================
+# (To distribute this file outside of CMake, substitute the full
+# License text for the above reference.)
+
+# message("<FindSDL2.cmake>")
+
+SET(SDL2_SEARCH_PATHS
+ ~/Library/Frameworks
+ /Library/Frameworks
+ /usr/local
+ /usr
+ /sw # Fink
+ /opt/local # DarwinPorts
+ /opt/csw # Blastwave
+ /opt
+ ${SDL2_PATH}
+)
+
+FIND_PATH(SDL2_INCLUDE_DIR SDL.h
+ HINTS
+ $ENV{SDL2DIR}
+ PATH_SUFFIXES include/SDL2 include
+ PATHS ${SDL2_SEARCH_PATHS}
+)
+
+if(CMAKE_SIZEOF_VOID_P EQUAL 8)
+ set(PATH_SUFFIXES lib64 lib/x64 lib)
+else()
+ set(PATH_SUFFIXES lib/x86 lib)
+endif()
+
+FIND_LIBRARY(SDL2_LIBRARY_TEMP
+ NAMES SDL2
+ HINTS
+ $ENV{SDL2DIR}
+ PATH_SUFFIXES ${PATH_SUFFIXES}
+ PATHS ${SDL2_SEARCH_PATHS}
+)
+
+IF(NOT SDL2_BUILDING_LIBRARY)
+ IF(NOT ${SDL2_INCLUDE_DIR} MATCHES ".framework")
+ # Non-OS X framework versions expect you to also dynamically link to
+ # SDL2main. This is mainly for Windows and OS X. Other (Unix) platforms
+ # seem to provide SDL2main for compatibility even though they don't
+ # necessarily need it.
+ FIND_LIBRARY(SDL2MAIN_LIBRARY
+ NAMES SDL2main
+ HINTS
+ $ENV{SDL2DIR}
+ PATH_SUFFIXES ${PATH_SUFFIXES}
+ PATHS ${SDL2_SEARCH_PATHS}
+ )
+ ENDIF(NOT ${SDL2_INCLUDE_DIR} MATCHES ".framework")
+ENDIF(NOT SDL2_BUILDING_LIBRARY)
+
+# SDL2 may require threads on your system.
+# The Apple build may not need an explicit flag because one of the
+# frameworks may already provide it.
+# But for non-OSX systems, I will use the CMake Threads package.
+IF(NOT APPLE)
+ FIND_PACKAGE(Threads)
+ENDIF(NOT APPLE)
+
+# MinGW needs an additional link flag, -mwindows
+# It's total link flags should look like -lmingw32 -lSDL2main -lSDL2 -mwindows
+IF(MINGW)
+ SET(MINGW32_LIBRARY mingw32 "-mwindows" CACHE STRING "mwindows for MinGW")
+ENDIF(MINGW)
+
+IF(SDL2_LIBRARY_TEMP)
+ # For SDL2main
+ IF(NOT SDL2_BUILDING_LIBRARY)
+ IF(SDL2MAIN_LIBRARY)
+ SET(SDL2_LIBRARY_TEMP ${SDL2MAIN_LIBRARY} ${SDL2_LIBRARY_TEMP})
+ ENDIF(SDL2MAIN_LIBRARY)
+ ENDIF(NOT SDL2_BUILDING_LIBRARY)
+
+ # For OS X, SDL2 uses Cocoa as a backend so it must link to Cocoa.
+ # CMake doesn't display the -framework Cocoa string in the UI even
+ # though it actually is there if I modify a pre-used variable.
+ # I think it has something to do with the CACHE STRING.
+ # So I use a temporary variable until the end so I can set the
+ # "real" variable in one-shot.
+ IF(APPLE)
+ SET(SDL2_LIBRARY_TEMP ${SDL2_LIBRARY_TEMP} "-framework Cocoa")
+ ENDIF(APPLE)
+
+ # For threads, as mentioned Apple doesn't need this.
+ # In fact, there seems to be a problem if I used the Threads package
+ # and try using this line, so I'm just skipping it entirely for OS X.
+ IF(NOT APPLE)
+ SET(SDL2_LIBRARY_TEMP ${SDL2_LIBRARY_TEMP} ${CMAKE_THREAD_LIBS_INIT})
+ ENDIF(NOT APPLE)
+
+ # For MinGW library
+ IF(MINGW)
+ SET(SDL2_LIBRARY_TEMP ${MINGW32_LIBRARY} ${SDL2_LIBRARY_TEMP})
+ ENDIF(MINGW)
+
+ # Set the final string here so the GUI reflects the final state.
+ SET(SDL2_LIBRARY ${SDL2_LIBRARY_TEMP} CACHE STRING "Where the SDL2 Library can be found")
+ # Set the temp variable to INTERNAL so it is not seen in the CMake GUI
+ SET(SDL2_LIBRARY_TEMP "${SDL2_LIBRARY_TEMP}" CACHE INTERNAL "")
+ENDIF(SDL2_LIBRARY_TEMP)
+
+# message("</FindSDL2.cmake>")
+
+INCLUDE(FindPackageHandleStandardArgs)
+
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(SDL2 REQUIRED_VARS SDL2_LIBRARY SDL2_INCLUDE_DIR)
diff --git a/common/base64.c b/common/base64.c
new file mode 100644
index 0000000..4e3685a
--- /dev/null
+++ b/common/base64.c
@@ -0,0 +1,315 @@
+/* $OpenBSD: base64.c,v 1.8 2015/01/16 16:48:51 deraadt Exp $ */
+
+/*
+ * Copyright (c) 1996 by Internet Software Consortium.
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
+ * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
+ * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
+ * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ */
+
+/*
+ * Portions Copyright (c) 1995 by International Business Machines, Inc.
+ *
+ * International Business Machines, Inc. (hereinafter called IBM) grants
+ * permission under its copyrights to use, copy, modify, and distribute this
+ * Software with or without fee, provided that the above copyright notice and
+ * all paragraphs of this notice appear in all copies, and that the name of IBM
+ * not be used in connection with the marketing of any product incorporating
+ * the Software or modifications thereof, without specific, written prior
+ * permission.
+ *
+ * To the extent it has a right to do so, IBM grants an immunity from suit
+ * under its patents, if any, for the use, sale or manufacture of products to
+ * the extent that such products are used for performing Domain Name System
+ * dynamic updates in TCP/IP networks by means of the Software. No immunity is
+ * granted for any product per se or for any other function of any product.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", AND IBM DISCLAIMS ALL WARRANTIES,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL IBM BE LIABLE FOR ANY SPECIAL,
+ * DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER ARISING
+ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE, EVEN
+ * IF IBM IS APPRISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ */
+
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <arpa/nameser.h>
+
+#include <ctype.h>
+#include <resolv.h>
+#include <stdio.h>
+
+#include <stdlib.h>
+#include <string.h>
+
+static const char Base64[] =
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
+static const char Pad64 = '=';
+
+/* (From RFC1521 and draft-ietf-dnssec-secext-03.txt)
+ The following encoding technique is taken from RFC 1521 by Borenstein
+ and Freed. It is reproduced here in a slightly edited form for
+ convenience.
+
+ A 65-character subset of US-ASCII is used, enabling 6 bits to be
+ represented per printable character. (The extra 65th character, "=",
+ is used to signify a special processing function.)
+
+ The encoding process represents 24-bit groups of input bits as output
+ strings of 4 encoded characters. Proceeding from left to right, a
+ 24-bit input group is formed by concatenating 3 8-bit input groups.
+ These 24 bits are then treated as 4 concatenated 6-bit groups, each
+ of which is translated into a single digit in the base64 alphabet.
+
+ Each 6-bit group is used as an index into an array of 64 printable
+ characters. The character referenced by the index is placed in the
+ output string.
+
+ Table 1: The Base64 Alphabet
+
+ Value Encoding Value Encoding Value Encoding Value Encoding
+ 0 A 17 R 34 i 51 z
+ 1 B 18 S 35 j 52 0
+ 2 C 19 T 36 k 53 1
+ 3 D 20 U 37 l 54 2
+ 4 E 21 V 38 m 55 3
+ 5 F 22 W 39 n 56 4
+ 6 G 23 X 40 o 57 5
+ 7 H 24 Y 41 p 58 6
+ 8 I 25 Z 42 q 59 7
+ 9 J 26 a 43 r 60 8
+ 10 K 27 b 44 s 61 9
+ 11 L 28 c 45 t 62 +
+ 12 M 29 d 46 u 63 /
+ 13 N 30 e 47 v
+ 14 O 31 f 48 w (pad) =
+ 15 P 32 g 49 x
+ 16 Q 33 h 50 y
+
+ Special processing is performed if fewer than 24 bits are available
+ at the end of the data being encoded. A full encoding quantum is
+ always completed at the end of a quantity. When fewer than 24 input
+ bits are available in an input group, zero bits are added (on the
+ right) to form an integral number of 6-bit groups. Padding at the
+ end of the data is performed using the '=' character.
+
+ Since all base64 input is an integral number of octets, only the
+ -------------------------------------------------
+ following cases can arise:
+
+ (1) the final quantum of encoding input is an integral
+ multiple of 24 bits; here, the final unit of encoded
+ output will be an integral multiple of 4 characters
+ with no "=" padding,
+ (2) the final quantum of encoding input is exactly 8 bits;
+ here, the final unit of encoded output will be two
+ characters followed by two "=" padding characters, or
+ (3) the final quantum of encoding input is exactly 16 bits;
+ here, the final unit of encoded output will be three
+ characters followed by one "=" padding character.
+ */
+
+int
+__b64_ntop(src, srclength, target, targsize)
+ u_char const *src;
+ size_t srclength;
+ char *target;
+ size_t targsize;
+{
+ size_t datalength = 0;
+ u_char input[3];
+ u_char output[4];
+ int i;
+
+ while (2 < srclength) {
+ input[0] = *src++;
+ input[1] = *src++;
+ input[2] = *src++;
+ srclength -= 3;
+
+ output[0] = input[0] >> 2;
+ output[1] = ((input[0] & 0x03) << 4) + (input[1] >> 4);
+ output[2] = ((input[1] & 0x0f) << 2) + (input[2] >> 6);
+ output[3] = input[2] & 0x3f;
+
+ if (datalength + 4 > targsize)
+ return (-1);
+ target[datalength++] = Base64[output[0]];
+ target[datalength++] = Base64[output[1]];
+ target[datalength++] = Base64[output[2]];
+ target[datalength++] = Base64[output[3]];
+ }
+
+ /* Now we worry about padding. */
+ if (0 != srclength) {
+ /* Get what's left. */
+ input[0] = input[1] = input[2] = '\0';
+ for (i = 0; i < srclength; i++)
+ input[i] = *src++;
+
+ output[0] = input[0] >> 2;
+ output[1] = ((input[0] & 0x03) << 4) + (input[1] >> 4);
+ output[2] = ((input[1] & 0x0f) << 2) + (input[2] >> 6);
+
+ if (datalength + 4 > targsize)
+ return (-1);
+ target[datalength++] = Base64[output[0]];
+ target[datalength++] = Base64[output[1]];
+ if (srclength == 1)
+ target[datalength++] = Pad64;
+ else
+ target[datalength++] = Base64[output[2]];
+ target[datalength++] = Pad64;
+ }
+ if (datalength >= targsize)
+ return (-1);
+ target[datalength] = '\0'; /* Returned value doesn't count \0. */
+ return (datalength);
+}
+
+/* skips all whitespace anywhere.
+ converts characters, four at a time, starting at (or after)
+ src from base - 64 numbers into three 8 bit bytes in the target area.
+ it returns the number of data bytes stored at the target, or -1 on error.
+ */
+
+int
+__b64_pton(src, target, targsize)
+ char const *src;
+ u_char *target;
+ size_t targsize;
+{
+ int tarindex, state, ch;
+ u_char nextbyte;
+ char *pos;
+
+ state = 0;
+ tarindex = 0;
+
+ while ((ch = (unsigned char)*src++) != '\0') {
+ if (isspace(ch)) /* Skip whitespace anywhere. */
+ continue;
+
+ if (ch == Pad64)
+ break;
+
+ pos = strchr(Base64, ch);
+ if (pos == 0) /* A non-base64 character. */
+ return (-1);
+
+ switch (state) {
+ case 0:
+ if (target) {
+ if (tarindex >= targsize)
+ return (-1);
+ target[tarindex] = (pos - Base64) << 2;
+ }
+ state = 1;
+ break;
+ case 1:
+ if (target) {
+ if (tarindex >= targsize)
+ return (-1);
+ target[tarindex] |= (pos - Base64) >> 4;
+ nextbyte = ((pos - Base64) & 0x0f) << 4;
+ if (tarindex + 1 < targsize)
+ target[tarindex+1] = nextbyte;
+ else if (nextbyte)
+ return (-1);
+ }
+ tarindex++;
+ state = 2;
+ break;
+ case 2:
+ if (target) {
+ if (tarindex >= targsize)
+ return (-1);
+ target[tarindex] |= (pos - Base64) >> 2;
+ nextbyte = ((pos - Base64) & 0x03) << 6;
+ if (tarindex + 1 < targsize)
+ target[tarindex+1] = nextbyte;
+ else if (nextbyte)
+ return (-1);
+ }
+ tarindex++;
+ state = 3;
+ break;
+ case 3:
+ if (target) {
+ if (tarindex >= targsize)
+ return (-1);
+ target[tarindex] |= (pos - Base64);
+ }
+ tarindex++;
+ state = 0;
+ break;
+ }
+ }
+
+ /*
+ * We are done decoding Base-64 chars. Let's see if we ended
+ * on a byte boundary, and/or with erroneous trailing characters.
+ */
+
+ if (ch == Pad64) { /* We got a pad char. */
+ ch = (unsigned char)*src++; /* Skip it, get next. */
+ switch (state) {
+ case 0: /* Invalid = in first position */
+ case 1: /* Invalid = in second position */
+ return (-1);
+
+ case 2: /* Valid, means one byte of info */
+ /* Skip any number of spaces. */
+ for (; ch != '\0'; ch = (unsigned char)*src++)
+ if (!isspace(ch))
+ break;
+ /* Make sure there is another trailing = sign. */
+ if (ch != Pad64)
+ return (-1);
+ ch = (unsigned char)*src++; /* Skip the = */
+ /* Fall through to "single trailing =" case. */
+ /* FALLTHROUGH */
+
+ case 3: /* Valid, means two bytes of info */
+ /*
+ * We know this char is an =. Is there anything but
+ * whitespace after it?
+ */
+ for (; ch != '\0'; ch = (unsigned char)*src++)
+ if (!isspace(ch))
+ return (-1);
+
+ /*
+ * Now make sure for cases 2 and 3 that the "extra"
+ * bits that slopped past the last full byte were
+ * zeros. If we don't check them, they become a
+ * subliminal channel.
+ */
+ if (target && tarindex < targsize &&
+ target[tarindex] != 0)
+ return (-1);
+ }
+ } else {
+ /*
+ * We ended by seeing the end of the string. Make sure we
+ * have no partial bytes lying around.
+ */
+ if (state != 0)
+ return (-1);
+ }
+
+ return (tarindex);
+}
diff --git a/common/base64.h b/common/base64.h
new file mode 100644
index 0000000..9b86fc1
--- /dev/null
+++ b/common/base64.h
@@ -0,0 +1,10 @@
+#ifndef _BASE64_H
+#define _BASE64_H
+
+extern int __b64_ntop(u_char const *src, size_t srclength, char *target, size_t targsize);
+extern int __b64_pton(char const *src, u_char *target, size_t targsize);
+
+#define rfbBase64NtoP __b64_ntop
+#define rfbBase64PtoN __b64_pton
+
+#endif /* _BASE64_H */
diff --git a/common/d3des.c b/common/d3des.c
index 2df1aab..12ccf62 100644
--- a/common/d3des.c
+++ b/common/d3des.c
@@ -28,12 +28,20 @@
#include "d3des.h"
+#if defined(__GNUC__)
+#define TLS __thread
+#elif defined(_MSC_VER)
+#define TLS __declspec(thread)
+#else
+#define TLS
+#endif
+
static void scrunch(unsigned char *, unsigned long *);
static void unscrun(unsigned long *, unsigned char *);
static void desfunc(unsigned long *, unsigned long *);
static void cookey(unsigned long *);
-static unsigned long KnL[32] = { 0L };
+static TLS unsigned long KnL[32] = { 0L };
/*
static unsigned long KnR[32] = { 0L };
static unsigned long Kn3[32] = { 0L };
@@ -43,10 +51,10 @@ static unsigned char Df_Key[24] = {
0x89,0xab,0xcd,0xef,0x01,0x23,0x45,0x67 };
*/
-static unsigned short bytebit[8] = {
+static const unsigned short bytebit[8] = {
01, 02, 04, 010, 020, 040, 0100, 0200 };
-static unsigned long bigbyte[24] = {
+static const unsigned long bigbyte[24] = {
0x800000L, 0x400000L, 0x200000L, 0x100000L,
0x80000L, 0x40000L, 0x20000L, 0x10000L,
0x8000L, 0x4000L, 0x2000L, 0x1000L,
@@ -56,16 +64,16 @@ static unsigned long bigbyte[24] = {
/* Use the key schedule specified in the Standard (ANSI X3.92-1981). */
-static unsigned char pc1[56] = {
+static const unsigned char pc1[56] = {
56, 48, 40, 32, 24, 16, 8, 0, 57, 49, 41, 33, 25, 17,
9, 1, 58, 50, 42, 34, 26, 18, 10, 2, 59, 51, 43, 35,
62, 54, 46, 38, 30, 22, 14, 6, 61, 53, 45, 37, 29, 21,
13, 5, 60, 52, 44, 36, 28, 20, 12, 4, 27, 19, 11, 3 };
-static unsigned char totrot[16] = {
+static const unsigned char totrot[16] = {
1,2,4,6,8,10,12,14,15,17,19,21,23,25,27,28 };
-static unsigned char pc2[48] = {
+static const unsigned char pc2[48] = {
13, 16, 10, 23, 0, 4, 2, 27, 14, 5, 20, 9,
22, 18, 11, 3, 25, 7, 15, 6, 26, 19, 12, 1,
40, 51, 30, 36, 46, 54, 29, 39, 50, 44, 32, 47,
@@ -129,14 +137,6 @@ static void cookey(register unsigned long *raw1)
return;
}
-void rfbCPKey(register unsigned long *into)
-{
- register unsigned long *from, *endp;
-
- from = KnL, endp = &KnL[32];
- while( from < endp ) *into++ = *from++;
- return;
- }
void rfbUseKey(register unsigned long *from)
{
@@ -186,7 +186,7 @@ static void unscrun(register unsigned long *outof,
return;
}
-static unsigned long SP1[64] = {
+static const unsigned long SP1[64] = {
0x01010400L, 0x00000000L, 0x00010000L, 0x01010404L,
0x01010004L, 0x00010404L, 0x00000004L, 0x00010000L,
0x00000400L, 0x01010400L, 0x01010404L, 0x00000400L,
@@ -204,7 +204,7 @@ static unsigned long SP1[64] = {
0x00000404L, 0x01000400L, 0x01000400L, 0x00000000L,
0x00010004L, 0x00010400L, 0x00000000L, 0x01010004L };
-static unsigned long SP2[64] = {
+static const unsigned long SP2[64] = {
0x80108020L, 0x80008000L, 0x00008000L, 0x00108020L,
0x00100000L, 0x00000020L, 0x80100020L, 0x80008020L,
0x80000020L, 0x80108020L, 0x80108000L, 0x80000000L,
@@ -222,7 +222,7 @@ static unsigned long SP2[64] = {
0x00108000L, 0x00000000L, 0x80008000L, 0x00008020L,
0x80000000L, 0x80100020L, 0x80108020L, 0x00108000L };
-static unsigned long SP3[64] = {
+static const unsigned long SP3[64] = {
0x00000208L, 0x08020200L, 0x00000000L, 0x08020008L,
0x08000200L, 0x00000000L, 0x00020208L, 0x08000200L,
0x00020008L, 0x08000008L, 0x08000008L, 0x00020000L,
@@ -240,7 +240,7 @@ static unsigned long SP3[64] = {
0x08020000L, 0x08000208L, 0x00000208L, 0x08020000L,
0x00020208L, 0x00000008L, 0x08020008L, 0x00020200L };
-static unsigned long SP4[64] = {
+static const unsigned long SP4[64] = {
0x00802001L, 0x00002081L, 0x00002081L, 0x00000080L,
0x00802080L, 0x00800081L, 0x00800001L, 0x00002001L,
0x00000000L, 0x00802000L, 0x00802000L, 0x00802081L,
@@ -258,7 +258,7 @@ static unsigned long SP4[64] = {
0x00002001L, 0x00002080L, 0x00800000L, 0x00802001L,
0x00000080L, 0x00800000L, 0x00002000L, 0x00802080L };
-static unsigned long SP5[64] = {
+static const unsigned long SP5[64] = {
0x00000100L, 0x02080100L, 0x02080000L, 0x42000100L,
0x00080000L, 0x00000100L, 0x40000000L, 0x02080000L,
0x40080100L, 0x00080000L, 0x02000100L, 0x40080100L,
@@ -276,7 +276,7 @@ static unsigned long SP5[64] = {
0x00080100L, 0x02000100L, 0x40000100L, 0x00080000L,
0x00000000L, 0x40080000L, 0x02080100L, 0x40000100L };
-static unsigned long SP6[64] = {
+static const unsigned long SP6[64] = {
0x20000010L, 0x20400000L, 0x00004000L, 0x20404010L,
0x20400000L, 0x00000010L, 0x20404010L, 0x00400000L,
0x20004000L, 0x00404010L, 0x00400000L, 0x20000010L,
@@ -294,7 +294,7 @@ static unsigned long SP6[64] = {
0x00004000L, 0x00400010L, 0x20004010L, 0x00000000L,
0x20404000L, 0x20000000L, 0x00400010L, 0x20004010L };
-static unsigned long SP7[64] = {
+static const unsigned long SP7[64] = {
0x00200000L, 0x04200002L, 0x04000802L, 0x00000000L,
0x00000800L, 0x04000802L, 0x00200802L, 0x04200800L,
0x04200802L, 0x00200000L, 0x00000000L, 0x04000002L,
@@ -312,7 +312,7 @@ static unsigned long SP7[64] = {
0x00000000L, 0x00200802L, 0x04200000L, 0x00000800L,
0x04000002L, 0x04000800L, 0x00000800L, 0x00200002L };
-static unsigned long SP8[64] = {
+static const unsigned long SP8[64] = {
0x10001040L, 0x00001000L, 0x00040000L, 0x10041040L,
0x10000000L, 0x10001040L, 0x00000040L, 0x10000000L,
0x00040040L, 0x10040000L, 0x10041040L, 0x00041000L,
diff --git a/common/d3des.h b/common/d3des.h
index e3761ca..bb7d182 100644
--- a/common/d3des.h
+++ b/common/d3des.h
@@ -37,12 +37,6 @@ extern void rfbUseKey(unsigned long *);
* Loads the internal key register with the data in cookedkey.
*/
-extern void rfbCPKey(unsigned long *);
-/* cookedkey[32]
- * Copies the contents of the internal key register into the storage
- * located at &cookedkey[0].
- */
-
extern void rfbDes(unsigned char *, unsigned char *);
/* from[8] to[8]
* Encrypts/Decrypts (according to the key currently loaded in the
diff --git a/common/md5.c b/common/md5.c
index c3e3fd7..13e47a8 100644
--- a/common/md5.c
+++ b/common/md5.c
@@ -27,12 +27,11 @@
# include <string.h>
#include "md5.h"
+#include "rfb/rfbconfig.h"
-/* #ifdef _LIBC */
-# include <endian.h>
-# if __BYTE_ORDER == __BIG_ENDIAN
+#ifdef LIBVNCSERVER_WORDS_BIGENDIAN
# define WORDS_BIGENDIAN 1
-# endif
+#endif
/* We need to keep the namespace clean so define the MD5 function
protected using leading __ . */
# define md5_init_ctx __md5_init_ctx
diff --git a/common/md5.h b/common/md5.h
index b48545b..b0daab1 100644
--- a/common/md5.h
+++ b/common/md5.h
@@ -88,7 +88,11 @@ struct md5_ctx
md5_uint32 total[2];
md5_uint32 buflen;
- char buffer[128] __attribute__ ((__aligned__ (__alignof__ (md5_uint32))));
+ char buffer[128]
+#if __GNUC__
+ __attribute__ ((__aligned__ (__alignof__ (md5_uint32))))
+#endif
+ ;
};
/*
@@ -98,21 +102,21 @@ struct md5_ctx
/* Initialize structure containing state of computation.
(RFC 1321, 3.3: Step 3) */
-extern void __md5_init_ctx (struct md5_ctx *ctx) __THROW;
+extern void __md5_init_ctx (struct md5_ctx *ctx);
/* Starting with the result of former calls of this function (or the
initialization function update the context for the next LEN bytes
starting at BUFFER.
It is necessary that LEN is a multiple of 64!!! */
extern void __md5_process_block (const void *buffer, size_t len,
- struct md5_ctx *ctx) __THROW;
+ struct md5_ctx *ctx);
/* Starting with the result of former calls of this function (or the
initialization function update the context for the next LEN bytes
starting at BUFFER.
It is NOT required that LEN is a multiple of 64. */
extern void __md5_process_bytes (const void *buffer, size_t len,
- struct md5_ctx *ctx) __THROW;
+ struct md5_ctx *ctx);
/* Process the remaining bytes in the buffer and put result from CTX
in first 16 bytes following RESBUF. The result is always in little
@@ -121,7 +125,7 @@ extern void __md5_process_bytes (const void *buffer, size_t len,
IMPORTANT: On some systems it is required that RESBUF is correctly
aligned for a 32 bits value. */
-extern void *__md5_finish_ctx (struct md5_ctx *ctx, void *resbuf) __THROW;
+extern void *__md5_finish_ctx (struct md5_ctx *ctx, void *resbuf);
/* Put result from CTX in first 16 bytes following RESBUF. The result is
@@ -130,19 +134,19 @@ extern void *__md5_finish_ctx (struct md5_ctx *ctx, void *resbuf) __THROW;
IMPORTANT: On some systems it is required that RESBUF is correctly
aligned for a 32 bits value. */
-extern void *__md5_read_ctx (const struct md5_ctx *ctx, void *resbuf) __THROW;
+extern void *__md5_read_ctx (const struct md5_ctx *ctx, void *resbuf);
/* Compute MD5 message digest for bytes read from STREAM. The
resulting message digest number will be written into the 16 bytes
beginning at RESBLOCK. */
-extern int __md5_stream (FILE *stream, void *resblock) __THROW;
+extern int __md5_stream (FILE *stream, void *resblock);
/* Compute MD5 message digest for LEN bytes beginning at BUFFER. The
result is always in little endian byte order, so that a byte-wise
output yields to the wanted ASCII representation of the message
digest. */
extern void *__md5_buffer (const char *buffer, size_t len,
- void *resblock) __THROW;
+ void *resblock);
#endif /* md5.h */
diff --git a/libvncserver/rfbcrypto.h b/common/rfbcrypto.h
index 9dc3e63..fec095e 100644
--- a/libvncserver/rfbcrypto.h
+++ b/common/rfbcrypto.h
@@ -1,12 +1,16 @@
#ifndef _RFB_CRYPTO_H
#define _RFB_CRYPTO_H 1
-#include <sys/uio.h>
+#include "rfb/rfbconfig.h"
#define SHA1_HASH_SIZE 20
#define MD5_HASH_SIZE 16
+#ifdef LIBVNCSERVER_HAVE_SYS_UIO_H
+#include <sys/uio.h>
+
void digestmd5(const struct iovec *iov, int iovcnt, void *dest);
void digestsha1(const struct iovec *iov, int iovcnt, void *dest);
+#endif
#endif
diff --git a/libvncserver/rfbcrypto_gnutls.c b/common/rfbcrypto_gnutls.c
index 2ecb2da..2ecb2da 100644
--- a/libvncserver/rfbcrypto_gnutls.c
+++ b/common/rfbcrypto_gnutls.c
diff --git a/libvncserver/rfbcrypto_included.c b/common/rfbcrypto_included.c
index 7feff61..7feff61 100644
--- a/libvncserver/rfbcrypto_included.c
+++ b/common/rfbcrypto_included.c
diff --git a/libvncserver/rfbcrypto_openssl.c b/common/rfbcrypto_openssl.c
index 29ec5c1..29ec5c1 100644
--- a/libvncserver/rfbcrypto_openssl.c
+++ b/common/rfbcrypto_openssl.c
diff --git a/common/turbojpeg.c b/common/turbojpeg.c
index 09df173..934e4f1 100644
--- a/common/turbojpeg.c
+++ b/common/turbojpeg.c
@@ -468,7 +468,8 @@ static tjhandle _tjInitCompress(tjinstance *this)
if(setjmp(this->jerr.setjmp_buffer))
{
/* If we get here, the JPEG code has signaled an error. */
- if(this) free(this); return NULL;
+ if(this) free(this);
+ return NULL;
}
jpeg_create_compress(&this->cinfo);
@@ -652,7 +653,8 @@ static tjhandle _tjInitDecompress(tjinstance *this)
if(setjmp(this->jerr.setjmp_buffer))
{
/* If we get here, the JPEG code has signaled an error. */
- if(this) free(this); return NULL;
+ if(this) free(this);
+ return NULL;
}
jpeg_create_decompress(&this->dinfo);
diff --git a/common/vncauth.c b/common/vncauth.c
index 9434ae4..53347d3 100644
--- a/common/vncauth.c
+++ b/common/vncauth.c
@@ -26,7 +26,9 @@
#endif
#include <stdio.h>
#include <stdlib.h>
+#ifdef LIBVNCSERVER_HAVE_UNISTD_H
#include <unistd.h>
+#endif
#include <rfb/rfbproto.h>
#include "d3des.h"
@@ -200,8 +202,9 @@ rfbEncryptBytes2(unsigned char *where, const int length, unsigned char *key) {
where[i] ^= key[i];
rfbDes(where, where);
for (i = 8; i < length; i += 8) {
- for (j = 0; j < 8; j++)
+ for (j = 0; j < 8; j++) {
where[i + j] ^= where[i + j - 8];
- rfbDes(where + i, where + i);
+ }
+ rfbDes(where + i, where + i);
}
}
diff --git a/configure.ac b/configure.ac
deleted file mode 100644
index f13edb4..0000000
--- a/configure.ac
+++ /dev/null
@@ -1,599 +0,0 @@
-# Process this file with autoconf to produce a configure script.
-AC_INIT(LibVNCServer, 0.9.11, https://github.com/LibVNC/libvncserver)
-AM_INIT_AUTOMAKE([subdir-objects])
-m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
-AM_CONFIG_HEADER(rfbconfig.h)
-AX_PREFIX_CONFIG_H([rfb/rfbconfig.h])
-AC_CONFIG_MACRO_DIR([m4])
-
-
-# set detailed version info
-AC_DEFINE(VERSION_MAJOR, 0, LibVNCServer major version)
-AC_DEFINE(VERSION_MINOR, 9, LibVNCServer minor version)
-AC_DEFINE(VERSION_PATCHLEVEL, 11, LibVNCServer patchlevel)
-
-# Checks for programs.
-AC_PROG_CC
-AM_PROG_CC_C_O
-if test -z "$CC"; then
- CCLD="\$(CC)"
-else
- CCLD="$CC"
-fi
-test "x$GCC" = "xyes" && CFLAGS="$CFLAGS -Wall"
-AC_PROG_MAKE_SET
-AC_LIBTOOL_WIN32_DLL
-AC_PROG_LIBTOOL
-AC_CHECK_TOOL([AR], [ar], [/usr/bin/ar],
- [$PATH:/usr/ccs/bin])
-
-# Options
-AH_TEMPLATE(WITH_TIGHTVNC_FILETRANSFER, [Disable TightVNCFileTransfer protocol])
-AC_ARG_WITH(tightvnc-filetransfer,
- [ --without-tightvnc-filetransfer disable TightVNC file transfer protocol],
- , [ with_tightvnc_filetransfer=yes ])
-# AC_DEFINE moved to after libpthread check.
-
-# WebSockets support
-AC_CHECK_FUNC(__b64_ntop, HAVE_B64_IN_LIBC="true", HAVE_B64_IN_LIBC="false")
-if test "x$HAVE_B64_IN_LIBC" != "xtrue"; then
- AC_CHECK_LIB(resolv, __b64_ntop, HAVE_B64_IN_LIBRESOLV="true", HAVE_B64_IN_LIBRESOLV="false")
- if test "x$HAVE_B64_IN_LIBRESOLV" = "xtrue"; then
- RESOLV_LIB="-lresolv"
- HAVE_B64="true"
- fi
-else
- HAVE_B64="true"
-fi
-AH_TEMPLATE(WITH_WEBSOCKETS, [Disable WebSockets support])
-AC_ARG_WITH(websockets,
- [ --without-websockets disable WebSockets support],
- , [ with_websockets=yes ])
-# AC_DEFINE moved to after libresolve check.
-
-AH_TEMPLATE(ALLOW24BPP, [Enable 24 bit per pixel in native framebuffer])
-AC_ARG_WITH(24bpp,
- [ --without-24bpp disable 24 bpp framebuffers],
- , [ with_24bpp=yes ])
-if test "x$with_24bpp" = "xyes"; then
- AC_DEFINE(ALLOW24BPP)
-fi
-AH_TEMPLATE(FFMPEG, [Use ffmpeg (for vnc2mpg)])
-AC_ARG_WITH(ffmpeg,
- [ --with-ffmpeg=dir set ffmpeg home directory],,)
-AC_SUBST(with_ffmpeg)
-AM_CONDITIONAL(WITH_FFMPEG, test ! -z "$with_ffmpeg")
-if test ! -z "$with_ffmpeg"; then
- AC_CHECK_LIB(mp3lame, lame_init, HAVE_MP3LAME="true", HAVE_MP3LAME="false" )
-fi
-AM_CONDITIONAL(HAVE_MP3LAME, test "$HAVE_MP3LAME" = "true")
-
-PKG_CHECK_MODULES([LIBSYSTEMD], [libsystemd], [with_systemd=1], [with_systemd=0])
-AM_CONDITIONAL([WITH_SYSTEMD], [test $with_systemd -eq 1])
-
-# Seem to need this dummy here to induce the 'checking for egrep... grep -E', etc.
-# before it seemed to be inside the with_jpeg conditional.
-AC_CHECK_HEADER(thenonexistentheader.h, HAVE_THENONEXISTENTHEADER_H="true")
-
-# set some ld -R nonsense
-#
-uname_s=`(uname -s) 2>/dev/null`
-ld_minus_R="yes"
-if test "x$uname_s" = "xHP-UX"; then
- ld_minus_R="no"
-elif test "x$uname_s" = "xOSF1"; then
- ld_minus_R="no"
-elif test "x$uname_s" = "xDarwin"; then
- ld_minus_R="no"
-fi
-
-# Check for OpenSSL
-AH_TEMPLATE(HAVE_LIBCRYPT, [libcrypt library present])
-AC_ARG_WITH(crypt,
-[ --without-crypt disable support for libcrypt],,)
-if test "x$with_crypt" != "xno"; then
- AC_CHECK_FUNCS([crypt], HAVE_LIBC_CRYPT="true")
- if test -z "$HAVE_LIBC_CRYPT"; then
- AC_CHECK_LIB(crypt, crypt,
- CRYPT_LIBS="-lcrypt"
- [AC_DEFINE(HAVE_LIBCRYPT)], ,)
- fi
-fi
-AC_SUBST(CRYPT_LIBS)
-
-# some OS's need both -lssl and -lcrypto on link line:
-AH_TEMPLATE(HAVE_LIBCRYPTO, [openssl libcrypto library present])
-AC_ARG_WITH(crypto,
-[ --without-crypto disable support for openssl libcrypto],,)
-
-AH_TEMPLATE(HAVE_LIBSSL, [openssl libssl library present])
-AC_ARG_WITH(ssl,
-[ --without-ssl disable support for openssl libssl]
-[ --with-ssl=DIR use openssl include/library files in DIR],,)
-
-if test "x$with_crypto" != "xno" -a "x$with_ssl" != "xno"; then
- if test ! -z "$with_ssl" -a "x$with_ssl" != "xyes"; then
- saved_CPPFLAGS="$CPPFLAGS"
- saved_LDFLAGS="$LDFLAGS"
- CPPFLAGS="$CPPFLAGS -I$with_ssl/include"
- LDFLAGS="$LDFLAGS -L$with_ssl/lib"
- if test "x$ld_minus_R" = "xno"; then
- :
- elif test "x$GCC" = "xyes"; then
- LDFLAGS="$LDFLAGS -Xlinker -R$with_ssl/lib"
- else
- LDFLAGS="$LDFLAGS -R$with_ssl/lib"
- fi
- fi
- AC_CHECK_LIB(crypto, RAND_file_name,
- [AC_DEFINE(HAVE_LIBCRYPTO) HAVE_LIBCRYPTO="true"], ,)
- if test ! -z "$with_ssl" -a "x$with_ssl" != "xyes"; then
- if test "x$HAVE_LIBCRYPTO" != "xtrue"; then
- CPPFLAGS="$saved_CPPFLAGS"
- LDFLAGS="$saved_LDFLAGS"
- fi
- fi
-fi
-
-AH_TEMPLATE(HAVE_X509_PRINT_EX_FP, [open ssl X509_print_ex_fp available])
-if test "x$with_ssl" != "xno"; then
- if test "x$HAVE_LIBCRYPTO" = "xtrue"; then
- AC_CHECK_LIB(ssl, SSL_library_init,
- SSL_LIBS="-lssl -lcrypto"
- [AC_DEFINE(HAVE_LIBSSL) HAVE_LIBSSL="true"], ,
- -lcrypto)
- else
- AC_CHECK_LIB(ssl, SSL_library_init,
- SSL_LIBS="-lssl"
- [AC_DEFINE(HAVE_LIBSSL) HAVE_LIBSSL="true"], ,)
- fi
-fi
-AC_SUBST(SSL_LIBS)
-AM_CONDITIONAL(HAVE_LIBSSL, test ! -z "$SSL_LIBS")
-
-
-
-
-AC_ARG_WITH(jpeg,
-[ --without-jpeg disable support for jpeg]
-[ --with-jpeg=DIR use jpeg include/library files in DIR],,)
-
-# At this point:
-# no jpeg on command line with_jpeg=""
-# -with-jpeg with_jpeg="yes"
-# -without-jpeg with_jpeg="no"
-# -with-jpeg=/foo/dir with_jpeg="/foo/dir"
-
-HAVE_LIBJPEG_TURBO="false"
-
-if test "x$with_jpeg" != "xno"; then
- AC_ARG_VAR(JPEG_LDFLAGS,
- [Linker flags to use when linking with libjpeg, e.g. -L/foo/dir/lib -Wl,-static -ljpeg -Wl,-shared. This overrides the linker flags set by --with-jpeg.])
- saved_CPPFLAGS="$CPPFLAGS"
- saved_LDFLAGS="$LDFLAGS"
- saved_LIBS="$LIBS"
- if test ! -z "$with_jpeg" -a "x$with_jpeg" != "xyes"; then
- # add user supplied directory to flags:
- CPPFLAGS="$CPPFLAGS -I$with_jpeg/include"
- LDFLAGS="$LDFLAGS -L$with_jpeg/lib"
- if test "x$ld_minus_R" = "xno"; then
- :
- elif test "x$GCC" = "xyes"; then
- # this is not complete... in general a rat's nest.
- LDFLAGS="$LDFLAGS -Xlinker -R$with_jpeg/lib"
- else
- LDFLAGS="$LDFLAGS -R$with_jpeg/lib"
- fi
- fi
- if test "x$JPEG_LDFLAGS" != "x"; then
- LDFLAGS="$saved_LDFLAGS"
- LIBS="$LIBS $JPEG_LDFLAGS"
- else
- LIBS="-ljpeg"
- fi
- AC_CHECK_HEADER(jpeglib.h, HAVE_JPEGLIB_H="true")
- AC_MSG_CHECKING(for jpeg_CreateCompress in libjpeg)
- if test "x$HAVE_JPEGLIB_H" = "xtrue"; then
- AC_LINK_IFELSE([AC_LANG_CALL([], [jpeg_CreateCompress])],
- [AC_MSG_RESULT(yes);
- AC_DEFINE(HAVE_LIBJPEG, 1, libjpeg support enabled)],
- [AC_MSG_RESULT(no); HAVE_JPEGLIB_H=""])
- fi
- if test "x$HAVE_JPEGLIB_H" != "xtrue"; then
- # restore old flags on failure:
- CPPFLAGS="$saved_CPPFLAGS"
- LDFLAGS="$saved_LDFLAGS"
- LIBS="$saved_LIBS"
- AC_MSG_WARN([
-==========================================================================
-*** The libjpeg compression library was not found. ***
-This may lead to reduced performance, especially over slow links.
-If libjpeg is in a non-standard location use --with-jpeg=DIR to
-indicate the header file is in DIR/include/jpeglib.h and the library
-in DIR/lib/libjpeg.a. You can also set the JPEG_LDFLAGS variable to
-specify more detailed linker flags. A copy of libjpeg-turbo may be
-obtained from: https://sourceforge.net/projects/libjpeg-turbo/files/
-A copy of libjpeg may be obtained from: http://ijg.org/files/
-==========================================================================
-])
- sleep 5
- fi
-
- if test "x$HAVE_JPEGLIB_H" = "xtrue"; then
- AC_MSG_CHECKING(whether JPEG library is libjpeg-turbo)
- m4_define([LJT_TEST],
- [AC_LANG_PROGRAM([#include <stdio.h>
- #include <jpeglib.h>],
- [struct jpeg_compress_struct cinfo;
- struct jpeg_error_mgr jerr;
- cinfo.err=jpeg_std_error(&jerr);
- jpeg_create_compress(&cinfo);
- cinfo.input_components = 3;
- jpeg_set_defaults(&cinfo);
- cinfo.in_color_space = JCS_EXT_RGB;
- jpeg_default_colorspace(&cinfo);
- return 0;])]
- )
- if test "x$cross_compiling" != "xyes"; then
- AC_RUN_IFELSE([LJT_TEST],
- [HAVE_LIBJPEG_TURBO="true"; AC_MSG_RESULT(yes)],
- [AC_MSG_RESULT(no)])
- else
- AC_LINK_IFELSE([LJT_TEST],
- [HAVE_LIBJPEG_TURBO="true"; AC_MSG_RESULT(yes)],
- [AC_MSG_RESULT(no)])
- fi
- fi
-
- if test "x$HAVE_JPEGLIB_H" = "xtrue" -a "x$HAVE_LIBJPEG_TURBO" != "xtrue"; then
- AC_MSG_WARN([
-==========================================================================
-*** The libjpeg library you are building against is not libjpeg-turbo.
-Performance will be reduced. You can obtain libjpeg-turbo from:
-https://sourceforge.net/projects/libjpeg-turbo/files/ ***
-==========================================================================
-])
- fi
-
-fi
-
-AC_ARG_WITH(png,
-[ --without-png disable support for png]
-[ --with-png=DIR use png include/library files in DIR],,)
-
-# At this point:
-# no png on command line with_png=""
-# -with-png with_png="yes"
-# -without-png with_png="no"
-# -with-png=/foo/dir with_png="/foo/dir"
-
-if test "x$with_png" != "xno"; then
- if test ! -z "$with_png" -a "x$with_png" != "xyes"; then
- # add user supplied directory to flags:
- saved_CPPFLAGS="$CPPFLAGS"
- saved_LDFLAGS="$LDFLAGS"
- CPPFLAGS="$CPPFLAGS -I$with_png/include"
- LDFLAGS="$LDFLAGS -L$with_png/lib"
- if test "x$ld_minus_R" = "xno"; then
- :
- elif test "x$GCC" = "xyes"; then
- # this is not complete... in general a rat's nest.
- LDFLAGS="$LDFLAGS -Xlinker -R$with_png/lib"
- else
- LDFLAGS="$LDFLAGS -R$with_png/lib"
- fi
- fi
- AC_CHECK_HEADER(png.h, HAVE_PNGLIB_H="true")
- if test "x$HAVE_PNGLIB_H" = "xtrue"; then
- AC_CHECK_LIB(png, png_create_write_struct, , HAVE_PNGLIB_H="")
- fi
- if test ! -z "$with_png" -a "x$with_png" != "xyes"; then
- if test "x$HAVE_PNGLIB_H" != "xtrue"; then
- # restore old flags on failure:
- CPPFLAGS="$saved_CPPFLAGS"
- LDFLAGS="$saved_LDFLAGS"
- fi
- fi
- if test "x$HAVE_PNGLIB_H" != "xtrue"; then
- AC_MSG_WARN([
-==========================================================================
-*** The libpng compression library was not found. ***
-This may lead to reduced performance, especially over slow links.
-If libpng is in a non-standard location use --with-png=DIR to
-indicate the header file is in DIR/include/png.h and the library
-in DIR/lib/libpng.a. A copy of libpng may be obtained from:
-http://www.libpng.org/pub/png/libpng.html
-==========================================================================
-])
- sleep 5
- fi
-fi
-
-AC_ARG_WITH(libz,
-[ --without-libz disable support for deflate],,)
-AC_ARG_WITH(zlib,
-[ --without-zlib disable support for deflate]
-[ --with-zlib=DIR use zlib include/library files in DIR],,)
-
-if test "x$with_zlib" != "xno" -a "x$with_libz" != "xno"; then
- if test ! -z "$with_zlib" -a "x$with_zlib" != "xyes"; then
- saved_CPPFLAGS="$CPPFLAGS"
- saved_LDFLAGS="$LDFLAGS"
- CPPFLAGS="$CPPFLAGS -I$with_zlib/include"
- LDFLAGS="$LDFLAGS -L$with_zlib/lib"
- if test "x$ld_minus_R" = "xno"; then
- :
- elif test "x$GCC" = "xyes"; then
- LDFLAGS="$LDFLAGS -Xlinker -R$with_zlib/lib"
- else
- LDFLAGS="$LDFLAGS -R$with_zlib/lib"
- fi
- fi
- AC_CHECK_HEADER(zlib.h, HAVE_ZLIB_H="true")
- if test "x$HAVE_ZLIB_H" = "xtrue"; then
- AC_CHECK_LIB(z, deflate, , HAVE_ZLIB_H="")
- fi
- if test ! -z "$with_zlib" -a "x$with_zlib" != "xyes"; then
- if test "x$HAVE_ZLIB_H" != "xtrue"; then
- CPPFLAGS="$saved_CPPFLAGS"
- LDFLAGS="$saved_LDFLAGS"
- fi
- fi
- if test "x$HAVE_ZLIB_H" != "xtrue"; then
- AC_MSG_WARN([
-==========================================================================
-*** The libz compression library was not found. ***
-This may lead to reduced performance, especially over slow links.
-If libz is in a non-standard location use --with-zlib=DIR to indicate the
-header file is in DIR/include/zlib.h and the library in DIR/lib/libz.a.
-A copy of libz may be obtained from: http://www.gzip.org/zlib/
-==========================================================================
-])
- sleep 5
- fi
-fi
-
-AC_ARG_WITH(pthread,
-[ --without-pthread disable support for libpthread],,)
-
-if test "x$with_pthread" != "xno"; then
- AC_CHECK_HEADER(pthread.h, HAVE_PTHREAD_H="true")
- if test ! -z "$HAVE_PTHREAD_H"; then
- AC_CHECK_LIB(pthread, pthread_mutex_lock)
- AC_CHECK_LIB(pthread, pthread_mutex_lock, HAVE_LIBPTHREAD="true")
- fi
-fi
-AM_CONDITIONAL(HAVE_LIBPTHREAD, test ! -z "$HAVE_LIBPTHREAD")
-
-AC_MSG_CHECKING([for __thread])
-AC_LINK_IFELSE([AC_LANG_PROGRAM(, [static __thread int p = 0])],
- [AC_DEFINE(HAVE_TLS, 1,
- Define to 1 if compiler supports __thread)
- AC_MSG_RESULT([yes])],
- [AC_MSG_RESULT([no])])
-
-# tightvnc-filetransfer implemented using threads:
-if test -z "$HAVE_LIBPTHREAD"; then
- with_tightvnc_filetransfer=""
-fi
-if test "x$with_tightvnc_filetransfer" = "xyes"; then
- AC_DEFINE(WITH_TIGHTVNC_FILETRANSFER)
-fi
-AM_CONDITIONAL(WITH_TIGHTVNC_FILETRANSFER, test "$with_tightvnc_filetransfer" = "yes")
-
-# websockets implemented using base64 from resolve
-if test "x$HAVE_B64" != "xtrue"; then
- with_websockets=""
-fi
-if test "x$with_websockets" = "xyes"; then
- LIBS="$LIBS $RESOLV_LIB $SSL_LIBS"
- AC_DEFINE(WITH_WEBSOCKETS)
-fi
-AM_CONDITIONAL(WITH_WEBSOCKETS, test "$with_websockets" = "yes")
-
-AM_CONDITIONAL(HAVE_LIBZ, test ! -z "$HAVE_ZLIB_H")
-AM_CONDITIONAL(HAVE_LIBJPEG, test ! -z "$HAVE_JPEGLIB_H")
-AM_CONDITIONAL(HAVE_LIBPNG, test ! -z "$HAVE_PNGLIB_H")
-
-
-SDLCONFIG="sdl-config"
-AC_ARG_WITH(sdl-config,
-[[ --with-sdl-config=FILE
- Use the given path to sdl-config when determining
- SDL configuration; defaults to "sdl-config"]],
-[
- if test "$withval" != "yes" -a "$withval" != ""; then
- SDLCONFIG=$withval
- fi
-])
-
-if test -z "$with_sdl"; then
- if $SDLCONFIG --version >/dev/null 2>&1; then
- with_sdl=yes
- SDL_CFLAGS=`$SDLCONFIG --cflags`
- SDL_LIBS=`$SDLCONFIG --libs`
- else
- with_sdl=no
- fi
-fi
-AM_CONDITIONAL(HAVE_LIBSDL, test "x$with_sdl" = "xyes")
-AC_SUBST(SDL_CFLAGS)
-AC_SUBST(SDL_LIBS)
-
-
-# Check for GTK+. if present, build the GTK+ vnc viewer example
-PKG_CHECK_MODULES([GTK], [gtk+-2.0],,:)
-AM_CONDITIONAL(HAVE_LIBGTK, test ! -z "$GTK_LIBS")
-
-AC_CANONICAL_HOST
-MINGW=`echo $host_os | grep mingw32 2>/dev/null`
-AM_CONDITIONAL(MINGW, test ! -z "$MINGW" )
-if test ! -z "$MINGW"; then
- WSOCKLIB="-lws2_32"
-fi
-AC_SUBST(WSOCKLIB)
-
-# Check for libgcrypt
-AH_TEMPLATE(WITH_CLIENT_GCRYPT, [Enable support for libgcrypt in libvncclient])
-AC_ARG_WITH(gcrypt,
-[ --without-gcrypt disable support for gcrypt],,)
-AC_ARG_WITH(client-gcrypt,
-[ --without-client-gcrypt disable support for gcrypt in libvncclient],,)
-
-if test "x$with_gcrypt" != "xno"; then
- AM_PATH_LIBGCRYPT(1.4.0, , with_client_gcrypt=no)
- CFLAGS="$CFLAGS $LIBGCRYPT_CFLAGS"
- LIBS="$LIBS $LIBGCRYPT_LIBS"
- if test "x$with_client_gcrypt" != "xno"; then
- AC_DEFINE(WITH_CLIENT_GCRYPT)
- fi
-fi
-
-# Checks for GnuTLS
-AH_TEMPLATE(HAVE_GNUTLS, [GnuTLS library present])
-AC_ARG_WITH(gnutls,
-[ --without-gnutls disable support for gnutls]
-[ --with-gnutls=DIR use gnutls include/library files in DIR],,)
-
-if test "x$with_gnutls" != "xno"; then
- PKG_CHECK_MODULES(GNUTLS, gnutls >= 2.4.0,,:)
- CFLAGS="$CFLAGS $GNUTLS_CFLAGS"
- LIBS="$LIBS $GNUTLS_LIBS"
-fi
-AM_CONDITIONAL(HAVE_GNUTLS, test ! -z "$GNUTLS_LIBS")
-if test ! -z "$GNUTLS_LIBS" ; then
- AC_DEFINE(HAVE_GNUTLS)
-fi
-
-
-# warn if neither GnuTLS nor OpenSSL are available
-if test -z "$SSL_LIBS" -a -z "$GNUTLS_LIBS"; then
- AC_MSG_WARN([
-==========================================================================
-*** No encryption library could be found. ***
-A libvncserver/libvncclient built this way will not support SSL encryption.
-To enable SSL install the necessary development packages (perhaps it is named
-something like libssl-dev or gnutls-dev) and run configure again.
-==========================================================================
-])
- sleep 5
-fi
-
-
-# IPv6
-AH_TEMPLATE(IPv6, [Enable IPv6 support])
-AC_ARG_WITH(ipv6,
-[ --without-ipv6 disable IPv6 support],,)
-if test "x$with_ipv6" != "xno"; then
- AC_CHECK_FUNC(getaddrinfo, AC_DEFINE(IPv6,1),
- AC_CHECK_LIB(socket, getaddrinfo, AC_DEFINE(IPv6,1), [
- AC_MSG_CHECKING([for getaddrinfo in -lws2_32])
- LIBS="$LIBS -lws2_32"
- AC_TRY_LINK([#include <ws2tcpip.h>], [getaddrinfo(0, 0, 0, 0);], [
- AC_DEFINE(IPv6,1)
- AC_MSG_RESULT([yes])
- ],
- AC_MSG_RESULT([no]))
- ]))
-fi
-
-
-
-# Checks for header files.
-AC_HEADER_STDC
-AC_CHECK_HEADERS([arpa/inet.h endian.h fcntl.h netdb.h netinet/in.h stdlib.h stdint.h string.h sys/endian.h sys/socket.h sys/time.h sys/timeb.h syslog.h unistd.h ws2tcpip.h])
-
-# Checks for typedefs, structures, and compiler characteristics.
-AC_C_CONST
-AC_C_INLINE
-AC_TYPE_SIZE_T
-AC_HEADER_TIME
-AC_HEADER_SYS_WAIT
-AX_TYPE_SOCKLEN_T
-AC_CACHE_CHECK([for in_addr_t],
- vnc_cv_inaddrt, [
- AC_TRY_COMPILE([#include <sys/types.h>
-#include <netinet/in.h>],
- [in_addr_t foo; return 0;],
- [inaddrt=yes],
- [inaddrt=no]),
- ])
-AH_TEMPLATE(NEED_INADDR_T, [Need a typedef for in_addr_t])
-if test $inaddrt = no ; then
- AC_DEFINE(NEED_INADDR_T)
-fi
-# Checks for library functions.
-AC_FUNC_MEMCMP
-AC_FUNC_STAT
-AC_FUNC_STRFTIME
-AC_FUNC_VPRINTF
-AC_FUNC_FORK
-AC_CHECK_LIB(nsl,gethostbyname)
-AC_CHECK_LIB(socket,socket)
-
-uname_s=`(uname -s) 2>/dev/null`
-if test "x$uname_s" = "xHP-UX"; then
- # need -lsec for getspnam()
- LDFLAGS="$LDFLAGS -lsec"
-fi
-
-AC_CHECK_FUNCS([ftime gethostbyname gethostname gettimeofday inet_ntoa memmove memset mmap mkfifo select socket strchr strcspn strdup strerror strstr])
-
-# check, if shmget is in cygipc.a
-AC_CHECK_LIB(cygipc,shmget)
-AM_CONDITIONAL(CYGIPC, test "$HAVE_CYGIPC" = "true")
-
-# Check if /usr/include/linux exists, if so, define LINUX
-AM_CONDITIONAL(LINUX, test -d /usr/include/linux)
-
-# Check for OS X specific header
-AC_CHECK_HEADER(ApplicationServices/ApplicationServices.h, HAVE_OSX="true")
-AM_CONDITIONAL(OSX, test "$HAVE_OSX" = "true")
-
-# Check for Android specific header
-AC_CHECK_HEADER(android/api-level.h, HAVE_ANDROID="true")
-AM_CONDITIONAL(ANDROID, test "$HAVE_ANDROID" = "true")
-if test "$HAVE_ANDROID" = "true"; then
- AC_DEFINE(HAVE_ANDROID, 1, [Android host system detected])
-fi
-
-# On Solaris 2.7, write() returns ENOENT when it really means EAGAIN
-AH_TEMPLATE(ENOENT_WORKAROUND, [work around when write() returns ENOENT but does not mean it])
-case `(uname -sr) 2>/dev/null` in
- "SunOS 5.7")
- AC_DEFINE(ENOENT_WORKAROUND)
- ;;
-esac
-
-# Check for rpm SOURCES path
-printf "checking for rpm sources path... "
-RPMSOURCEDIR="NOT-FOUND"
-for directory in packages OpenLinux redhat RedHat rpm RPM "" ; do
- if test -d /usr/src/${directory}/SOURCES; then
- RPMSOURCEDIR="/usr/src/${directory}/SOURCES/"
- fi
-done
-echo "$RPMSOURCEDIR"
-AM_CONDITIONAL(HAVE_RPM, test "$RPMSOURCEDIR" != "NOT-FOUND")
-AC_SUBST(RPMSOURCEDIR)
-
-AC_CONFIG_FILES([Makefile
- libvncserver.pc
- libvncclient.pc
- libvncserver/Makefile
- examples/Makefile
- examples/android/Makefile
- webclients/Makefile
- webclients/java-applet/Makefile
- webclients/java-applet/ssl/Makefile
- libvncclient/Makefile
- client_examples/Makefile
- test/Makefile
- libvncserver-config
- LibVNCServer.spec])
-
-
-AC_CONFIG_COMMANDS([chmod-libvncserver-config],[chmod a+x libvncserver-config])
-AC_OUTPUT
-chmod a+x ./libvncserver-config
-
diff --git a/deps/sasl-fix-snprintf-macro.patch b/deps/sasl-fix-snprintf-macro.patch
new file mode 100644
index 0000000..26b5da4
--- /dev/null
+++ b/deps/sasl-fix-snprintf-macro.patch
@@ -0,0 +1,26 @@
+From 310579a87a289588cf8c45587354a90973978510 Mon Sep 17 00:00:00 2001
+From: "Montazeri, Mehrdad" <mmontaze@amazon.com>
+Date: Wed, 31 Jan 2018 09:25:08 -0800
+Subject: [PATCH 2/2] fix snprintf macro
+
+---
+ win32/include/config.h | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/win32/include/config.h b/win32/include/config.h
+index 8d8548e..304a4a9 100644
+--- a/win32/include/config.h
++++ b/win32/include/config.h
+@@ -117,7 +117,9 @@ typedef int intptr_t;
+ /* Windows calls these functions something else
+ */
+ #define strcasecmp stricmp
++#if defined (_MSC_VER) && (_MSC_VER < 1900)
+ #define snprintf _snprintf
++#endif
+ #define strncasecmp strnicmp
+
+ #define MAXHOSTNAMELEN 1024
+--
+2.11.0.windows.3
+
diff --git a/examples/Makefile.am b/examples/Makefile.am
deleted file mode 100644
index 829f735..0000000
--- a/examples/Makefile.am
+++ /dev/null
@@ -1,27 +0,0 @@
-AM_CPPFLAGS = -I$(top_srcdir)
-LDADD = ../libvncserver/libvncserver.la @WSOCKLIB@
-
-if OSX
-MAC=mac
-mac_LDFLAGS=-framework ApplicationServices -framework Carbon -framework IOKit
-endif
-
-if ANDROID
-SUBDIRS=android
-endif
-
-if WITH_TIGHTVNC_FILETRANSFER
-FILETRANSFER=filetransfer
-endif
-
-if HAVE_LIBPTHREAD
-BLOOPTEST=blooptest
-endif
-
-noinst_HEADERS=radon.h rotatetemplate.c
-
-noinst_PROGRAMS=example pnmshow regiontest pnmshow24 fontsel \
- vncev storepasswd colourmaptest simple simple15 $(MAC) \
- $(FILETRANSFER) backchannel $(BLOOPTEST) camera rotate \
- zippy repeater
-
diff --git a/examples/android/Makefile.am b/examples/android/Makefile.am
deleted file mode 100644
index 9cb5c02..0000000
--- a/examples/android/Makefile.am
+++ /dev/null
@@ -1,7 +0,0 @@
-AM_CPPFLAGS = -I$(top_srcdir)
-LDADD = $(top_srcdir)/libvncserver/libvncserver.la @WSOCKLIB@
-
-noinst_PROGRAMS=androidvncserver
-androidvncserver_SOURCES=jni/fbvncserver.c
-
-EXTRA_DIST=jni/Android.mk
diff --git a/examples/android/README b/examples/android/README
deleted file mode 100644
index 57e14cf..0000000
--- a/examples/android/README
+++ /dev/null
@@ -1,63 +0,0 @@
-
-This example VNC server for Android is adopted from
-http://code.google.com/p/android-vnc-server/ with some additional
-fixes applied.
-
-To build, you'll need the Android Native Development Kit from
-http://developer.android.com/sdk/ndk/.
-
-
-Building with autotools
------------------------
-
-This has the advantage that the LibVNCServer sources are properly set up
-using the configure script.
-
-1. Read <NDK location>/docs/STANDALONE-TOOLCHAIN.html.
-
-2. Setup your toolchain according to step 3 in the above file.
-
-3. Execute
-
- ./configure --host=arm-eabi CC=arm-linux-androideabi-gcc
-
- in the LibVNCServer root directory.
-
-4. Execute
-
- make
-
- in the LibVNCServer root directory. This will build the whole
- LibVNCServer distribution for Android, including androidvncserver.
-
-
-
-
-Building with the NDK build system
-----------------------------------
-
-This is probably easier than the autotools method, but you'll have to edit
-some files manually.
-
-1. Edit rfb/rfbconfig.h to match your Android target. For instance, comment out
- LIBVNCSERVER_HAVE_LIBJPEG if you don't have libjpeg for Android.
-
-2. Edit the HAVE_X variables in jni/Android.mk accordingly.
-
-3. Execute
-
- ndk-build -C .
-
- in the examples/android directory. The resulting binary will be in libs/.
-
-
-
-Installing && Running
----------------------
-
-This can be done via
-
- adb push androidvncserver /data/local/
- adb shell /data/local/androidvncserver
-
-
diff --git a/examples/android/jni/Android.mk b/examples/android/jni/Android.mk
deleted file mode 100644
index 731a790..0000000
--- a/examples/android/jni/Android.mk
+++ /dev/null
@@ -1,65 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LIBVNCSERVER_ROOT:=../../..
-
-HAVE_LIBZ=1
-#HAVE_LIBJPEG=1
-
-ifdef HAVE_LIBZ
-ZLIBSRCS := \
- $(LIBVNCSERVER_ROOT)/libvncserver/zlib.c \
- $(LIBVNCSERVER_ROOT)/libvncserver/zrle.c \
- $(LIBVNCSERVER_ROOT)/libvncserver/zrleoutstream.c \
- $(LIBVNCSERVER_ROOT)/libvncserver/zrlepalettehelper.c \
- $(LIBVNCSERVER_ROOT)/common/zywrletemplate.c
-ifdef HAVE_LIBJPEG
-TIGHTSRCS := $(LIBVNCSERVER_ROOT)/libvncserver/tight.c
-endif
-endif
-
-LOCAL_SRC_FILES:= \
- fbvncserver.c \
- $(LIBVNCSERVER_ROOT)/libvncserver/main.c \
- $(LIBVNCSERVER_ROOT)/libvncserver/rfbserver.c \
- $(LIBVNCSERVER_ROOT)/libvncserver/rfbregion.c \
- $(LIBVNCSERVER_ROOT)/libvncserver/auth.c \
- $(LIBVNCSERVER_ROOT)/libvncserver/sockets.c \
- $(LIBVNCSERVER_ROOT)/libvncserver/stats.c \
- $(LIBVNCSERVER_ROOT)/libvncserver/corre.c \
- $(LIBVNCSERVER_ROOT)/libvncserver/hextile.c \
- $(LIBVNCSERVER_ROOT)/libvncserver/rre.c \
- $(LIBVNCSERVER_ROOT)/libvncserver/translate.c \
- $(LIBVNCSERVER_ROOT)/libvncserver/cutpaste.c \
- $(LIBVNCSERVER_ROOT)/libvncserver/httpd.c \
- $(LIBVNCSERVER_ROOT)/libvncserver/cursor.c \
- $(LIBVNCSERVER_ROOT)/libvncserver/font.c \
- $(LIBVNCSERVER_ROOT)/libvncserver/draw.c \
- $(LIBVNCSERVER_ROOT)/libvncserver/selbox.c \
- $(LIBVNCSERVER_ROOT)/common/d3des.c \
- $(LIBVNCSERVER_ROOT)/common/vncauth.c \
- $(LIBVNCSERVER_ROOT)/libvncserver/cargs.c \
- $(LIBVNCSERVER_ROOT)/common/minilzo.c \
- $(LIBVNCSERVER_ROOT)/libvncserver/ultra.c \
- $(LIBVNCSERVER_ROOT)/libvncserver/scale.c \
- $(ZLIBSRCS) \
- $(TIGHTSRCS)
-
-LOCAL_C_INCLUDES := \
- $(LOCAL_PATH) \
- $(LOCAL_PATH)/$(LIBVNCSERVER_ROOT)/libvncserver \
- $(LOCAL_PATH)/$(LIBVNCSERVER_ROOT)/common \
- $(LOCAL_PATH)/$(LIBVNCSERVER_ROOT) \
- external/jpeg
-
-ifdef HAVE_LIBZ
-LOCAL_SHARED_LIBRARIES := libz
-LOCAL_LDLIBS := -lz
-endif
-ifdef HAVE_LIBJPEG
-LOCAL_STATIC_LIBRARIES := libjpeg
-endif
-
-LOCAL_MODULE:= androidvncserver
-
-include $(BUILD_EXECUTABLE)
diff --git a/examples/android/jni/fbvncserver.c b/examples/androidvncserver.c
index a8c4827..885a7ef 100644
--- a/examples/android/jni/fbvncserver.c
+++ b/examples/androidvncserver.c
@@ -1,5 +1,10 @@
/*
- * $Id$
+ * This example VNC server for Android is adopted from
+ * http://code.google.com/p/android-vnc-server/ with some additional
+ * fixes applied.
+ *
+ * To build, you'll need the Android Native Development Kit from
+ * http://developer.android.com/sdk/ndk/.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
@@ -243,7 +248,7 @@ static int keysym2scancode(rfbBool down, rfbKeySym key, rfbClientPtr cl)
} else if (code>=0xFF50 && code<=0xFF58) {
static const uint16_t map[] =
{ KEY_HOME, KEY_LEFT, KEY_UP, KEY_RIGHT, KEY_DOWN,
- KEY_SOFT1, KEY_SOFT2, KEY_END, 0 };
+ KEY_END, 0 };
scancode = map[code & 0xF];
} else if (code>=0xFFE1 && code<=0xFFEE) {
static const uint16_t map[] =
@@ -264,10 +269,7 @@ static int keysym2scancode(rfbBool down, rfbKeySym key, rfbClientPtr cl)
scancode = map[(code & 0x5F) - 'A'];
} else {
switch (code) {
- case 0x0003: scancode = KEY_CENTER; break;
case 0x0020: scancode = KEY_SPACE; break;
- case 0x0023: scancode = KEY_SHARP; break;
- case 0x0033: scancode = KEY_SHARP; break;
case 0x002C: scancode = KEY_COMMA; break;
case 0x003C: scancode = KEY_COMMA; break;
case 0x002E: scancode = KEY_DOT; break;
@@ -280,7 +282,6 @@ static int keysym2scancode(rfbBool down, rfbKeySym key, rfbClientPtr cl)
case 0xFF1B: scancode = KEY_BACK; break;
case 0xFF09: scancode = KEY_TAB; break;
case 0xFF0D: scancode = KEY_ENTER; break;
- case 0x002A: scancode = KEY_STAR; break;
case 0xFFBE: scancode = KEY_F1; break; // F1
case 0xFFBF: scancode = KEY_F2; break; // F2
case 0xFFC0: scancode = KEY_F3; break; // F3
@@ -459,7 +460,7 @@ void print_usage(char **argv)
printf("%s [-k device] [-t device] [-h]\n"
"-k device: keyboard device node, default is /dev/input/event3\n"
"-t device: touch device node, default is /dev/input/event1\n"
- "-h : print this help\n");
+ "-h : print this help\n", argv[0]);
}
int main(int argc, char **argv)
@@ -517,6 +518,6 @@ int main(int argc, char **argv)
printf("Cleaning up...\n");
cleanup_fb();
- cleanup_kdb();
+ cleanup_kbd();
cleanup_touch();
}
diff --git a/examples/repeater.c b/examples/repeater.c
index cf0350f..dbfa39e 100644
--- a/examples/repeater.c
+++ b/examples/repeater.c
@@ -12,6 +12,7 @@ int main(int argc,char** argv)
char *repeaterHost;
int repeaterPort, sock;
char id[250];
+ int idlen;
rfbClientPtr cl;
int i,j;
@@ -23,7 +24,12 @@ int main(int argc,char** argv)
"Usage: %s <id> <repeater-host> [<repeater-port>]\n", argv[0]);
exit(1);
}
- snprintf(id, sizeof(id) - 1, "ID:%s", argv[1]);
+ idlen = snprintf(id, sizeof(id) - 1, "ID:%s", argv[1]);
+ if(idlen < 0 || idlen >= (int)sizeof(id)) {
+ fprintf(stderr, "Error, given ID is probably too long.\n");
+ return 1;
+ }
+
repeaterHost = argv[2];
repeaterPort = argc < 4 ? 5500 : atoi(argv[3]);
@@ -48,7 +54,7 @@ int main(int argc,char** argv)
perror("connect to repeater");
return 1;
}
- if (write(sock, id, sizeof(id)) != sizeof(id)) {
+ if (write(sock, id, idlen+1) != idlen+1) {
perror("writing id");
return 1;
}
diff --git a/examples/vncev.c b/examples/vncev.c
index a8e0884..4051d2b 100644
--- a/examples/vncev.c
+++ b/examples/vncev.c
@@ -2,10 +2,14 @@
* @example vncev.c
* This program is a simple server to show events coming from the client
*/
+#ifdef __STRICT_ANSI__
+#define _BSD_SOURCE
+#endif
+#include <rfb/rfbconfig.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
-#ifndef __MINGW32__
+#if LIBVNCSERVER_HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
#include <rfb/rfb.h>
diff --git a/libvncclient.pc.cmakein b/libvncclient.pc.cmakein
new file mode 100644
index 0000000..169a8b7
--- /dev/null
+++ b/libvncclient.pc.cmakein
@@ -0,0 +1,14 @@
+prefix=@CMAKE_INSTALL_PREFIX@
+exec_prefix=@CMAKE_INSTALL_PREFIX@
+libdir=@CMAKE_INSTALL_PREFIX@/lib
+includedir=@CMAKE_INSTALL_PREFIX@/include
+
+Name: LibVNCClient
+Description: A library for easy implementation of a VNC client.
+Version: @PACKAGE_VERSION@
+Requires:
+Requires.private: zlib
+Libs: -L${libdir} -lvncclient
+Libs.private: @PRIVATE_LIBS@
+Cflags: -I${includedir}
+
diff --git a/libvncclient.pc.in b/libvncclient.pc.in
deleted file mode 100644
index 37495e7..0000000
--- a/libvncclient.pc.in
+++ /dev/null
@@ -1,14 +0,0 @@
-prefix=@prefix@
-exec_prefix=@exec_prefix@
-libdir=@libdir@
-includedir=@includedir@
-
-Name: LibVNCClient
-Description: A library for easy implementation of a VNC client.
-Version: @VERSION@
-Requires:
-Requires.private: zlib
-Libs: -L${libdir} -lvncclient
-Libs.private: @LIBS@ @WSOCKLIB@
-Cflags: -I${includedir}
-
diff --git a/libvncclient/Makefile.am b/libvncclient/Makefile.am
deleted file mode 100644
index bc2420b..0000000
--- a/libvncclient/Makefile.am
+++ /dev/null
@@ -1,29 +0,0 @@
-AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/common
-
-if HAVE_GNUTLS
-TLSSRCS = tls_gnutls.c
-TLSLIBS = @GNUTLS_LIBS@
-else
-if HAVE_LIBSSL
-TLSSRCS = tls_openssl.c
-TLSLIBS = @SSL_LIBS@ @CRYPT_LIBS@
-else
-TLSSRCS = tls_none.c
-endif
-endif
-
-
-libvncclient_la_SOURCES=cursor.c listen.c rfbproto.c sockets.c vncviewer.c ../common/minilzo.c $(TLSSRCS)
-libvncclient_la_LIBADD=$(TLSLIBS)
-
-noinst_HEADERS=../common/lzodefs.h ../common/lzoconf.h ../common/minilzo.h tls.h
-
-rfbproto.o: rfbproto.c corre.c hextile.c rre.c tight.c zlib.c zrle.c ultra.c
-
-EXTRA_DIST=corre.c hextile.c rre.c tight.c zlib.c zrle.c ultra.c tls_gnutls.c tls_openssl.c tls_none.c
-
-$(libvncclient_la_OBJECTS): ../rfb/rfbclient.h
-
-lib_LTLIBRARIES=libvncclient.la
-libvncclient_la_LDFLAGS = -version-info 1:0:0
-
diff --git a/libvncclient/corre.c b/libvncclient/corre.c
index baf91cc..cbc986a 100644
--- a/libvncclient/corre.c
+++ b/libvncclient/corre.c
@@ -46,9 +46,9 @@ HandleCoRREBPP (rfbClient* client, int rx, int ry, int rw, int rh)
if (!ReadFromRFBServer(client, (char *)&pix, sizeof(pix)))
return FALSE;
- FillRectangle(client, rx, ry, rw, rh, pix);
+ client->GotFillRect(client, rx, ry, rw, rh, pix);
- if (!ReadFromRFBServer(client, client->buffer, hdr.nSubrects * (4 + (BPP / 8))))
+ if (hdr.nSubrects > RFB_BUFFER_SIZE / (4 + (BPP / 8)) || !ReadFromRFBServer(client, client->buffer, hdr.nSubrects * (4 + (BPP / 8))))
return FALSE;
ptr = (uint8_t *)client->buffer;
@@ -61,7 +61,7 @@ HandleCoRREBPP (rfbClient* client, int rx, int ry, int rw, int rh)
w = *ptr++;
h = *ptr++;
- FillRectangle(client, rx+x, ry+y, w, h, pix);
+ client->GotFillRect(client, rx+x, ry+y, w, h, pix);
}
return TRUE;
diff --git a/libvncclient/hextile.c b/libvncclient/hextile.c
index 8698445..05a7cf5 100644
--- a/libvncclient/hextile.c
+++ b/libvncclient/hextile.c
@@ -55,7 +55,7 @@ HandleHextileBPP (rfbClient* client, int rx, int ry, int rw, int rh)
if (!ReadFromRFBServer(client, client->buffer, w * h * (BPP / 8)))
return FALSE;
- CopyRectangle(client, (uint8_t *)client->buffer, x, y, w, h);
+ client->GotBitmap(client, (uint8_t *)client->buffer, x, y, w, h);
continue;
}
@@ -64,7 +64,7 @@ HandleHextileBPP (rfbClient* client, int rx, int ry, int rw, int rh)
if (!ReadFromRFBServer(client, (char *)&bg, sizeof(bg)))
return FALSE;
- FillRectangle(client, x, y, w, h, bg);
+ client->GotFillRect(client, x, y, w, h, bg);
if (subencoding & rfbHextileForegroundSpecified)
if (!ReadFromRFBServer(client, (char *)&fg, sizeof(fg)))
@@ -100,7 +100,7 @@ HandleHextileBPP (rfbClient* client, int rx, int ry, int rw, int rh)
sh = rfbHextileExtractH(*ptr);
ptr++;
- FillRectangle(client, x+sx, y+sy, sw, sh, fg);
+ client->GotFillRect(client, x+sx, y+sy, sw, sh, fg);
}
} else {
@@ -115,7 +115,7 @@ HandleHextileBPP (rfbClient* client, int rx, int ry, int rw, int rh)
sh = rfbHextileExtractH(*ptr);
ptr++;
- FillRectangle(client, x+sx, y+sy, sw, sh, fg);
+ client->GotFillRect(client, x+sx, y+sy, sw, sh, fg);
}
}
}
diff --git a/libvncclient/listen.c b/libvncclient/listen.c
index 37def52..4ecedff 100644
--- a/libvncclient/listen.c
+++ b/libvncclient/listen.c
@@ -22,7 +22,12 @@
* listen.c - listen for incoming connections
*/
+#ifdef __STRICT_ANSI__
+#define _BSD_SOURCE
+#endif
+#if LIBVNCSERVER_HAVE_UNISTD_H
#include <unistd.h>
+#endif
#include <sys/types.h>
#ifdef WIN32
#define close closesocket
@@ -31,7 +36,9 @@
#include <sys/wait.h>
#include <sys/utsname.h>
#endif
+#if LIBVNCSERVER_HAVE_SYS_TIME_H
#include <sys/time.h>
+#endif
#include <rfb/rfbclient.h>
/*
@@ -82,7 +89,7 @@ listenForIncomingConnections(rfbClient* client)
int r;
/* reap any zombies */
int status, pid;
- while ((pid= wait3(&status, WNOHANG, (struct rusage *)0))>0);
+ while ((pid= wait4(-1, &status, WNOHANG, (struct rusage *)0))>0);
/* TODO: callback for discard any events (like X11 events) */
diff --git a/libvncclient/rfbproto.c b/libvncclient/rfbproto.c
index 44d0a46..267c1c5 100644
--- a/libvncclient/rfbproto.c
+++ b/libvncclient/rfbproto.c
@@ -42,12 +42,6 @@
#define Z_NULL NULL
#endif
#endif
-#ifdef LIBVNCSERVER_HAVE_LIBJPEG
-#ifdef _RPCNDR_H /* This Windows header typedefs 'boolean', jpeglib has to know */
-#define HAVE_BOOLEAN
-#endif
-#include <jpeglib.h>
-#endif
#ifndef _MSC_VER
/* Strings.h is not available in MSVC */
@@ -61,7 +55,12 @@
#include <gcrypt.h>
#endif
+#include "sasl.h"
+#ifdef LIBVNCSERVER_HAVE_LZO
+#include <lzo/lzo1x.h>
+#else
#include "minilzo.h"
+#endif
#include "tls.h"
#ifdef _MSC_VER
@@ -140,125 +139,6 @@ void* rfbClientGetClientData(rfbClient* client, void* tag)
return NULL;
}
-/* messages */
-
-static rfbBool CheckRect(rfbClient* client, int x, int y, int w, int h) {
- return x + w <= client->width && y + h <= client->height;
-}
-
-static void FillRectangle(rfbClient* client, int x, int y, int w, int h, uint32_t colour) {
- int i,j;
-
- if (client->frameBuffer == NULL) {
- return;
- }
-
- if (!CheckRect(client, x, y, w, h)) {
- rfbClientLog("Rect out of bounds: %dx%d at (%d, %d)\n", x, y, w, h);
- return;
- }
-
-#define FILL_RECT(BPP) \
- for(j=y*client->width;j<(y+h)*client->width;j+=client->width) \
- for(i=x;i<x+w;i++) \
- ((uint##BPP##_t*)client->frameBuffer)[j+i]=colour;
-
- switch(client->format.bitsPerPixel) {
- case 8: FILL_RECT(8); break;
- case 16: FILL_RECT(16); break;
- case 32: FILL_RECT(32); break;
- default:
- rfbClientLog("Unsupported bitsPerPixel: %d\n",client->format.bitsPerPixel);
- }
-}
-
-static void CopyRectangle(rfbClient* client, uint8_t* buffer, int x, int y, int w, int h) {
- int j;
-
- if (client->frameBuffer == NULL) {
- return;
- }
-
- if (!CheckRect(client, x, y, w, h)) {
- rfbClientLog("Rect out of bounds: %dx%d at (%d, %d)\n", x, y, w, h);
- return;
- }
-
-#define COPY_RECT(BPP) \
- { \
- int rs = w * BPP / 8, rs2 = client->width * BPP / 8; \
- for (j = ((x * (BPP / 8)) + (y * rs2)); j < (y + h) * rs2; j += rs2) { \
- memcpy(client->frameBuffer + j, buffer, rs); \
- buffer += rs; \
- } \
- }
-
- switch(client->format.bitsPerPixel) {
- case 8: COPY_RECT(8); break;
- case 16: COPY_RECT(16); break;
- case 32: COPY_RECT(32); break;
- default:
- rfbClientLog("Unsupported bitsPerPixel: %d\n",client->format.bitsPerPixel);
- }
-}
-
-/* TODO: test */
-static void CopyRectangleFromRectangle(rfbClient* client, int src_x, int src_y, int w, int h, int dest_x, int dest_y) {
- int i,j;
-
- if (client->frameBuffer == NULL) {
- return;
- }
-
- if (!CheckRect(client, src_x, src_y, w, h)) {
- rfbClientLog("Source rect out of bounds: %dx%d at (%d, %d)\n", src_x, src_y, w, h);
- return;
- }
-
- if (!CheckRect(client, dest_x, dest_y, w, h)) {
- rfbClientLog("Dest rect out of bounds: %dx%d at (%d, %d)\n", dest_x, dest_y, w, h);
- return;
- }
-
-#define COPY_RECT_FROM_RECT(BPP) \
- { \
- uint##BPP##_t* _buffer=((uint##BPP##_t*)client->frameBuffer)+(src_y-dest_y)*client->width+src_x-dest_x; \
- if (dest_y < src_y) { \
- for(j = dest_y*client->width; j < (dest_y+h)*client->width; j += client->width) { \
- if (dest_x < src_x) { \
- for(i = dest_x; i < dest_x+w; i++) { \
- ((uint##BPP##_t*)client->frameBuffer)[j+i]=_buffer[j+i]; \
- } \
- } else { \
- for(i = dest_x+w-1; i >= dest_x; i--) { \
- ((uint##BPP##_t*)client->frameBuffer)[j+i]=_buffer[j+i]; \
- } \
- } \
- } \
- } else { \
- for(j = (dest_y+h-1)*client->width; j >= dest_y*client->width; j-=client->width) { \
- if (dest_x < src_x) { \
- for(i = dest_x; i < dest_x+w; i++) { \
- ((uint##BPP##_t*)client->frameBuffer)[j+i]=_buffer[j+i]; \
- } \
- } else { \
- for(i = dest_x+w-1; i >= dest_x; i--) { \
- ((uint##BPP##_t*)client->frameBuffer)[j+i]=_buffer[j+i]; \
- } \
- } \
- } \
- } \
- }
-
- switch(client->format.bitsPerPixel) {
- case 8: COPY_RECT_FROM_RECT(8); break;
- case 16: COPY_RECT_FROM_RECT(16); break;
- case 32: COPY_RECT_FROM_RECT(32); break;
- default:
- rfbClientLog("Unsupported bitsPerPixel: %d\n",client->format.bitsPerPixel);
- }
-}
-
static rfbBool HandleRRE8(rfbClient* client, int rx, int ry, int rw, int rh);
static rfbBool HandleRRE16(rfbClient* client, int rx, int ry, int rw, int rh);
static rfbBool HandleRRE32(rfbClient* client, int rx, int ry, int rw, int rh);
@@ -274,6 +154,13 @@ static rfbBool HandleUltra32(rfbClient* client, int rx, int ry, int rw, int rh);
static rfbBool HandleUltraZip8(rfbClient* client, int rx, int ry, int rw, int rh);
static rfbBool HandleUltraZip16(rfbClient* client, int rx, int ry, int rw, int rh);
static rfbBool HandleUltraZip32(rfbClient* client, int rx, int ry, int rw, int rh);
+static rfbBool HandleTRLE8(rfbClient* client, int rx, int ry, int rw, int rh);
+static rfbBool HandleTRLE15(rfbClient* client, int rx, int ry, int rw, int rh);
+static rfbBool HandleTRLE16(rfbClient* client, int rx, int ry, int rw, int rh);
+static rfbBool HandleTRLE24(rfbClient* client, int rx, int ry, int rw, int rh);
+static rfbBool HandleTRLE24Up(rfbClient* client, int rx, int ry, int rw, int rh);
+static rfbBool HandleTRLE24Down(rfbClient* client, int rx, int ry, int rw, int rh);
+static rfbBool HandleTRLE32(rfbClient* client, int rx, int ry, int rw, int rh);
#ifdef LIBVNCSERVER_HAVE_LIBZ
static rfbBool HandleZlib8(rfbClient* client, int rx, int ry, int rw, int rh);
static rfbBool HandleZlib16(rfbClient* client, int rx, int ry, int rw, int rh);
@@ -284,13 +171,6 @@ static rfbBool HandleTight16(rfbClient* client, int rx, int ry, int rw, int rh);
static rfbBool HandleTight32(rfbClient* client, int rx, int ry, int rw, int rh);
static long ReadCompactLen (rfbClient* client);
-
-static void JpegInitSource(j_decompress_ptr cinfo);
-static boolean JpegFillInputBuffer(j_decompress_ptr cinfo);
-static void JpegSkipInputData(j_decompress_ptr cinfo, long num_bytes);
-static void JpegTermSource(j_decompress_ptr cinfo);
-static void JpegSetSrcManager(j_decompress_ptr cinfo, uint8_t *compressedData,
- int compressedLen);
#endif
static rfbBool HandleZRLE8(rfbClient* client, int rx, int ry, int rw, int rh);
static rfbBool HandleZRLE15(rfbClient* client, int rx, int ry, int rw, int rh);
@@ -486,6 +366,7 @@ rfbBool ConnectToRFBRepeater(rfbClient* client,const char *repeaterHost, int rep
rfbProtocolVersionMsg pv;
int major,minor;
char tmphost[250];
+ int tmphostlen;
#ifdef LIBVNCSERVER_IPv6
client->sock = ConnectClientToTcpAddr6(repeaterHost, repeaterPort);
@@ -521,8 +402,11 @@ rfbBool ConnectToRFBRepeater(rfbClient* client,const char *repeaterHost, int rep
rfbClientLog("Connected to VNC repeater, using protocol version %d.%d\n", major, minor);
- snprintf(tmphost, sizeof(tmphost), "%s:%d", destHost, destPort);
- if (!WriteToRFBServer(client, tmphost, sizeof(tmphost)))
+ tmphostlen = snprintf(tmphost, sizeof(tmphost), "%s:%d", destHost, destPort);
+ if(tmphostlen < 0 || tmphostlen >= (int)sizeof(tmphost))
+ return FALSE; /* snprintf error or output truncated */
+
+ if (!WriteToRFBServer(client, tmphost, tmphostlen + 1))
return FALSE;
return TRUE;
@@ -531,11 +415,29 @@ rfbBool ConnectToRFBRepeater(rfbClient* client,const char *repeaterHost, int rep
extern void rfbClientEncryptBytes(unsigned char* bytes, char* passwd);
extern void rfbClientEncryptBytes2(unsigned char *where, const int length, unsigned char *key);
+static void
+ReadReason(rfbClient* client)
+{
+ uint32_t reasonLen;
+ char *reason;
+
+ if (!ReadFromRFBServer(client, (char *)&reasonLen, 4)) return;
+ reasonLen = rfbClientSwap32IfLE(reasonLen);
+ if(reasonLen > 1<<20) {
+ rfbClientLog("VNC connection failed, but sent reason length of %u exceeds limit of 1MB",(unsigned int)reasonLen);
+ return;
+ }
+ reason = malloc(reasonLen+1);
+ if (!ReadFromRFBServer(client, reason, reasonLen)) { free(reason); return; }
+ reason[reasonLen]=0;
+ rfbClientLog("VNC connection failed: %s\n",reason);
+ free(reason);
+}
+
rfbBool
rfbHandleAuthResult(rfbClient* client)
{
- uint32_t authResult=0, reasonLen=0;
- char *reason=NULL;
+ uint32_t authResult=0;
if (!ReadFromRFBServer(client, (char *)&authResult, 4)) return FALSE;
@@ -553,13 +455,7 @@ rfbHandleAuthResult(rfbClient* client)
if (client->major==3 && client->minor>7)
{
/* we have an error following */
- if (!ReadFromRFBServer(client, (char *)&reasonLen, 4)) return FALSE;
- reasonLen = rfbClientSwap32IfLE(reasonLen);
- reason = malloc(reasonLen+1);
- if (!ReadFromRFBServer(client, reason, reasonLen)) { free(reason); return FALSE; }
- reason[reasonLen]=0;
- rfbClientLog("VNC connection failed: %s\n",reason);
- free(reason);
+ ReadReason(client);
return FALSE;
}
rfbClientLog("VNC authentication failed\n");
@@ -574,21 +470,6 @@ rfbHandleAuthResult(rfbClient* client)
return FALSE;
}
-static void
-ReadReason(rfbClient* client)
-{
- uint32_t reasonLen;
- char *reason;
-
- /* we have an error following */
- if (!ReadFromRFBServer(client, (char *)&reasonLen, 4)) return;
- reasonLen = rfbClientSwap32IfLE(reasonLen);
- reason = malloc(reasonLen+1);
- if (!ReadFromRFBServer(client, reason, reasonLen)) { free(reason); return; }
- reason[reasonLen]=0;
- rfbClientLog("VNC connection failed: %s\n",reason);
- free(reason);
-}
static rfbBool
ReadSupportedSecurityType(rfbClient* client, uint32_t *result, rfbBool subAuth)
@@ -596,9 +477,11 @@ ReadSupportedSecurityType(rfbClient* client, uint32_t *result, rfbBool subAuth)
uint8_t count=0;
uint8_t loop=0;
uint8_t flag=0;
+ rfbBool extAuthHandler;
uint8_t tAuth[256];
char buf1[500],buf2[10];
uint32_t authScheme;
+ rfbClientProtocolExtension* e;
if (!ReadFromRFBServer(client, (char *)&count, 1)) return FALSE;
@@ -617,10 +500,24 @@ ReadSupportedSecurityType(rfbClient* client, uint32_t *result, rfbBool subAuth)
if (!ReadFromRFBServer(client, (char *)&tAuth[loop], 1)) return FALSE;
rfbClientLog("%d) Received security type %d\n", loop, tAuth[loop]);
if (flag) continue;
+ extAuthHandler=FALSE;
+ for (e = rfbClientExtensions; e; e = e->next) {
+ if (!e->handleAuthentication) continue;
+ uint32_t const* secType;
+ for (secType = e->securityTypes; secType && *secType; secType++) {
+ if (tAuth[loop]==*secType) {
+ extAuthHandler=TRUE;
+ }
+ }
+ }
if (tAuth[loop]==rfbVncAuth || tAuth[loop]==rfbNoAuth ||
+ extAuthHandler ||
#if defined(LIBVNCSERVER_HAVE_GNUTLS) || defined(LIBVNCSERVER_HAVE_LIBSSL)
tAuth[loop]==rfbVeNCrypt ||
#endif
+#ifdef LIBVNCSERVER_HAVE_SASL
+ tAuth[loop]==rfbSASL ||
+#endif /* LIBVNCSERVER_HAVE_SASL */
(tAuth[loop]==rfbARD && client->GetCredential) ||
(!subAuth && (tAuth[loop]==rfbTLS || (tAuth[loop]==rfbVeNCrypt && client->GetCredential))))
{
@@ -1228,6 +1125,12 @@ InitialiseRFBConnection(rfbClient* client)
if (!HandleVncAuth(client)) return FALSE;
break;
+#ifdef LIBVNCSERVER_HAVE_SASL
+ case rfbSASL:
+ if (!HandleSASLAuth(client)) return FALSE;
+ break;
+#endif /* LIBVNCSERVER_HAVE_SASL */
+
case rfbMSLogon:
if (!HandleMSLogonAuth(client)) return FALSE;
break;
@@ -1266,6 +1169,12 @@ InitialiseRFBConnection(rfbClient* client)
if (!HandleVncAuth(client)) return FALSE;
break;
+#ifdef LIBVNCSERVER_HAVE_SASL
+ case rfbSASL:
+ if (!HandleSASLAuth(client)) return FALSE;
+ break;
+#endif /* LIBVNCSERVER_HAVE_SASL */
+
default:
rfbClientLog("Unknown sub authentication scheme from VNC server: %d\n",
(int)subAuthScheme);
@@ -1295,6 +1204,13 @@ InitialiseRFBConnection(rfbClient* client)
if (!HandlePlainAuth(client)) return FALSE;
break;
+#ifdef LIBVNCSERVER_HAVE_SASL
+ case rfbVeNCryptX509SASL:
+ case rfbVeNCryptTLSSASL:
+ if (!HandleSASLAuth(client)) return FALSE;
+ break;
+#endif /* LIBVNCSERVER_HAVE_SASL */
+
default:
rfbClientLog("Unknown sub authentication scheme from VNC server: %d\n",
client->subAuthScheme);
@@ -1304,6 +1220,22 @@ InitialiseRFBConnection(rfbClient* client)
break;
default:
+ {
+ rfbBool authHandled=FALSE;
+ rfbClientProtocolExtension* e;
+ for (e = rfbClientExtensions; e; e = e->next) {
+ uint32_t const* secType;
+ if (!e->handleAuthentication) continue;
+ for (secType = e->securityTypes; secType && *secType; secType++) {
+ if (authScheme==*secType) {
+ if (!e->handleAuthentication(client, authScheme)) return FALSE;
+ if (!rfbHandleAuthResult(client)) return FALSE;
+ authHandled=TRUE;
+ }
+ }
+ }
+ if (authHandled) break;
+ }
rfbClientLog("Unknown authentication scheme from VNC server: %d\n",
(int)authScheme);
return FALSE;
@@ -1322,8 +1254,12 @@ InitialiseRFBConnection(rfbClient* client)
client->si.format.blueMax = rfbClientSwap16IfLE(client->si.format.blueMax);
client->si.nameLength = rfbClientSwap32IfLE(client->si.nameLength);
- /* To guard against integer wrap-around, si.nameLength is cast to 64 bit */
- client->desktopName = malloc((uint64_t)client->si.nameLength + 1);
+ if (client->si.nameLength > 1<<20) {
+ rfbClientErr("Too big desktop name length sent by server: %u B > 1 MB\n", (unsigned int)client->si.nameLength);
+ return FALSE;
+ }
+
+ client->desktopName = malloc(client->si.nameLength + 1);
if (!client->desktopName) {
rfbClientLog("Error allocating memory for desktop name, %lu bytes\n",
(unsigned long)client->si.nameLength);
@@ -1381,6 +1317,7 @@ SetFormatAndEncodings(rfbClient* client)
if (!SupportsClient2Server(client, rfbSetEncodings)) return TRUE;
se->type = rfbSetEncodings;
+ se->pad = 0;
se->nEncodings = 0;
if (client->appData.encodingsString) {
@@ -1421,6 +1358,8 @@ SetFormatAndEncodings(rfbClient* client)
encs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingZlibHex);
if (client->appData.compressLevel >= 0 && client->appData.compressLevel <= 9)
requestCompressLevel = TRUE;
+ } else if (strncasecmp(encStr,"trle",encStrLen) == 0) {
+ encs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingTRLE);
} else if (strncasecmp(encStr,"zrle",encStrLen) == 0) {
encs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingZRLE);
} else if (strncasecmp(encStr,"zywrle",encStrLen) == 0) {
@@ -1769,6 +1708,7 @@ SendKeyEvent(rfbClient* client, uint32_t key, rfbBool down)
if (!SupportsClient2Server(client, rfbKeyEvent)) return TRUE;
+ memset(&ke, 0, sizeof(ke));
ke.type = rfbKeyEvent;
ke.down = down ? 1 : 0;
ke.key = rfbClientSwap32IfLE(key);
@@ -1787,6 +1727,7 @@ SendClientCutText(rfbClient* client, char *str, int len)
if (!SupportsClient2Server(client, rfbClientCutText)) return TRUE;
+ memset(&cct, 0, sizeof(cct));
cct.type = rfbClientCutText;
cct.length = rfbClientSwap32IfLE(len);
return (WriteToRFBServer(client, (char *)&cct, sz_rfbClientCutTextMsg) &&
@@ -2003,14 +1944,14 @@ HandleRFBServerMessage(rfbClient* client)
/* Regardless of cause, do not divide by zero. */
linesToRead = bytesPerLine ? (RFB_BUFFER_SIZE / bytesPerLine) : 0;
- while (h > 0) {
+ while (linesToRead && h > 0) {
if (linesToRead > h)
linesToRead = h;
if (!ReadFromRFBServer(client, client->buffer,bytesPerLine * linesToRead))
return FALSE;
- CopyRectangle(client, (uint8_t *)client->buffer,
+ client->GotBitmap(client, (uint8_t *)client->buffer,
rect.r.x, y, rect.r.w,linesToRead);
h -= linesToRead;
@@ -2036,13 +1977,8 @@ HandleRFBServerMessage(rfbClient* client)
client->SoftCursorLockArea(client,
cr.srcX, cr.srcY, rect.r.w, rect.r.h);
- if (client->GotCopyRect != NULL) {
- client->GotCopyRect(client, cr.srcX, cr.srcY, rect.r.w, rect.r.h,
- rect.r.x, rect.r.y);
- } else
- CopyRectangleFromRectangle(client,
- cr.srcX, cr.srcY, rect.r.w, rect.r.h,
- rect.r.x, rect.r.y);
+ client->GotCopyRect(client, cr.srcX, cr.srcY, rect.r.w, rect.r.h,
+ rect.r.x, rect.r.y);
break;
}
@@ -2141,6 +2077,47 @@ HandleRFBServerMessage(rfbClient* client)
break;
}
+ case rfbEncodingTRLE:
+ {
+ switch (client->format.bitsPerPixel) {
+ case 8:
+ if (!HandleTRLE8(client, rect.r.x, rect.r.y, rect.r.w, rect.r.h))
+ return FALSE;
+ break;
+ case 16:
+ if (client->si.format.greenMax > 0x1F) {
+ if (!HandleTRLE16(client, rect.r.x, rect.r.y, rect.r.w, rect.r.h))
+ return FALSE;
+ } else {
+ if (!HandleTRLE15(client, rect.r.x, rect.r.y, rect.r.w, rect.r.h))
+ return FALSE;
+ }
+ break;
+ case 32: {
+ uint32_t maxColor =
+ (client->format.redMax << client->format.redShift) |
+ (client->format.greenMax << client->format.greenShift) |
+ (client->format.blueMax << client->format.blueShift);
+ if ((client->format.bigEndian && (maxColor & 0xff) == 0) ||
+ (!client->format.bigEndian && (maxColor & 0xff000000) == 0)) {
+ if (!HandleTRLE24(client, rect.r.x, rect.r.y, rect.r.w, rect.r.h))
+ return FALSE;
+ } else if (!client->format.bigEndian && (maxColor & 0xff) == 0) {
+ if (!HandleTRLE24Up(client, rect.r.x, rect.r.y, rect.r.w, rect.r.h))
+ return FALSE;
+ } else if (client->format.bigEndian && (maxColor & 0xff000000) == 0) {
+ if (!HandleTRLE24Down(client, rect.r.x, rect.r.y, rect.r.w,
+ rect.r.h))
+ return FALSE;
+ } else if (!HandleTRLE32(client, rect.r.x, rect.r.y, rect.r.w,
+ rect.r.h))
+ return FALSE;
+ break;
+ }
+ }
+ break;
+ }
+
#ifdef LIBVNCSERVER_HAVE_LIBZ
case rfbEncodingZlib:
{
@@ -2275,10 +2252,17 @@ HandleRFBServerMessage(rfbClient* client)
msg.sct.length = rfbClientSwap32IfLE(msg.sct.length);
+ if (msg.sct.length > 1<<20) {
+ rfbClientErr("Ignoring too big cut text length sent by server: %u B > 1 MB\n", (unsigned int)msg.sct.length);
+ return FALSE;
+ }
+
buffer = malloc(msg.sct.length+1);
- if (!ReadFromRFBServer(client, buffer, msg.sct.length))
+ if (!ReadFromRFBServer(client, buffer, msg.sct.length)) {
+ free(buffer);
return FALSE;
+ }
buffer[msg.sct.length] = 0;
@@ -2431,6 +2415,7 @@ HandleRFBServerMessage(rfbClient* client)
#include "ultra.c"
#include "zlib.c"
#include "tight.c"
+#include "trle.c"
#include "zrle.c"
#undef BPP
#define BPP 16
@@ -2440,8 +2425,11 @@ HandleRFBServerMessage(rfbClient* client)
#include "ultra.c"
#include "zlib.c"
#include "tight.c"
+#include "trle.c"
#include "zrle.c"
#define REALBPP 15
+#include "trle.c"
+#define REALBPP 15
#include "zrle.c"
#undef BPP
#define BPP 32
@@ -2451,14 +2439,23 @@ HandleRFBServerMessage(rfbClient* client)
#include "ultra.c"
#include "zlib.c"
#include "tight.c"
+#include "trle.c"
#include "zrle.c"
#define REALBPP 24
+#include "trle.c"
+#define REALBPP 24
#include "zrle.c"
#define REALBPP 24
#define UNCOMP 8
+#include "trle.c"
+#define REALBPP 24
+#define UNCOMP 8
#include "zrle.c"
#define REALBPP 24
#define UNCOMP -8
+#include "trle.c"
+#define REALBPP 24
+#define UNCOMP -8
#include "zrle.c"
#undef BPP
@@ -2499,7 +2496,6 @@ PrintPixelFormat(rfbPixelFormat *format)
#define rfbDes rfbClientDes
#define rfbDesKey rfbClientDesKey
#define rfbUseKey rfbClientUseKey
-#define rfbCPKey rfbClientCPKey
#include "vncauth.c"
#include "d3des.c"
diff --git a/libvncclient/rre.c b/libvncclient/rre.c
index 94158c9..752d7cc 100644
--- a/libvncclient/rre.c
+++ b/libvncclient/rre.c
@@ -45,7 +45,7 @@ HandleRREBPP (rfbClient* client, int rx, int ry, int rw, int rh)
if (!ReadFromRFBServer(client, (char *)&pix, sizeof(pix)))
return FALSE;
- FillRectangle(client, rx, ry, rw, rh, pix);
+ client->GotFillRect(client, rx, ry, rw, rh, pix);
for (i = 0; i < hdr.nSubrects; i++) {
if (!ReadFromRFBServer(client, (char *)&pix, sizeof(pix)))
@@ -59,7 +59,7 @@ HandleRREBPP (rfbClient* client, int rx, int ry, int rw, int rh)
subrect.w = rfbClientSwap16IfLE(subrect.w);
subrect.h = rfbClientSwap16IfLE(subrect.h);
- FillRectangle(client, rx+subrect.x, ry+subrect.y, subrect.w, subrect.h, pix);
+ client->GotFillRect(client, rx+subrect.x, ry+subrect.y, subrect.w, subrect.h, pix);
}
return TRUE;
diff --git a/libvncclient/sasl.c b/libvncclient/sasl.c
new file mode 100644
index 0000000..db240c1
--- /dev/null
+++ b/libvncclient/sasl.c
@@ -0,0 +1,582 @@
+/*
+ * The software in this file is derived from the vncconnection.c source file
+ * from the GTK VNC Widget with modifications by S. Waterman <simon.waterman@zynstra.com>
+ * for compatibility with libvncserver. The copyright and license
+ * statements below apply only to this source file and to no other parts of the
+ * libvncserver library.
+ *
+ * GTK VNC Widget
+ *
+ * Copyright (C) 2006 Anthony Liguori <anthony@codemonkey.ws>
+ * Copyright (C) 2009-2010 Daniel P. Berrange <dan@berrange.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.0 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/*
+ * sasl.c - functions to deal with client side of the SASL protocol.
+ */
+
+#ifdef __STRICT_ANSI__
+#define _BSD_SOURCE
+#define _POSIX_SOURCE
+#define _XOPEN_SOURCE 600
+#endif
+
+#include <errno.h>
+#include <rfb/rfbclient.h>
+
+#ifdef WIN32
+#undef SOCKET
+#include <winsock2.h>
+#ifdef EWOULDBLOCK
+#undef EWOULDBLOCK
+#endif
+#define EWOULDBLOCK WSAEWOULDBLOCK
+#define socklen_t int
+#define close closesocket
+#define read(sock,buf,len) recv(sock,buf,len,0)
+#define write(sock,buf,len) send(sock,buf,len,0)
+#ifdef LIBVNCSERVER_HAVE_WS2TCPIP_H
+#undef socklen_t
+#include <ws2tcpip.h>
+#endif /* LIBVNCSERVER_HAVE_WS2TCPIP_H */
+#else /* WIN32 */
+#include <arpa/inet.h>
+#endif /* WIN32 */
+
+#include "sasl.h"
+
+#include "tls.h"
+
+#ifdef _MSC_VER
+# define snprintf _snprintf /* MSVC went straight to the underscored syntax */
+#endif
+
+/*
+ * NB, keep in sync with similar method in qemud/remote.c
+ */
+static char *vnc_connection_addr_to_string(char *host, int port)
+{
+ char * buf = (char *)malloc(strlen(host) + 7);
+ sprintf(buf, "%s;%hu", host, port);
+ return buf;
+}
+
+static int log_func(void *context,
+ int level,
+ const char *message)
+{
+ rfbClientLog("SASL: %s\n", message);
+
+ return SASL_OK;
+}
+
+static int user_callback_adapt(void *context,
+ int id,
+ const char **result,
+ unsigned *len)
+{
+ rfbClient* client = (rfbClient *)context;
+
+ if (id != SASL_CB_AUTHNAME) {
+ rfbClientLog("Unrecognized SASL callback ID %d\n", id);
+ return SASL_FAIL;
+ }
+
+ if (!client->GetUser) {
+ rfbClientLog("Client user callback not found\n");
+ return SASL_FAIL;
+ }
+
+ *result = client->GetUser(client);
+
+ if (! *result) return SASL_FAIL;
+ /**len = strlen(*result);*/
+ return SASL_OK;
+}
+
+static int password_callback_adapt(sasl_conn_t *conn,
+ void * context,
+ int id,
+ sasl_secret_t **secret)
+{
+ rfbClient* client = (rfbClient *)context;
+ char * password;
+
+ if (id != SASL_CB_PASS) {
+ rfbClientLog("Unrecognized SASL callback ID %d\n", id);
+ return SASL_FAIL;
+ }
+
+ if (client->saslSecret) { /* If we've already got it just return it. */
+ *secret = client->saslSecret;
+ return SASL_OK;
+ }
+
+ if (!client->GetPassword) {
+ rfbClientLog("Client password callback not found\n");
+ return SASL_FAIL;
+ }
+
+ password = client->GetPassword(client);
+
+ if (! password) return SASL_FAIL;
+
+ sasl_secret_t *lsec = (sasl_secret_t *)malloc(sizeof(sasl_secret_t) + strlen(password));
+ if (!lsec) {
+ rfbClientLog("Could not allocate sasl_secret_t\n");
+ return SASL_FAIL;
+ }
+
+ strcpy(lsec->data, password);
+ lsec->len = strlen(password);
+ client->saslSecret = lsec;
+ *secret = lsec;
+
+ /* Clear client password */
+ size_t i;
+ for (i = 0; i < lsec->len; i++) {
+ password[i] = '\0';
+ }
+ free(password);
+
+ return SASL_OK;
+}
+
+#define SASL_MAX_MECHLIST_LEN 300
+#define SASL_MAX_DATA_LEN (1024 * 1024)
+
+/* Perform the SASL authentication process
+ */
+rfbBool
+HandleSASLAuth(rfbClient *client)
+{
+ sasl_conn_t *saslconn = NULL;
+ sasl_security_properties_t secprops;
+ const char *clientout;
+ char *serverin = NULL;
+ unsigned int clientoutlen, serverinlen;
+ int err, complete = 0;
+ char *localAddr = NULL, *remoteAddr = NULL;
+ const void *val;
+ sasl_ssf_t ssf;
+ sasl_callback_t saslcb[] = {
+ {SASL_CB_LOG, (void *)log_func, NULL},
+ {SASL_CB_AUTHNAME, client->GetUser ? (void *)user_callback_adapt : NULL, client},
+ {SASL_CB_PASS, client->GetPassword ? (void *)password_callback_adapt : NULL, client},
+ { .id = 0 },
+ };
+ sasl_interact_t *interact = NULL;
+ uint32_t mechlistlen;
+ char *mechlist;
+ char *wantmech;
+ const char *mechname;
+ rfbBool ret;
+
+ client->saslconn = NULL;
+
+ /* Sets up the SASL library as a whole */
+ err = sasl_client_init(NULL);
+ rfbClientLog("Client initialize SASL authentication %d\n", err);
+ if (err != SASL_OK) {
+ rfbClientLog("failed to initialize SASL library: %d (%s)\n",
+ err, sasl_errstring(err, NULL, NULL));
+ goto error;
+ }
+
+ /* Get local address in form IPADDR:PORT */
+ struct sockaddr_storage localAddress;
+ socklen_t addressLength = sizeof(localAddress);
+ char buf[INET6_ADDRSTRLEN];
+ int port;
+
+ if (getsockname(client->sock, (struct sockaddr*)&localAddress, &addressLength)) {
+ rfbClientLog("failed to get local address\n");
+ goto error;
+ }
+
+ if (localAddress.ss_family == AF_INET) {
+ struct sockaddr_in *sa_in = (struct sockaddr_in*)&localAddress;
+ inet_ntop(AF_INET, &(sa_in->sin_addr), buf, INET_ADDRSTRLEN);
+ port = ntohs(sa_in->sin_port);
+ localAddr = vnc_connection_addr_to_string(buf, port);
+ } else if (localAddress.ss_family == AF_INET6) {
+ struct sockaddr_in6 *sa_in = (struct sockaddr_in6*)&localAddress;
+ inet_ntop(AF_INET6, &(sa_in->sin6_addr), buf, INET6_ADDRSTRLEN);
+ port = ntohs(sa_in->sin6_port);
+ localAddr = vnc_connection_addr_to_string(buf, port);
+ } else {
+ rfbClientLog("failed to get local address\n");
+ goto error;
+ }
+
+ /* Get remote address in form IPADDR:PORT */
+ remoteAddr = vnc_connection_addr_to_string(client->serverHost, client->serverPort);
+
+ rfbClientLog("Client SASL new host:'%s' local:'%s' remote:'%s'\n", client->serverHost, localAddr, remoteAddr);
+
+ /* Setup a handle for being a client */
+ err = sasl_client_new("vnc",
+ client->serverHost,
+ localAddr,
+ remoteAddr,
+ saslcb,
+ SASL_SUCCESS_DATA,
+ &saslconn);
+ free(localAddr);
+ free(remoteAddr);
+
+ if (err != SASL_OK) {
+ rfbClientLog("Failed to create SASL client context: %d (%s)\n",
+ err, sasl_errstring(err, NULL, NULL));
+ goto error;
+ }
+
+ /* Initialize some connection props we care about */
+ if (client->tlsSession) {
+ if (!(ssf = (sasl_ssf_t)GetTLSCipherBits(client))) {
+ rfbClientLog("%s", "invalid cipher size for TLS session\n");
+ goto error;
+ }
+
+ rfbClientLog("Setting external SSF %d\n", ssf);
+ err = sasl_setprop(saslconn, SASL_SSF_EXTERNAL, &ssf);
+ if (err != SASL_OK) {
+ rfbClientLog("cannot set external SSF %d (%s)\n",
+ err, sasl_errstring(err, NULL, NULL));
+ goto error;
+ }
+ }
+
+ memset (&secprops, 0, sizeof secprops);
+ /* If we've got TLS, we don't care about SSF */
+ secprops.min_ssf = client->tlsSession ? 0 : 56; /* Equiv to DES supported by all Kerberos */
+ secprops.max_ssf = client->tlsSession ? 0 : 100000; /* Very strong ! AES == 256 */
+ secprops.maxbufsize = 100000;
+ /* If we're not TLS, then forbid any anonymous or trivially crackable auth */
+ secprops.security_flags = client->tlsSession ? 0 :
+ SASL_SEC_NOANONYMOUS | SASL_SEC_NOPLAINTEXT;
+
+ err = sasl_setprop(saslconn, SASL_SEC_PROPS, &secprops);
+ if (err != SASL_OK) {
+ rfbClientLog("cannot set security props %d (%s)\n",
+ err, sasl_errstring(err, NULL, NULL));
+ goto error;
+ }
+
+ /* Get the supported mechanisms from the server */
+ if (!ReadFromRFBServer(client, (char *)&mechlistlen, 4)) {
+ rfbClientLog("failed to read mechlistlen\n");
+ goto error;
+ }
+ mechlistlen = rfbClientSwap32IfLE(mechlistlen);
+ rfbClientLog("mechlistlen is %d\n", mechlistlen);
+ if (mechlistlen > SASL_MAX_MECHLIST_LEN) {
+ rfbClientLog("mechlistlen %d too long\n", mechlistlen);
+ goto error;
+ }
+
+ mechlist = malloc(mechlistlen+1);
+ if (!ReadFromRFBServer(client, mechlist, mechlistlen)) {
+ free(mechlist);
+ goto error;
+ }
+ mechlist[mechlistlen] = '\0';
+
+ /* Allow the client to influence the mechanism selected. */
+ if (client->GetSASLMechanism) {
+ wantmech = client->GetSASLMechanism(client, mechlist);
+
+ if (wantmech && *wantmech != 0) {
+ if (strstr(mechlist, wantmech) == NULL) {
+ rfbClientLog("Client requested SASL mechanism %s not supported by server\n",
+ wantmech);
+ free(mechlist);
+ free(wantmech);
+ goto error;
+ } else {
+ free(mechlist);
+ mechlist = wantmech;
+ }
+ }
+ }
+
+ rfbClientLog("Client start negotiation mechlist '%s'\n", mechlist);
+
+ restart:
+ /* Start the auth negotiation on the client end first */
+ err = sasl_client_start(saslconn,
+ mechlist,
+ &interact,
+ &clientout,
+ &clientoutlen,
+ &mechname);
+ if (err != SASL_OK && err != SASL_CONTINUE && err != SASL_INTERACT) {
+ rfbClientLog("Failed to start SASL negotiation: %d (%s)\n",
+ err, sasl_errdetail(saslconn));
+ free(mechlist);
+ mechlist = NULL;
+ goto error;
+ }
+
+ /* Need to gather some credentials from the client */
+ if (err == SASL_INTERACT) {
+ rfbClientLog("User interaction required but not currently supported\n");
+ goto error;
+ }
+
+ rfbClientLog("Server start negotiation with mech %s. Data %d bytes %p '%s'\n",
+ mechname, clientoutlen, clientout, clientout);
+
+ if (clientoutlen > SASL_MAX_DATA_LEN) {
+ rfbClientLog("SASL negotiation data too long: %d bytes\n",
+ clientoutlen);
+ goto error;
+ }
+
+ /* Send back the chosen mechname */
+ uint32_t mechnamelen = rfbClientSwap32IfLE(strlen(mechname));
+ if (!WriteToRFBServer(client, (char *)&mechnamelen, 4)) goto error;
+ if (!WriteToRFBServer(client, (char *)mechname, strlen(mechname))) goto error;
+
+ /* NB, distinction of NULL vs "" is *critical* in SASL */
+ if (clientout) {
+ uint32_t colsw = rfbClientSwap32IfLE(clientoutlen + 1);
+ if (!WriteToRFBServer(client, (char *)&colsw, 4)) goto error;
+ if (!WriteToRFBServer(client, (char *)clientout, clientoutlen + 1)) goto error;
+ } else {
+ uint32_t temp = 0;
+ if (!WriteToRFBServer(client, (char *)&temp, 4)) goto error;
+ }
+
+ rfbClientLog("%s", "Getting sever start negotiation reply\n");
+ /* Read the 'START' message reply from server */
+ if (!ReadFromRFBServer(client, (char *)&serverinlen, 4)) goto error;
+ serverinlen = rfbClientSwap32IfLE(serverinlen);
+
+ if (serverinlen > SASL_MAX_DATA_LEN) {
+ rfbClientLog("SASL negotiation data too long: %d bytes\n",
+ serverinlen);
+ goto error;
+ }
+
+ /* NB, distinction of NULL vs "" is *critical* in SASL */
+ if (serverinlen) {
+ serverin = malloc(serverinlen);
+ if (!ReadFromRFBServer(client, serverin, serverinlen)) goto error;
+ serverin[serverinlen-1] = '\0';
+ serverinlen--;
+ } else {
+ serverin = NULL;
+ }
+ if (!ReadFromRFBServer(client, (char *)&complete, 1)) goto error;
+
+ rfbClientLog("Client start result complete: %d. Data %d bytes %p '%s'\n",
+ complete, serverinlen, serverin, serverin);
+
+ /* Loop-the-loop...
+ * Even if the server has completed, the client must *always* do at least one step
+ * in this loop to verify the server isn't lying about something. Mutual auth */
+ for (;;) {
+ restep:
+ err = sasl_client_step(saslconn,
+ serverin,
+ serverinlen,
+ &interact,
+ &clientout,
+ &clientoutlen);
+ if (err != SASL_OK && err != SASL_CONTINUE && err != SASL_INTERACT) {
+ rfbClientLog("Failed SASL step: %d (%s)\n",
+ err, sasl_errdetail(saslconn));
+ goto error;
+ }
+
+ /* Need to gather some credentials from the client */
+ if (err == SASL_INTERACT) {
+ rfbClientLog("User interaction required but not currently supported\n");
+ goto error;
+ }
+
+ if (serverin) {
+ free(serverin);
+ serverin = NULL;
+ }
+
+ rfbClientLog("Client step result %d. Data %d bytes %p '%s'\n", err, clientoutlen, clientout, clientout);
+
+ /* Previous server call showed completion & we're now locally complete too */
+ if (complete && err == SASL_OK)
+ break;
+
+ /* Not done, prepare to talk with the server for another iteration */
+
+ /* NB, distinction of NULL vs "" is *critical* in SASL */
+ if (clientout) {
+ uint32_t colsw = rfbClientSwap32IfLE(clientoutlen + 1);
+ if (!WriteToRFBServer(client, (char *)&colsw, 4)) goto error;
+ if (!WriteToRFBServer(client, (char *)clientout, clientoutlen + 1)) goto error;
+ } else {
+ uint32_t temp = 0;
+ if (!WriteToRFBServer(client, (char *)&temp, 4)) goto error;
+ }
+
+ rfbClientLog("Server step with %d bytes %p\n", clientoutlen, clientout);
+
+ if (!ReadFromRFBServer(client, (char *)&serverinlen, 4)) goto error;
+ serverinlen = rfbClientSwap32IfLE(serverinlen);
+
+ if (serverinlen > SASL_MAX_DATA_LEN) {
+ rfbClientLog("SASL negotiation data too long: %d bytes\n",
+ serverinlen);
+ goto error;
+ }
+
+ /* NB, distinction of NULL vs "" is *critical* in SASL */
+ if (serverinlen) {
+ serverin = malloc(serverinlen);
+ if (!ReadFromRFBServer(client, serverin, serverinlen)) goto error;
+ serverin[serverinlen-1] = '\0';
+ serverinlen--;
+ } else {
+ serverin = NULL;
+ }
+ if (!ReadFromRFBServer(client, (char *)&complete, 1)) goto error;
+
+ rfbClientLog("Client step result complete: %d. Data %d bytes %p '%s'\n",
+ complete, serverinlen, serverin, serverin);
+
+ /* This server call shows complete, and earlier client step was OK */
+ if (complete && err == SASL_OK) {
+ free(serverin);
+ serverin = NULL;
+ break;
+ }
+ }
+
+ /* Check for suitable SSF if non-TLS */
+ if (!client->tlsSession) {
+ err = sasl_getprop(saslconn, SASL_SSF, &val);
+ if (err != SASL_OK) {
+ rfbClientLog("cannot query SASL ssf on connection %d (%s)\n",
+ err, sasl_errstring(err, NULL, NULL));
+ goto error;
+ }
+ ssf = *(const int *)val;
+ rfbClientLog("SASL SSF value %d\n", ssf);
+ if (ssf < 56) { /* 56 == DES level, good for Kerberos */
+ rfbClientLog("negotiation SSF %d was not strong enough\n", ssf);
+ goto error;
+ }
+ }
+
+ rfbClientLog("%s", "SASL authentication complete\n");
+
+ uint32_t result;
+ if (!ReadFromRFBServer(client, (char *)&result, 4)) {
+ rfbClientLog("Failed to read authentication result\n");
+ goto error;
+ }
+ result = rfbClientSwap32IfLE(result);
+
+ if (result != 0) {
+ rfbClientLog("Authentication failure\n");
+ goto error;
+ }
+ rfbClientLog("Authentication successful - switching to SSF\n");
+
+ /* This must come *after* check-auth-result, because the former
+ * is defined to be sent unencrypted, and setting saslconn turns
+ * on the SSF layer encryption processing */
+ client->saslconn = saslconn;
+
+ /* Clear SASL secret from memory if set - it'll be free'd on dispose */
+ if (client->saslSecret) {
+ size_t i;
+ for (i = 0; i < client->saslSecret->len; i++)
+ client->saslSecret->data[i] = '\0';
+ client->saslSecret->len = 0;
+ }
+
+ return TRUE;
+
+ error:
+ if (client->saslSecret) {
+ size_t i;
+ for (i = 0; i < client->saslSecret->len; i++)
+ client->saslSecret->data[i] = '\0';
+ client->saslSecret->len = 0;
+ }
+
+ if (saslconn)
+ sasl_dispose(&saslconn);
+ return FALSE;
+}
+
+int
+ReadFromSASL(rfbClient* client, char *out, unsigned int n)
+{
+ size_t want;
+
+ if (client->saslDecoded == NULL) {
+ char *encoded;
+ int encodedLen;
+ int err, ret;
+
+ encodedLen = 8192;
+ encoded = (char *)malloc(encodedLen);
+
+ ret = read(client->sock, encoded, encodedLen);
+ if (ret < 0) {
+ free(encoded);
+ return ret;
+ }
+ if (ret == 0) {
+ free(encoded);
+ errno = EIO;
+ return -EIO;
+ }
+
+ err = sasl_decode(client->saslconn, encoded, ret,
+ &client->saslDecoded, &client->saslDecodedLength);
+ free(encoded);
+ if (err != SASL_OK) {
+ rfbClientLog("Failed to decode SASL data %s\n",
+ sasl_errstring(err, NULL, NULL));
+ return -EINVAL;
+ }
+ client->saslDecodedOffset = 0;
+ }
+
+ want = client->saslDecodedLength - client->saslDecodedOffset;
+ if (want > n)
+ want = n;
+
+ memcpy(out,
+ client->saslDecoded + client->saslDecodedOffset,
+ want);
+ client->saslDecodedOffset += want;
+ if (client->saslDecodedOffset == client->saslDecodedLength) {
+ client->saslDecodedLength = client->saslDecodedOffset = 0;
+ client->saslDecoded = NULL;
+ }
+
+ if (!want) {
+ errno = EAGAIN;
+ return -EAGAIN;
+ }
+
+ return want;
+}
diff --git a/libvncclient/sasl.h b/libvncclient/sasl.h
new file mode 100644
index 0000000..2936364
--- /dev/null
+++ b/libvncclient/sasl.h
@@ -0,0 +1,39 @@
+#ifndef RFBSASL_H
+#define RFBSASL_H
+
+/*
+ * Copyright (C) 2017 S. Waterman. All Rights Reserved.
+ *
+ * This is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this software; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+ * USA.
+ */
+
+#ifdef LIBVNCSERVER_HAVE_SASL
+
+#include <rfb/rfbclient.h>
+
+/*
+ * Perform the SASL authentication process
+ */
+rfbBool HandleSASLAuth(rfbClient *client);
+
+/*
+ * Read from SASL when the SASL SSF is in use.
+ */
+int ReadFromSASL(rfbClient* client, char *out, unsigned int n);
+
+#endif /* LIBVNCSERVER_HAVE_SASL */
+
+#endif /* RFBSASL_H */
diff --git a/libvncclient/sockets.c b/libvncclient/sockets.c
index 8d2eb98..2b0ee71 100644
--- a/libvncclient/sockets.c
+++ b/libvncclient/sockets.c
@@ -22,7 +22,17 @@
* sockets.c - functions to deal with sockets.
*/
+#ifdef __STRICT_ANSI__
+#define _BSD_SOURCE
+#ifdef __linux__
+/* Setting this on other systems hides definitions such as INADDR_LOOPBACK.
+ * The check should be for __GLIBC__ in fact. */
+# define _POSIX_SOURCE
+#endif
+#endif
+#if LIBVNCSERVER_HAVE_UNISTD_H
#include <unistd.h>
+#endif
#include <errno.h>
#include <fcntl.h>
#include <assert.h>
@@ -30,6 +40,9 @@
#ifdef WIN32
#undef SOCKET
#include <winsock2.h>
+#ifdef EWOULDBLOCK
+#undef EWOULDBLOCK
+#endif
#define EWOULDBLOCK WSAEWOULDBLOCK
#define close closesocket
#define read(sock,buf,len) recv(sock,buf,len,0)
@@ -48,6 +61,7 @@
#include <netdb.h>
#endif
#include "tls.h"
+#include "sasl.h"
#ifdef _MSC_VER
# define snprintf _snprintf
@@ -144,16 +158,24 @@ ReadFromRFBServer(rfbClient* client, char *out, unsigned int n)
while (client->buffered < n) {
int i;
- if (client->tlsSession) {
+ if (client->tlsSession)
i = ReadFromTLS(client, client->buf + client->buffered, RFB_BUF_SIZE - client->buffered);
- } else {
+ else
+#ifdef LIBVNCSERVER_HAVE_SASL
+ if (client->saslconn)
+ i = ReadFromSASL(client, client->buf + client->buffered, RFB_BUF_SIZE - client->buffered);
+ else {
+#endif /* LIBVNCSERVER_HAVE_SASL */
i = read(client->sock, client->buf + client->buffered, RFB_BUF_SIZE - client->buffered);
+#ifdef WIN32
+ if (i < 0) errno=WSAGetLastError();
+#endif
+#ifdef LIBVNCSERVER_HAVE_SASL
}
+#endif
+
if (i <= 0) {
if (i < 0) {
-#ifdef WIN32
- errno=WSAGetLastError();
-#endif
if (errno == EWOULDBLOCK || errno == EAGAIN) {
/* TODO:
ProcessXtEvents();
@@ -184,11 +206,15 @@ ReadFromRFBServer(rfbClient* client, char *out, unsigned int n)
while (n > 0) {
int i;
- if (client->tlsSession) {
+ if (client->tlsSession)
i = ReadFromTLS(client, out, n);
- } else {
+ else
+#ifdef LIBVNCSERVER_HAVE_SASL
+ if (client->saslconn)
+ i = ReadFromSASL(client, out, n);
+ else
+#endif
i = read(client->sock, out, n);
- }
if (i <= 0) {
if (i < 0) {
@@ -242,6 +268,12 @@ WriteToRFBServer(rfbClient* client, char *buf, int n)
fd_set fds;
int i = 0;
int j;
+ const char *obuf = buf;
+#ifdef LIBVNCSERVER_HAVE_SASL
+ const char *output;
+ unsigned int outputlen;
+ int err;
+#endif /* LIBVNCSERVER_HAVE_SASL */
if (client->serverPort==-1)
return TRUE; /* vncrec playing */
@@ -253,9 +285,23 @@ WriteToRFBServer(rfbClient* client, char *buf, int n)
return TRUE;
}
+#ifdef LIBVNCSERVER_HAVE_SASL
+ if (client->saslconn) {
+ err = sasl_encode(client->saslconn,
+ buf, n,
+ &output, &outputlen);
+ if (err != SASL_OK) {
+ rfbClientLog("Failed to encode SASL data %s",
+ sasl_errstring(err, NULL, NULL));
+ return FALSE;
+ }
+ obuf = output;
+ n = outputlen;
+ }
+#endif /* LIBVNCSERVER_HAVE_SASL */
while (i < n) {
- j = write(client->sock, buf + i, (n - i));
+ j = write(client->sock, obuf + i, (n - i));
if (j <= 0) {
if (j < 0) {
#ifdef WIN32
@@ -288,8 +334,6 @@ WriteToRFBServer(rfbClient* client, char *buf, int n)
return TRUE;
}
-
-
static int initSockets() {
#ifdef WIN32
WSADATA trash;
diff --git a/libvncclient/tight.c b/libvncclient/tight.c
index 2f9fbab..df01812 100644
--- a/libvncclient/tight.c
+++ b/libvncclient/tight.c
@@ -1,4 +1,7 @@
/*
+ * Copyright (C) 2017 D. R. Commander. All Rights Reserved.
+ * Copyright (C) 2004-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (C) 2004 Landmark Graphics Corporation. All Rights Reserved.
* Copyright (C) 2000, 2001 Const Kaplinsky. All Rights Reserved.
*
* This is free software; you can redistribute it and/or modify
@@ -20,6 +23,8 @@
#ifdef LIBVNCSERVER_HAVE_LIBZ
#ifdef LIBVNCSERVER_HAVE_LIBJPEG
+#include "turbojpeg.h"
+
/*
* tight.c - handle ``tight'' encoding.
*
@@ -71,16 +76,16 @@
/* Type declarations */
-typedef void (*filterPtrBPP)(rfbClient* client, int, CARDBPP *);
+typedef void (*filterPtrBPP)(rfbClient* client, int, int, int);
/* Prototypes */
static int InitFilterCopyBPP (rfbClient* client, int rw, int rh);
static int InitFilterPaletteBPP (rfbClient* client, int rw, int rh);
static int InitFilterGradientBPP (rfbClient* client, int rw, int rh);
-static void FilterCopyBPP (rfbClient* client, int numRows, CARDBPP *destBuffer);
-static void FilterPaletteBPP (rfbClient* client, int numRows, CARDBPP *destBuffer);
-static void FilterGradientBPP (rfbClient* client, int numRows, CARDBPP *destBuffer);
+static void FilterCopyBPP (rfbClient* client, int srcx, int srcy, int numRows);
+static void FilterPaletteBPP (rfbClient* client, int srcx, int srcy, int numRows);
+static void FilterGradientBPP (rfbClient* client, int srcx, int srcy, int numRows);
#if BPP != 8
static rfbBool DecompressJpegRectBPP(rfbClient* client, int x, int y, int w, int h);
@@ -96,9 +101,17 @@ HandleTightBPP (rfbClient* client, int rx, int ry, int rw, int rh)
uint8_t filter_id;
filterPtrBPP filterFn;
z_streamp zs;
- char *buffer2;
int err, stream_id, compressedLen, bitsPixel;
int bufferSize, rowSize, numRows, portionLen, rowsProcessed, extraBytes;
+ rfbBool readUncompressed = FALSE;
+
+ if (client->frameBuffer == NULL)
+ return FALSE;
+
+ if (rx + rw > client->width || ry + rh > client->height) {
+ rfbClientLog("Rect out of bounds: %dx%d at (%d, %d)\n", rx, ry, rw, rh);
+ return FALSE;
+ }
if (!ReadFromRFBServer(client, (char *)&comp_ctl, 1))
return FALSE;
@@ -114,6 +127,11 @@ HandleTightBPP (rfbClient* client, int rx, int ry, int rw, int rh)
comp_ctl >>= 1;
}
+ if ((comp_ctl & rfbTightNoZlib) == rfbTightNoZlib) {
+ comp_ctl &= ~(rfbTightNoZlib);
+ readUncompressed = TRUE;
+ }
+
/* Handle solid rectangles. */
if (comp_ctl == rfbTightFill) {
#if BPP == 32
@@ -131,7 +149,7 @@ HandleTightBPP (rfbClient* client, int rx, int ry, int rw, int rh)
return FALSE;
#endif
- FillRectangle(client, rx, ry, rw, rh, fill_colour);
+ client->GotFillRect(client, rx, ry, rw, rh, fill_colour);
return TRUE;
}
@@ -195,10 +213,7 @@ HandleTightBPP (rfbClient* client, int rx, int ry, int rw, int rh)
if (!ReadFromRFBServer(client, (char*)client->buffer, rh * rowSize))
return FALSE;
- buffer2 = &client->buffer[TIGHT_MIN_TO_COMPRESS * 4];
- filterFn(client, rh, (CARDBPP *)buffer2);
-
- CopyRectangle(client, (uint8_t *)buffer2, rx, ry, rw, rh);
+ filterFn(client, rx, ry, rh);
return TRUE;
}
@@ -209,6 +224,14 @@ HandleTightBPP (rfbClient* client, int rx, int ry, int rw, int rh)
rfbClientLog("Incorrect data received from the server.\n");
return FALSE;
}
+ if (readUncompressed) {
+ if (!ReadFromRFBServer(client, (char*)client->buffer, compressedLen))
+ return FALSE;
+
+ filterFn(client, rx, ry, rh);
+
+ return TRUE;
+ }
/* Now let's initialize compression stream if needed. */
stream_id = comp_ctl & 0x03;
@@ -229,7 +252,6 @@ HandleTightBPP (rfbClient* client, int rx, int ry, int rw, int rh)
/* Read, decode and draw actual pixel data in a loop. */
bufferSize = RFB_BUFFER_SIZE * bitsPixel / (bitsPixel + BPP) & 0xFFFFFFFC;
- buffer2 = &client->buffer[bufferSize];
if (rowSize > bufferSize) {
/* Should be impossible when RFB_BUFFER_SIZE >= 16384 */
rfbClientLog("Internal error: incorrect buffer size.\n");
@@ -271,14 +293,12 @@ HandleTightBPP (rfbClient* client, int rx, int ry, int rw, int rh)
numRows = (bufferSize - zs->avail_out) / rowSize;
- filterFn(client, numRows, (CARDBPP *)buffer2);
+ filterFn(client, rx, ry+rowsProcessed, numRows);
extraBytes = bufferSize - zs->avail_out - numRows * rowSize;
if (extraBytes > 0)
memcpy(client->buffer, &client->buffer[numRows * rowSize], extraBytes);
- CopyRectangle(client, (uint8_t *)buffer2, rx, ry+rowsProcessed, rw, numRows);
-
rowsProcessed += numRows;
}
while (zs->avail_out == 0);
@@ -317,16 +337,19 @@ InitFilterCopyBPP (rfbClient* client, int rw, int rh)
}
static void
-FilterCopyBPP (rfbClient* client, int numRows, CARDBPP *dst)
+FilterCopyBPP (rfbClient* client, int srcx, int srcy, int numRows)
{
+ CARDBPP *dst =
+ (CARDBPP *)&client->frameBuffer[(srcy * client->width + srcx) * BPP / 8];
+ int y;
#if BPP == 32
- int x, y;
+ int x;
if (client->cutZeros) {
for (y = 0; y < numRows; y++) {
for (x = 0; x < client->rectWidth; x++) {
- dst[y*client->rectWidth+x] =
+ dst[y*client->width+x] =
RGB24_TO_PIXEL32(client->buffer[(y*client->rectWidth+x)*3],
client->buffer[(y*client->rectWidth+x)*3+1],
client->buffer[(y*client->rectWidth+x)*3+2]);
@@ -336,7 +359,9 @@ FilterCopyBPP (rfbClient* client, int numRows, CARDBPP *dst)
}
#endif
- memcpy (dst, client->buffer, numRows * client->rectWidth * (BPP / 8));
+ for (y = 0; y < numRows; y++)
+ memcpy (&dst[y*client->width], &client->buffer[y*client->rectWidth],
+ client->rectWidth * (BPP / 8));
}
static int
@@ -356,8 +381,10 @@ InitFilterGradientBPP (rfbClient* client, int rw, int rh)
#if BPP == 32
static void
-FilterGradient24 (rfbClient* client, int numRows, uint32_t *dst)
+FilterGradient24 (rfbClient* client, int srcx, int srcy, int numRows)
{
+ CARDBPP *dst =
+ (CARDBPP *)&client->frameBuffer[(srcy * client->width + srcx) * BPP / 8];
int x, y, c;
uint8_t thisRow[2048*3];
uint8_t pix[3];
@@ -370,7 +397,7 @@ FilterGradient24 (rfbClient* client, int numRows, uint32_t *dst)
pix[c] = client->tightPrevRow[c] + client->buffer[y*client->rectWidth*3+c];
thisRow[c] = pix[c];
}
- dst[y*client->rectWidth] = RGB24_TO_PIXEL32(pix[0], pix[1], pix[2]);
+ dst[y*client->width] = RGB24_TO_PIXEL32(pix[0], pix[1], pix[2]);
/* Remaining pixels of a row */
for (x = 1; x < client->rectWidth; x++) {
@@ -385,7 +412,7 @@ FilterGradient24 (rfbClient* client, int numRows, uint32_t *dst)
pix[c] = (uint8_t)est[c] + client->buffer[(y*client->rectWidth+x)*3+c];
thisRow[x*3+c] = pix[c];
}
- dst[y*client->rectWidth+x] = RGB24_TO_PIXEL32(pix[0], pix[1], pix[2]);
+ dst[y*client->width+x] = RGB24_TO_PIXEL32(pix[0], pix[1], pix[2]);
}
memcpy(client->tightPrevRow, thisRow, client->rectWidth * 3);
@@ -395,8 +422,10 @@ FilterGradient24 (rfbClient* client, int numRows, uint32_t *dst)
#endif
static void
-FilterGradientBPP (rfbClient* client, int numRows, CARDBPP *dst)
+FilterGradientBPP (rfbClient* client, int srcx, int srcy, int numRows)
{
+ CARDBPP *dst =
+ (CARDBPP *)&client->frameBuffer[(srcy * client->width + srcx) * BPP / 8];
int x, y, c;
CARDBPP *src = (CARDBPP *)client->buffer;
uint16_t *thatRow = (uint16_t *)client->tightPrevRow;
@@ -408,7 +437,7 @@ FilterGradientBPP (rfbClient* client, int numRows, CARDBPP *dst)
#if BPP == 32
if (client->cutZeros) {
- FilterGradient24(client, numRows, dst);
+ FilterGradient24(client, srcx, srcy, numRows);
return;
}
#endif
@@ -428,7 +457,7 @@ FilterGradientBPP (rfbClient* client, int numRows, CARDBPP *dst)
pix[c] = (uint16_t)(((src[y*client->rectWidth] >> shift[c]) + thatRow[c]) & max[c]);
thisRow[c] = pix[c];
}
- dst[y*client->rectWidth] = RGB_TO_PIXEL(BPP, pix[0], pix[1], pix[2]);
+ dst[y*client->width] = RGB_TO_PIXEL(BPP, pix[0], pix[1], pix[2]);
/* Remaining pixels of a row */
for (x = 1; x < client->rectWidth; x++) {
@@ -442,7 +471,7 @@ FilterGradientBPP (rfbClient* client, int numRows, CARDBPP *dst)
pix[c] = (uint16_t)(((src[y*client->rectWidth+x] >> shift[c]) + est[c]) & max[c]);
thisRow[x*3+c] = pix[c];
}
- dst[y*client->rectWidth+x] = RGB_TO_PIXEL(BPP, pix[0], pix[1], pix[2]);
+ dst[y*client->width+x] = RGB_TO_PIXEL(BPP, pix[0], pix[1], pix[2]);
}
memcpy(thatRow, thisRow, client->rectWidth * 3 * sizeof(uint16_t));
}
@@ -487,9 +516,11 @@ InitFilterPaletteBPP (rfbClient* client, int rw, int rh)
}
static void
-FilterPaletteBPP (rfbClient* client, int numRows, CARDBPP *dst)
+FilterPaletteBPP (rfbClient* client, int srcx, int srcy, int numRows)
{
int x, y, b, w;
+ CARDBPP *dst =
+ (CARDBPP *)&client->frameBuffer[(srcy * client->width + srcx) * BPP / 8];
uint8_t *src = (uint8_t *)client->buffer;
CARDBPP *palette = (CARDBPP *)client->tightPalette;
@@ -498,16 +529,16 @@ FilterPaletteBPP (rfbClient* client, int numRows, CARDBPP *dst)
for (y = 0; y < numRows; y++) {
for (x = 0; x < client->rectWidth / 8; x++) {
for (b = 7; b >= 0; b--)
- dst[y*client->rectWidth+x*8+7-b] = palette[src[y*w+x] >> b & 1];
+ dst[y*client->width+x*8+7-b] = palette[src[y*w+x] >> b & 1];
}
for (b = 7; b >= 8 - client->rectWidth % 8; b--) {
- dst[y*client->rectWidth+x*8+7-b] = palette[src[y*w+x] >> b & 1];
+ dst[y*client->width+x*8+7-b] = palette[src[y*w+x] >> b & 1];
}
}
} else {
for (y = 0; y < numRows; y++)
for (x = 0; x < client->rectWidth; x++)
- dst[y*client->rectWidth+x] = palette[(int)src[y*client->rectWidth+x]];
+ dst[y*client->width+x] = palette[(int)src[y*client->rectWidth+x]];
}
}
@@ -522,13 +553,9 @@ FilterPaletteBPP (rfbClient* client, int numRows, CARDBPP *dst)
static rfbBool
DecompressJpegRectBPP(rfbClient* client, int x, int y, int w, int h)
{
- struct jpeg_decompress_struct cinfo;
- struct jpeg_error_mgr jerr;
int compressedLen;
- uint8_t *compressedData;
- CARDBPP *pixelPtr;
- JSAMPROW rowPointer[1];
- int dx, dy;
+ uint8_t *compressedData, *dst;
+ int pixelSize, pitch, flags = 0;
compressedLen = (int)ReadCompactLen(client);
if (compressedLen <= 0) {
@@ -547,47 +574,60 @@ DecompressJpegRectBPP(rfbClient* client, int x, int y, int w, int h)
return FALSE;
}
- cinfo.err = jpeg_std_error(&jerr);
- cinfo.client_data = client;
- jpeg_create_decompress(&cinfo);
-
- JpegSetSrcManager(&cinfo, compressedData, compressedLen);
+ if(client->GotJpeg != NULL)
+ return client->GotJpeg(client, compressedData, compressedLen, x, y, w, h);
+
+ if (!client->tjhnd) {
+ if ((client->tjhnd = tjInitDecompress()) == NULL) {
+ rfbClientLog("TurboJPEG error: %s\n", tjGetErrorStr());
+ free(compressedData);
+ return FALSE;
+ }
+ }
- jpeg_read_header(&cinfo, TRUE);
- cinfo.out_color_space = JCS_RGB;
+#if BPP == 16
+ flags = 0;
+ pixelSize = 3;
+ pitch = w * pixelSize;
+ dst = (uint8_t *)client->buffer;
+#else
+ if (client->format.bigEndian) flags |= TJ_ALPHAFIRST;
+ if (client->format.redShift == 16 && client->format.blueShift == 0)
+ flags |= TJ_BGR;
+ if (client->format.bigEndian) flags ^= TJ_BGR;
+ pixelSize = BPP / 8;
+ pitch = client->width * pixelSize;
+ dst = &client->frameBuffer[y * pitch + x * pixelSize];
+#endif
- jpeg_start_decompress(&cinfo);
- if (cinfo.output_width != w || cinfo.output_height != h ||
- cinfo.output_components != 3) {
- rfbClientLog("Tight Encoding: Wrong JPEG data received.\n");
- jpeg_destroy_decompress(&cinfo);
+ if (tjDecompress(client->tjhnd, compressedData, (unsigned long)compressedLen,
+ dst, w, pitch, h, pixelSize, flags)==-1) {
+ rfbClientLog("TurboJPEG error: %s\n", tjGetErrorStr());
free(compressedData);
return FALSE;
}
- rowPointer[0] = (JSAMPROW)client->buffer;
- dy = 0;
- while (cinfo.output_scanline < cinfo.output_height) {
- jpeg_read_scanlines(&cinfo, rowPointer, 1);
- if (client->jpegError) {
- break;
- }
- pixelPtr = (CARDBPP *)&client->buffer[RFB_BUFFER_SIZE / 2];
- for (dx = 0; dx < w; dx++) {
- *pixelPtr++ =
- RGB24_TO_PIXEL(BPP, client->buffer[dx*3], client->buffer[dx*3+1], client->buffer[dx*3+2]);
+ free(compressedData);
+
+#if BPP == 16
+ pixelSize = BPP / 8;
+ pitch = client->width * pixelSize;
+ dst = &client->frameBuffer[y * pitch + x * pixelSize];
+ {
+ CARDBPP *dst16=(CARDBPP *)dst, *dst2;
+ char *src = client->buffer;
+ int i, j;
+
+ for (j = 0; j < h; j++) {
+ for (i = 0, dst2 = dst16; i < w; i++, dst2++, src += 3) {
+ *dst2 = RGB24_TO_PIXEL(BPP, src[0], src[1], src[2]);
+ }
+ dst16 += client->width;
}
- CopyRectangle(client, (uint8_t *)&client->buffer[RFB_BUFFER_SIZE / 2], x, y + dy, w, 1);
- dy++;
}
+#endif
- if (!client->jpegError)
- jpeg_finish_decompress(&cinfo);
-
- jpeg_destroy_decompress(&cinfo);
- free(compressedData);
-
- return !client->jpegError;
+ return TRUE;
}
#else
@@ -614,70 +654,6 @@ ReadCompactLen (rfbClient* client)
return len;
}
-/*
- * JPEG source manager functions for JPEG decompression in Tight decoder.
- */
-
-static void
-JpegInitSource(j_decompress_ptr cinfo)
-{
- rfbClient* client=(rfbClient*)cinfo->client_data;
- client->jpegError = FALSE;
-}
-
-static boolean
-JpegFillInputBuffer(j_decompress_ptr cinfo)
-{
- rfbClient* client=(rfbClient*)cinfo->client_data;
- client->jpegError = TRUE;
- client->jpegSrcManager->bytes_in_buffer = client->jpegBufferLen;
- client->jpegSrcManager->next_input_byte = (JOCTET *)client->jpegBufferPtr;
-
- return TRUE;
-}
-
-static void
-JpegSkipInputData(j_decompress_ptr cinfo, long num_bytes)
-{
- rfbClient* client=(rfbClient*)cinfo->client_data;
- if (num_bytes < 0 || num_bytes > client->jpegSrcManager->bytes_in_buffer) {
- client->jpegError = TRUE;
- client->jpegSrcManager->bytes_in_buffer = client->jpegBufferLen;
- client->jpegSrcManager->next_input_byte = (JOCTET *)client->jpegBufferPtr;
- } else {
- client->jpegSrcManager->next_input_byte += (size_t) num_bytes;
- client->jpegSrcManager->bytes_in_buffer -= (size_t) num_bytes;
- }
-}
-
-static void
-JpegTermSource(j_decompress_ptr cinfo)
-{
- /* nothing to do here. */
-}
-
-static void
-JpegSetSrcManager(j_decompress_ptr cinfo,
- uint8_t *compressedData,
- int compressedLen)
-{
- rfbClient* client=(rfbClient*)cinfo->client_data;
- client->jpegBufferPtr = compressedData;
- client->jpegBufferLen = (size_t)compressedLen;
-
- if(client->jpegSrcManager == NULL)
- client->jpegSrcManager = malloc(sizeof(struct jpeg_source_mgr));
- client->jpegSrcManager->init_source = JpegInitSource;
- client->jpegSrcManager->fill_input_buffer = JpegFillInputBuffer;
- client->jpegSrcManager->skip_input_data = JpegSkipInputData;
- client->jpegSrcManager->resync_to_restart = jpeg_resync_to_restart;
- client->jpegSrcManager->term_source = JpegTermSource;
- client->jpegSrcManager->next_input_byte = (JOCTET*)client->jpegBufferPtr;
- client->jpegSrcManager->bytes_in_buffer = client->jpegBufferLen;
-
- cinfo->src = client->jpegSrcManager;
-}
-
#endif
#undef CARDBPP
diff --git a/libvncclient/tls.h b/libvncclient/tls.h
index 48d159b..ffcfdeb 100644
--- a/libvncclient/tls.h
+++ b/libvncclient/tls.h
@@ -43,9 +43,14 @@ int ReadFromTLS(rfbClient* client, char *out, unsigned int n);
* It's a wrapper function over gnutls_record_send() and it will be
* blocking call, until all bytes are written or error returned.
*/
-int WriteToTLS(rfbClient* client, char *buf, unsigned int n);
+int WriteToTLS(rfbClient* client, const char *buf, unsigned int n);
/* Free TLS resources */
void FreeTLS(rfbClient* client);
+#ifdef LIBVNCSERVER_HAVE_SASL
+/* Get the number of bits in the current cipher */
+int GetTLSCipherBits(rfbClient* client);
+#endif /* LIBVNCSERVER_HAVE_SASL */
+
#endif /* TLS_H */
diff --git a/libvncclient/tls_gnutls.c b/libvncclient/tls_gnutls.c
index b9ffe89..ec3c450 100644
--- a/libvncclient/tls_gnutls.c
+++ b/libvncclient/tls_gnutls.c
@@ -18,6 +18,7 @@
*/
#include <gnutls/gnutls.h>
+#include <gnutls/x509.h>
#include <rfb/rfbclient.h>
#include <errno.h>
#ifdef WIN32
@@ -39,6 +40,98 @@ static gnutls_dh_params_t rfbDHParams;
static rfbBool rfbTLSInitialized = FALSE;
+static int
+verify_certificate_callback (gnutls_session_t session)
+{
+ unsigned int status;
+ const gnutls_datum_t *cert_list;
+ unsigned int cert_list_size;
+ int ret;
+ gnutls_x509_crt_t cert;
+ rfbClient *sptr;
+ char *hostname;
+
+ sptr = (rfbClient *)gnutls_session_get_ptr(session);
+ if (!sptr) {
+ rfbClientLog("Failed to validate certificate - missing client data\n");
+ return GNUTLS_E_CERTIFICATE_ERROR;
+ }
+
+ hostname = sptr->serverHost;
+ if (!hostname) {
+ rfbClientLog("No server hostname found for client\n");
+ return GNUTLS_E_CERTIFICATE_ERROR;
+ }
+
+ /* This verification function uses the trusted CAs in the credentials
+ * structure. So you must have installed one or more CA certificates.
+ */
+ ret = gnutls_certificate_verify_peers2 (session, &status);
+ if (ret < 0)
+ {
+ rfbClientLog ("Certificate validation call failed\n");
+ return GNUTLS_E_CERTIFICATE_ERROR;
+ }
+
+ if (status & GNUTLS_CERT_INVALID)
+ rfbClientLog("The certificate is not trusted.\n");
+
+ if (status & GNUTLS_CERT_SIGNER_NOT_FOUND)
+ rfbClientLog("The certificate hasn't got a known issuer.\n");
+
+ if (status & GNUTLS_CERT_REVOKED)
+ rfbClientLog("The certificate has been revoked.\n");
+
+ if (status & GNUTLS_CERT_EXPIRED)
+ rfbClientLog("The certificate has expired\n");
+
+ if (status & GNUTLS_CERT_NOT_ACTIVATED)
+ rfbClientLog("The certificate is not yet activated\n");
+
+ if (status)
+ return GNUTLS_E_CERTIFICATE_ERROR;
+
+ /* Up to here the process is the same for X.509 certificates and
+ * OpenPGP keys. From now on X.509 certificates are assumed. This can
+ * be easily extended to work with openpgp keys as well.
+ */
+ if (gnutls_certificate_type_get (session) != GNUTLS_CRT_X509) {
+ rfbClientLog("The certificate was not X509\n");
+ return GNUTLS_E_CERTIFICATE_ERROR;
+ }
+
+ if (gnutls_x509_crt_init (&cert) < 0)
+ {
+ rfbClientLog("Error initialising certificate structure\n");
+ return GNUTLS_E_CERTIFICATE_ERROR;
+ }
+
+ cert_list = gnutls_certificate_get_peers (session, &cert_list_size);
+ if (cert_list == NULL)
+ {
+ rfbClientLog("No certificate was found!\n");
+ return GNUTLS_E_CERTIFICATE_ERROR;
+ }
+
+ if (gnutls_x509_crt_import (cert, &cert_list[0], GNUTLS_X509_FMT_DER) < 0)
+ {
+ rfbClientLog("Error parsing certificate\n");
+ return GNUTLS_E_CERTIFICATE_ERROR;
+ }
+
+ if (!gnutls_x509_crt_check_hostname (cert, hostname))
+ {
+ rfbClientLog("The certificate's owner does not match hostname '%s'\n",
+ hostname);
+ return GNUTLS_E_CERTIFICATE_ERROR;
+ }
+
+ gnutls_x509_crt_deinit (cert);
+
+ /* notify gnutls to continue handshake normally */
+ return 0;
+}
+
static rfbBool
InitializeTLS(void)
{
@@ -52,7 +145,7 @@ InitializeTLS(void)
rfbClientLog("Failed to initialized GnuTLS: %s.\n", gnutls_strerror(ret));
return FALSE;
}
- rfbClientLog("GnuTLS initialized.\n");
+ rfbClientLog("GnuTLS version %s initialized.\n", gnutls_check_version(NULL));
rfbTLSInitialized = TRUE;
return TRUE;
}
@@ -170,7 +263,7 @@ InitializeTLSSession(rfbClient* client, rfbBool anonTLS)
static rfbBool
SetTLSAnonCredential(rfbClient* client)
{
- gnutls_anon_client_credentials anonCred;
+ gnutls_anon_client_credentials_t anonCred;
int ret;
if ((ret = gnutls_anon_allocate_client_credentials(&anonCred)) < 0 ||
@@ -200,6 +293,7 @@ HandshakeTLS(rfbClient* client)
continue;
}
rfbClientLog("TLS handshake failed: %s.\n", gnutls_strerror(ret));
+
FreeTLS(client);
return FALSE;
}
@@ -252,6 +346,10 @@ ReadVeNCryptSecurityType(rfbClient* client, uint32_t *result)
if (t==rfbVeNCryptTLSNone ||
t==rfbVeNCryptTLSVNC ||
t==rfbVeNCryptTLSPlain ||
+#ifdef LIBVNCSERVER_HAVE_SASL
+ t==rfbVeNCryptTLSSASL ||
+ t==rfbVeNCryptX509SASL ||
+#endif /*LIBVNCSERVER_HAVE_SASL */
t==rfbVeNCryptX509None ||
t==rfbVeNCryptX509VNC ||
t==rfbVeNCryptX509Plain)
@@ -411,6 +509,9 @@ HandleVeNCryptAuth(rfbClient* client)
case rfbVeNCryptTLSNone:
case rfbVeNCryptTLSVNC:
case rfbVeNCryptTLSPlain:
+#ifdef LIBVNCSERVER_HAVE_SASL
+ case rfbVeNCryptTLSSASL:
+#endif /* LIBVNCSERVER_HAVE_SASL */
anonTLS = TRUE;
break;
default:
@@ -449,6 +550,10 @@ HandleVeNCryptAuth(rfbClient* client)
}
else
{
+ /* Set the certificate verification callback. */
+ gnutls_certificate_set_verify_function (x509_cred, verify_certificate_callback);
+ gnutls_session_set_ptr ((gnutls_session_t)client->tlsSession, (void *)client);
+
if ((ret = gnutls_credentials_set((gnutls_session_t)client->tlsSession, GNUTLS_CRD_CERTIFICATE, x509_cred)) < 0)
{
rfbClientLog("Cannot set x509 credential: %s.\n", gnutls_strerror(ret));
@@ -459,8 +564,6 @@ HandleVeNCryptAuth(rfbClient* client)
if (!HandshakeTLS(client)) return FALSE;
- /* TODO: validate certificate */
-
/* We are done here. The caller should continue with client->subAuthScheme
* to do actual sub authentication.
*/
@@ -486,7 +589,7 @@ ReadFromTLS(rfbClient* client, char *out, unsigned int n)
}
int
-WriteToTLS(rfbClient* client, char *buf, unsigned int n)
+WriteToTLS(rfbClient* client, const char *buf, unsigned int n)
{
unsigned int offset = 0;
ssize_t ret;
@@ -535,3 +638,14 @@ void FreeTLS(rfbClient* client)
client->tlsSession = NULL;
}
}
+
+#ifdef LIBVNCSERVER_HAVE_SASL
+int
+GetTLSCipherBits(rfbClient* client)
+{
+ gnutls_cipher_algorithm_t cipher = gnutls_cipher_get((gnutls_session_t)client->tlsSession);
+
+ return gnutls_cipher_get_key_size(cipher) * 8;
+}
+#endif /* LIBVNCSERVER_HAVE_SASL */
+
diff --git a/libvncclient/tls_none.c b/libvncclient/tls_none.c
index 91a9f93..d436ce9 100644
--- a/libvncclient/tls_none.c
+++ b/libvncclient/tls_none.c
@@ -43,7 +43,7 @@ int ReadFromTLS(rfbClient* client, char *out, unsigned int n)
}
-int WriteToTLS(rfbClient* client, char *buf, unsigned int n)
+int WriteToTLS(rfbClient* client, const char *buf, unsigned int n)
{
rfbClientLog("TLS is not supported.\n");
errno = EINTR;
@@ -56,3 +56,12 @@ void FreeTLS(rfbClient* client)
}
+#ifdef LIBVNCSERVER_HAVE_SASL
+int
+GetTLSCipherBits(rfbClient* client)
+{
+ rfbClientLog("TLS is not supported.\n");
+ return 0;
+}
+#endif /* LIBVNCSERVER_HAVE_SASL */
+
diff --git a/libvncclient/tls_openssl.c b/libvncclient/tls_openssl.c
index 00d031d..304116a 100644
--- a/libvncclient/tls_openssl.c
+++ b/libvncclient/tls_openssl.c
@@ -164,53 +164,11 @@ InitializeTLS(void)
SSLeay_add_ssl_algorithms();
RAND_load_file("/dev/urandom", 1024);
- rfbClientLog("OpenSSL initialized.\n");
+ rfbClientLog("OpenSSL version %s initialized.\n", SSLeay_version(SSLEAY_VERSION));
rfbTLSInitialized = TRUE;
return TRUE;
}
-static int
-ssl_verify (int ok, X509_STORE_CTX *ctx)
-{
- unsigned char md5sum[16], fingerprint[40], *f;
- rfbClient *client;
- int err, i;
- unsigned int md5len;
- //char buf[257];
- X509 *cert;
- SSL *ssl;
-
- if (ok)
- return TRUE;
-
- ssl = X509_STORE_CTX_get_ex_data (ctx, SSL_get_ex_data_X509_STORE_CTX_idx ());
-
- client = SSL_CTX_get_app_data (ssl->ctx);
-
- cert = X509_STORE_CTX_get_current_cert (ctx);
- err = X509_STORE_CTX_get_error (ctx);
-
- /* calculate the MD5 hash of the raw certificate */
- md5len = sizeof (md5sum);
- X509_digest (cert, EVP_md5 (), md5sum, &md5len);
- for (i = 0, f = fingerprint; i < 16; i++, f += 3)
- sprintf ((char *) f, "%.2x%c", md5sum[i], i != 15 ? ':' : '\0');
-
-#define GET_STRING(name) X509_NAME_oneline (name, buf, 256)
-
- /* TODO: Don't just ignore certificate checks
-
- fingerprint = key to check in db
-
- GET_STRING (X509_get_issuer_name (cert));
- GET_STRING (X509_get_subject_name (cert));
- cert->valid (bool: GOOD or BAD) */
-
- ok = TRUE;
-
- return ok;
-}
-
static int sock_read_ready(SSL *ssl, uint32_t ms)
{
int r = 0;
@@ -247,8 +205,12 @@ static int wait_for_data(SSL *ssl, int ret, int timeout)
}
break;
- default:
+ default:
retval = 3;
+ long verify_res = SSL_get_verify_result(ssl);
+ if (verify_res != X509_V_OK)
+ rfbClientLog("Could not verify server certificate: %s.\n",
+ X509_verify_cert_error_string(verify_res));
break;
}
@@ -257,17 +219,131 @@ static int wait_for_data(SSL *ssl, int ret, int timeout)
return retval;
}
+static rfbBool
+load_crls_from_file(char *file, SSL_CTX *ssl_ctx)
+{
+ X509_STORE *st;
+ X509_CRL *crl;
+ int i;
+ int count = 0;
+ BIO *bio;
+ STACK_OF(X509_INFO) *xis = NULL;
+ X509_INFO *xi;
+
+ st = SSL_CTX_get_cert_store(ssl_ctx);
+
+ int rv = 0;
+
+ bio = BIO_new_file(file, "r");
+ if (bio == NULL)
+ return FALSE;
+
+ xis = PEM_X509_INFO_read_bio(bio, NULL, NULL, NULL);
+ BIO_free(bio);
+
+ for (i = 0; i < sk_X509_INFO_num(xis); i++)
+ {
+ xi = sk_X509_INFO_value(xis, i);
+ if (xi->crl)
+ {
+ X509_STORE_add_crl(st, xi->crl);
+ xi->crl = NULL;
+ count++;
+ }
+ }
+
+ sk_X509_INFO_pop_free(xis, X509_INFO_free);
+
+ if (count > 0)
+ return TRUE;
+ else
+ return FALSE;
+}
+
static SSL *
-open_ssl_connection (rfbClient *client, int sockfd, rfbBool anonTLS)
+open_ssl_connection (rfbClient *client, int sockfd, rfbBool anonTLS, rfbCredential *cred)
{
SSL_CTX *ssl_ctx = NULL;
SSL *ssl = NULL;
int n, finished = 0;
+ X509_VERIFY_PARAM *param;
+ uint8_t verify_crls = cred->x509Credential.x509CrlVerifyMode;
+
+ if (!(ssl_ctx = SSL_CTX_new(SSLv23_client_method())))
+ {
+ rfbClientLog("Could not create new SSL context.\n");
+ return NULL;
+ }
+
+ param = X509_VERIFY_PARAM_new();
+
+ /* Setup verification if not anonymous */
+ if (!anonTLS)
+ {
+ if (cred->x509Credential.x509CACertFile)
+ {
+ if (!SSL_CTX_load_verify_locations(ssl_ctx, cred->x509Credential.x509CACertFile, NULL))
+ {
+ rfbClientLog("Failed to load CA certificate from %s.\n",
+ cred->x509Credential.x509CACertFile);
+ goto error_free_ctx;
+ }
+ } else {
+ rfbClientLog("Using default paths for certificate verification.\n");
+ SSL_CTX_set_default_verify_paths (ssl_ctx);
+ }
+
+ if (cred->x509Credential.x509CACrlFile)
+ {
+ if (!load_crls_from_file(cred->x509Credential.x509CACrlFile, ssl_ctx))
+ {
+ rfbClientLog("CRLs could not be loaded.\n");
+ goto error_free_ctx;
+ }
+ if (verify_crls == rfbX509CrlVerifyNone) verify_crls = rfbX509CrlVerifyAll;
+ }
+
+ if (cred->x509Credential.x509ClientCertFile && cred->x509Credential.x509ClientKeyFile)
+ {
+ if (SSL_CTX_use_certificate_chain_file(ssl_ctx, cred->x509Credential.x509ClientCertFile) != 1)
+ {
+ rfbClientLog("Client certificate could not be loaded.\n");
+ goto error_free_ctx;
+ }
+
+ if (SSL_CTX_use_PrivateKey_file(ssl_ctx, cred->x509Credential.x509ClientKeyFile,
+ SSL_FILETYPE_PEM) != 1)
+ {
+ rfbClientLog("Client private key could not be loaded.\n");
+ goto error_free_ctx;
+ }
+
+ if (SSL_CTX_check_private_key(ssl_ctx) == 0) {
+ rfbClientLog("Client certificate and private key do not match.\n");
+ goto error_free_ctx;
+ }
+ }
+
+ SSL_CTX_set_verify(ssl_ctx, SSL_VERIFY_PEER, NULL);
- ssl_ctx = SSL_CTX_new (SSLv23_client_method ());
- SSL_CTX_set_default_verify_paths (ssl_ctx);
- SSL_CTX_set_verify (ssl_ctx, SSL_VERIFY_NONE, &ssl_verify);
- ssl = SSL_new (ssl_ctx);
+ if (verify_crls == rfbX509CrlVerifyClient)
+ X509_VERIFY_PARAM_set_flags(param, X509_V_FLAG_CRL_CHECK);
+ else if (verify_crls == rfbX509CrlVerifyAll)
+ X509_VERIFY_PARAM_set_flags(param, X509_V_FLAG_CRL_CHECK | X509_V_FLAG_CRL_CHECK_ALL);
+
+ if(!X509_VERIFY_PARAM_set1_host(param, client->serverHost, strlen(client->serverHost)))
+ {
+ rfbClientLog("Could not set server name for verification.\n");
+ goto error_free_ctx;
+ }
+ SSL_CTX_set1_param(ssl_ctx, param);
+ }
+
+ if (!(ssl = SSL_new (ssl_ctx)))
+ {
+ rfbClientLog("Could not create a new SSL session.\n");
+ goto error_free_ctx;
+ }
/* TODO: finetune this list, take into account anonTLS bool */
SSL_set_cipher_list(ssl, "ALL");
@@ -283,27 +359,34 @@ open_ssl_connection (rfbClient *client, int sockfd, rfbBool anonTLS)
{
if (wait_for_data(ssl, n, 1) != 1)
{
- finished = 1;
- if (ssl->ctx)
- SSL_CTX_free (ssl->ctx);
- SSL_free(ssl);
- SSL_shutdown (ssl);
+ finished = 1;
+ SSL_shutdown(ssl);
- return NULL;
+ goto error_free_ssl;
}
}
} while( n != 1 && finished != 1 );
+ X509_VERIFY_PARAM_free(param);
return ssl;
+
+error_free_ssl:
+ SSL_free(ssl);
+
+error_free_ctx:
+ X509_VERIFY_PARAM_free(param);
+ SSL_CTX_free(ssl_ctx);
+
+ return NULL;
}
static rfbBool
-InitializeTLSSession(rfbClient* client, rfbBool anonTLS)
+InitializeTLSSession(rfbClient* client, rfbBool anonTLS, rfbCredential *cred)
{
if (client->tlsSession) return TRUE;
- client->tlsSession = open_ssl_connection (client, client->sock, anonTLS);
+ client->tlsSession = open_ssl_connection (client, client->sock, anonTLS, cred);
if (!client->tlsSession)
return FALSE;
@@ -314,13 +397,6 @@ InitializeTLSSession(rfbClient* client, rfbBool anonTLS)
}
static rfbBool
-SetTLSAnonCredential(rfbClient* client)
-{
- rfbClientLog("TLS anonymous credential created.\n");
- return TRUE;
-}
-
-static rfbBool
HandshakeTLS(rfbClient* client)
{
int timeout = 15;
@@ -341,7 +417,8 @@ return TRUE;
timeout--;
continue;
}
- rfbClientLog("TLS handshake failed: -.\n");
+ rfbClientLog("TLS handshake failed.\n");
+
FreeTLS(client);
return FALSE;
}
@@ -394,6 +471,10 @@ ReadVeNCryptSecurityType(rfbClient* client, uint32_t *result)
if (t==rfbVeNCryptTLSNone ||
t==rfbVeNCryptTLSVNC ||
t==rfbVeNCryptTLSPlain ||
+#ifdef LIBVNCSERVER_HAVE_SASL
+ t==rfbVeNCryptTLSSASL ||
+ t==rfbVeNCryptX509SASL ||
+#endif /*LIBVNCSERVER_HAVE_SASL */
t==rfbVeNCryptX509None ||
t==rfbVeNCryptX509VNC ||
t==rfbVeNCryptX509Plain)
@@ -426,22 +507,31 @@ ReadVeNCryptSecurityType(rfbClient* client, uint32_t *result)
rfbBool
HandleAnonTLSAuth(rfbClient* client)
{
- if (!InitializeTLS() || !InitializeTLSSession(client, TRUE)) return FALSE;
-
- if (!SetTLSAnonCredential(client)) return FALSE;
+ if (!InitializeTLS() || !InitializeTLSSession(client, TRUE, NULL)) return FALSE;
if (!HandshakeTLS(client)) return FALSE;
return TRUE;
}
+static void
+FreeX509Credential(rfbCredential *cred)
+{
+ if (cred->x509Credential.x509CACertFile) free(cred->x509Credential.x509CACertFile);
+ if (cred->x509Credential.x509CACrlFile) free(cred->x509Credential.x509CACrlFile);
+ if (cred->x509Credential.x509ClientCertFile) free(cred->x509Credential.x509ClientCertFile);
+ if (cred->x509Credential.x509ClientKeyFile) free(cred->x509Credential.x509ClientKeyFile);
+ free(cred);
+}
+
rfbBool
HandleVeNCryptAuth(rfbClient* client)
{
uint8_t major, minor, status;
uint32_t authScheme;
rfbBool anonTLS;
-// gnutls_certificate_credentials_t x509_cred = NULL;
+ rfbCredential *cred = NULL;
+ rfbBool result = TRUE;
if (!InitializeTLS()) return FALSE;
@@ -486,6 +576,9 @@ HandleVeNCryptAuth(rfbClient* client)
case rfbVeNCryptTLSNone:
case rfbVeNCryptTLSVNC:
case rfbVeNCryptTLSPlain:
+#ifdef LIBVNCSERVER_HAVE_SASL
+ case rfbVeNCryptTLSSASL:
+#endif /* LIBVNCSERVER_HAVE_SASL */
anonTLS = TRUE;
break;
default:
@@ -496,7 +589,6 @@ HandleVeNCryptAuth(rfbClient* client)
/* Get X509 Credentials if it's not anonymous */
if (!anonTLS)
{
- rfbCredential *cred;
if (!client->GetCredential)
{
@@ -509,39 +601,18 @@ HandleVeNCryptAuth(rfbClient* client)
rfbClientLog("Reading credential failed\n");
return FALSE;
}
-
- /* TODO: don't just ignore this
- x509_cred = CreateX509CertCredential(cred);
- FreeX509Credential(cred);
- if (!x509_cred) return FALSE; */
}
/* Start up the TLS session */
- if (!InitializeTLSSession(client, anonTLS)) return FALSE;
+ if (!InitializeTLSSession(client, anonTLS, cred)) result = FALSE;
- if (anonTLS)
- {
- if (!SetTLSAnonCredential(client)) return FALSE;
- }
- else
- {
-/* TODO: don't just ignore this
- if ((ret = gnutls_credentials_set(client->tlsSession, GNUTLS_CRD_CERTIFICATE, x509_cred)) < 0)
- {
- rfbClientLog("Cannot set x509 credential: %s.\n", gnutls_strerror(ret));
- FreeTLS(client); */
- return FALSE;
- // }
- }
-
- if (!HandshakeTLS(client)) return FALSE;
-
- /* TODO: validate certificate */
+ if (!HandshakeTLS(client)) result = FALSE;
/* We are done here. The caller should continue with client->subAuthScheme
* to do actual sub authentication.
*/
- return TRUE;
+ if (cred) FreeX509Credential(cred);
+ return result;
}
int
@@ -565,7 +636,7 @@ ReadFromTLS(rfbClient* client, char *out, unsigned int n)
}
int
-WriteToTLS(rfbClient* client, char *buf, unsigned int n)
+WriteToTLS(rfbClient* client, const char *buf, unsigned int n)
{
unsigned int offset = 0;
ssize_t ret;
@@ -611,3 +682,14 @@ void FreeTLS(rfbClient* client)
SSL_free(client->tlsSession);
}
+#ifdef LIBVNCSERVER_HAVE_SASL
+int GetTLSCipherBits(rfbClient* client)
+{
+ SSL *ssl = (SSL *)(client->tlsSession);
+
+ const SSL_CIPHER *cipher = SSL_get_current_cipher(ssl);
+
+ return SSL_CIPHER_get_bits(cipher, NULL);
+}
+#endif /* LIBVNCSERVER_HAVE_SASL */
+
diff --git a/libvncclient/trle.c b/libvncclient/trle.c
new file mode 100644
index 0000000..b8d6e5c
--- /dev/null
+++ b/libvncclient/trle.c
@@ -0,0 +1,296 @@
+/*
+ * Copyright (C) 2017 Wiki Wang <wikiwang@live.com>. All Rights Reserved.
+ *
+ * This is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this software; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+ * USA.
+ */
+
+/*
+ * trle.c - handle trle encoding.
+ *
+ * This file shouldn't be compiled directly. It is included multiple times by
+ * rfbproto.c, each time with a different definition of the macro BPP. For
+ * each value of BPP, this file defines a function which handles a trle
+ * encoded rectangle with BPP bits per pixel.
+ */
+
+#ifndef REALBPP
+#define REALBPP BPP
+#endif
+
+#if !defined(UNCOMP) || UNCOMP == 0
+#define HandleTRLE CONCAT2E(HandleTRLE, REALBPP)
+#elif UNCOMP > 0
+#define HandleTRLE CONCAT3E(HandleTRLE, REALBPP, Down)
+#else
+#define HandleTRLE CONCAT3E(HandleTRLE, REALBPP, Up)
+#endif
+#define CARDBPP CONCAT3E(uint, BPP, _t)
+#define CARDREALBPP CONCAT3E(uint, REALBPP, _t)
+
+#if REALBPP != BPP && defined(UNCOMP) && UNCOMP != 0
+#if UNCOMP > 0
+#define UncompressCPixel(pointer) ((*(CARDBPP *)pointer) >> UNCOMP)
+#else
+#define UncompressCPixel(pointer) ((*(CARDBPP *)pointer) << (-(UNCOMP)))
+#endif
+#else
+#define UncompressCPixel(pointer) (*(CARDBPP *)pointer)
+#endif
+
+static rfbBool HandleTRLE(rfbClient *client, int rx, int ry, int rw, int rh) {
+ int x, y, w, h;
+ uint8_t type, last_type;
+ int min_buffer_size = 16 * 16 * (REALBPP / 8) * 2;
+ uint8_t *buffer;
+ CARDBPP palette[128];
+ int bpp, mask, divider;
+ CARDBPP color;
+
+ /* First make sure we have a large enough raw buffer to hold the
+ * decompressed data. In practice, with a fixed REALBPP, fixed frame
+ * buffer size and the first update containing the entire frame
+ * buffer, this buffer allocation should only happen once, on the
+ * first update.
+ */
+ if (client->raw_buffer_size < min_buffer_size) {
+
+ if (client->raw_buffer != NULL) {
+
+ free(client->raw_buffer);
+ }
+
+ client->raw_buffer_size = min_buffer_size;
+ client->raw_buffer = (char *)malloc(client->raw_buffer_size);
+ }
+
+ rfbClientLog("Update %d %d %d %d\n", rx, ry, rw, rh);
+
+ for (y = ry; y < ry + rh; y += 16) {
+ for (x = rx; x < rx + rw; x += 16) {
+ w = h = 16;
+ if (rx + rw - x < 16)
+ w = rx + rw - x;
+ if (ry + rh - y < 16)
+ h = ry + rh - y;
+
+ if (!ReadFromRFBServer(client, &type, 1))
+ return FALSE;
+
+ buffer = client->raw_buffer;
+
+ switch (type) {
+ case_0:
+ case 0: {
+ if (!ReadFromRFBServer(client, buffer, w * h * REALBPP / 8))
+ return FALSE;
+#if REALBPP != BPP
+ int i, j;
+
+ for (j = y * client->width; j < (y + h) * client->width;
+ j += client->width)
+ for (i = x; i < x + w; i++, buffer += REALBPP / 8)
+ ((CARDBPP *)client->frameBuffer)[j + i] = UncompressCPixel(buffer);
+#else
+ client->GotBitmap(client, buffer, x, y, w, h);
+#endif
+ type = last_type;
+ break;
+ }
+ case 1: {
+ if (!ReadFromRFBServer(client, buffer, REALBPP / 8))
+ return FALSE;
+
+ color = UncompressCPixel(buffer);
+
+ client->GotFillRect(client, x, y, w, h, color);
+
+ last_type = type;
+ break;
+ }
+ case_127:
+ case 127:
+ switch (last_type) {
+ case 0:
+ return FALSE;
+ case 1:
+ client->GotFillRect(client, x, y, w, h, color);
+ type = last_type;
+ break;
+ case 128:
+ return FALSE;
+ default:
+ if (last_type >= 130) {
+ last_type = last_type & 0x7f;
+
+ bpp = (last_type > 4 ? (last_type > 16 ? 8 : 4)
+ : (last_type > 2 ? 2 : 1)),
+ mask = (1 << bpp) - 1, divider = (8 / bpp);
+ }
+ if (last_type <= 16) {
+ int i, j, shift;
+
+ if (!ReadFromRFBServer(client, buffer,
+ (w + divider - 1) / divider * h))
+ return FALSE;
+
+ /* read palettized pixels */
+ for (j = y * client->width; j < (y + h) * client->width;
+ j += client->width) {
+ for (i = x, shift = 8 - bpp; i < x + w; i++) {
+ ((CARDBPP *)client->frameBuffer)[j + i] =
+ palette[((*buffer) >> shift) & mask];
+ shift -= bpp;
+ if (shift < 0) {
+ shift = 8 - bpp;
+ buffer++;
+ }
+ }
+ if (shift < 8 - bpp)
+ buffer++;
+
+ type = last_type;
+ }
+ } else
+ return FALSE;
+ }
+ break;
+ case 128: {
+ int i = 0, j = 0;
+ while (j < h) {
+ int color, length;
+ /* read color */
+ if (!ReadFromRFBServer(client, buffer, REALBPP / 8 + 1))
+ return FALSE;
+ color = UncompressCPixel(buffer);
+ buffer += REALBPP / 8;
+ /* read run length */
+ length = 1;
+ while (*buffer == 0xff) {
+ if (!ReadFromRFBServer(client, buffer + 1, 1))
+ return FALSE;
+ length += *buffer;
+ buffer++;
+ }
+ length += *buffer;
+ buffer++;
+ while (j < h && length > 0) {
+ ((CARDBPP *)client->frameBuffer)[(y + j) * client->width + x + i] =
+ color;
+ length--;
+ i++;
+ if (i >= w) {
+ i = 0;
+ j++;
+ }
+ }
+ if (length > 0)
+ rfbClientLog("Warning: possible TRLE corruption\n");
+ }
+
+ type = last_type;
+
+ break;
+ }
+ case_129:
+ case 129: {
+ int i, j;
+ /* read palettized pixels */
+ i = j = 0;
+ while (j < h) {
+ int color, length;
+ /* read color */
+ if (!ReadFromRFBServer(client, buffer, 1))
+ return FALSE;
+ color = palette[(*buffer) & 0x7f];
+ length = 1;
+ if (*buffer & 0x80) {
+ if (!ReadFromRFBServer(client, buffer + 1, 1))
+ return FALSE;
+ buffer++;
+ /* read run length */
+ while (*buffer == 0xff) {
+ if (!ReadFromRFBServer(client, buffer + 1, 1))
+ return FALSE;
+ length += *buffer;
+ buffer++;
+ }
+ length += *buffer;
+ }
+ buffer++;
+ while (j < h && length > 0) {
+ ((CARDBPP *)client->frameBuffer)[(y + j) * client->width + x + i] =
+ color;
+ length--;
+ i++;
+ if (i >= w) {
+ i = 0;
+ j++;
+ }
+ }
+ if (length > 0)
+ rfbClientLog("Warning: possible TRLE corruption\n");
+ }
+
+ if (type == 129) {
+ type = last_type;
+ }
+
+ break;
+ }
+ default:
+ if (type <= 16) {
+ int i;
+
+ bpp = (type > 4 ? (type > 16 ? 8 : 4) : (type > 2 ? 2 : 1)),
+ mask = (1 << bpp) - 1, divider = (8 / bpp);
+
+ if (!ReadFromRFBServer(client, buffer, type * REALBPP / 8))
+ return FALSE;
+
+ /* read palette */
+ for (i = 0; i < type; i++, buffer += REALBPP / 8)
+ palette[i] = UncompressCPixel(buffer);
+
+ last_type = type;
+ goto case_127;
+ } else if (type >= 130) {
+ int i;
+
+ if (!ReadFromRFBServer(client, buffer, (type - 128) * REALBPP / 8))
+ return FALSE;
+
+ /* read palette */
+ for (i = 0; i < type - 128; i++, buffer += REALBPP / 8)
+ palette[i] = UncompressCPixel(buffer);
+
+ last_type = type;
+ goto case_129;
+ } else
+ return FALSE;
+ }
+ last_type = type;
+ }
+ }
+
+ return TRUE;
+}
+
+#undef CARDBPP
+#undef CARDREALBPP
+#undef HandleTRLE
+#undef UncompressCPixel
+#undef REALBPP
+#undef UNCOMP
diff --git a/libvncclient/ultra.c b/libvncclient/ultra.c
index 32a1b2b..a287526 100644
--- a/libvncclient/ultra.c
+++ b/libvncclient/ultra.c
@@ -66,6 +66,8 @@ HandleUltraBPP (rfbClient* client, int rx, int ry, int rw, int rh)
if ((client->raw_buffer_size % 4)!=0)
client->raw_buffer_size += (4-(client->raw_buffer_size % 4));
client->raw_buffer = (char*) malloc( client->raw_buffer_size );
+ if(client->raw_buffer == NULL)
+ return FALSE;
}
/* allocate enough space to store the incoming compressed packet */
@@ -98,7 +100,7 @@ HandleUltraBPP (rfbClient* client, int rx, int ry, int rw, int rh)
/* Put the uncompressed contents of the update on the screen. */
if ( inflateResult == LZO_E_OK )
{
- CopyRectangle(client, (unsigned char *)client->raw_buffer, rx, ry, rw, rh);
+ client->GotBitmap(client, (unsigned char *)client->raw_buffer, rx, ry, rw, rh);
}
else
{
@@ -150,6 +152,8 @@ HandleUltraZipBPP (rfbClient* client, int rx, int ry, int rw, int rh)
if ((client->raw_buffer_size % 4)!=0)
client->raw_buffer_size += (4-(client->raw_buffer_size % 4));
client->raw_buffer = (char*) malloc( client->raw_buffer_size );
+ if(client->raw_buffer == NULL)
+ return FALSE;
}
@@ -199,7 +203,7 @@ HandleUltraZipBPP (rfbClient* client, int rx, int ry, int rw, int rh)
if (se == rfbEncodingRaw)
{
- CopyRectangle(client, (unsigned char *)ptr, sx, sy, sw, sh);
+ client->GotBitmap(client, (unsigned char *)ptr, sx, sy, sw, sh);
ptr += ((sw * sh) * (BPP / 8));
}
}
diff --git a/libvncclient/vncviewer.c b/libvncclient/vncviewer.c
index 8a59c6d..486390e 100644
--- a/libvncclient/vncviewer.c
+++ b/libvncclient/vncviewer.c
@@ -109,6 +109,125 @@ static rfbBool MallocFrameBuffer(rfbClient* client) {
return client->frameBuffer?TRUE:FALSE;
}
+/* messages */
+
+static rfbBool CheckRect(rfbClient* client, int x, int y, int w, int h) {
+ return x + w <= client->width && y + h <= client->height;
+}
+
+static void FillRectangle(rfbClient* client, int x, int y, int w, int h, uint32_t colour) {
+ int i,j;
+
+ if (client->frameBuffer == NULL) {
+ return;
+ }
+
+ if (!CheckRect(client, x, y, w, h)) {
+ rfbClientLog("Rect out of bounds: %dx%d at (%d, %d)\n", x, y, w, h);
+ return;
+ }
+
+#define FILL_RECT(BPP) \
+ for(j=y*client->width;j<(y+h)*client->width;j+=client->width) \
+ for(i=x;i<x+w;i++) \
+ ((uint##BPP##_t*)client->frameBuffer)[j+i]=colour;
+
+ switch(client->format.bitsPerPixel) {
+ case 8: FILL_RECT(8); break;
+ case 16: FILL_RECT(16); break;
+ case 32: FILL_RECT(32); break;
+ default:
+ rfbClientLog("Unsupported bitsPerPixel: %d\n",client->format.bitsPerPixel);
+ }
+}
+
+static void CopyRectangle(rfbClient* client, const uint8_t* buffer, int x, int y, int w, int h) {
+ int j;
+
+ if (client->frameBuffer == NULL) {
+ return;
+ }
+
+ if (!CheckRect(client, x, y, w, h)) {
+ rfbClientLog("Rect out of bounds: %dx%d at (%d, %d)\n", x, y, w, h);
+ return;
+ }
+
+#define COPY_RECT(BPP) \
+ { \
+ int rs = w * BPP / 8, rs2 = client->width * BPP / 8; \
+ for (j = ((x * (BPP / 8)) + (y * rs2)); j < (y + h) * rs2; j += rs2) { \
+ memcpy(client->frameBuffer + j, buffer, rs); \
+ buffer += rs; \
+ } \
+ }
+
+ switch(client->format.bitsPerPixel) {
+ case 8: COPY_RECT(8); break;
+ case 16: COPY_RECT(16); break;
+ case 32: COPY_RECT(32); break;
+ default:
+ rfbClientLog("Unsupported bitsPerPixel: %d\n",client->format.bitsPerPixel);
+ }
+}
+
+/* TODO: test */
+static void CopyRectangleFromRectangle(rfbClient* client, int src_x, int src_y, int w, int h, int dest_x, int dest_y) {
+ int i,j;
+
+ if (client->frameBuffer == NULL) {
+ return;
+ }
+
+ if (!CheckRect(client, src_x, src_y, w, h)) {
+ rfbClientLog("Source rect out of bounds: %dx%d at (%d, %d)\n", src_x, src_y, w, h);
+ return;
+ }
+
+ if (!CheckRect(client, dest_x, dest_y, w, h)) {
+ rfbClientLog("Dest rect out of bounds: %dx%d at (%d, %d)\n", dest_x, dest_y, w, h);
+ return;
+ }
+
+#define COPY_RECT_FROM_RECT(BPP) \
+ { \
+ uint##BPP##_t* _buffer=((uint##BPP##_t*)client->frameBuffer)+(src_y-dest_y)*client->width+src_x-dest_x; \
+ if (dest_y < src_y) { \
+ for(j = dest_y*client->width; j < (dest_y+h)*client->width; j += client->width) { \
+ if (dest_x < src_x) { \
+ for(i = dest_x; i < dest_x+w; i++) { \
+ ((uint##BPP##_t*)client->frameBuffer)[j+i]=_buffer[j+i]; \
+ } \
+ } else { \
+ for(i = dest_x+w-1; i >= dest_x; i--) { \
+ ((uint##BPP##_t*)client->frameBuffer)[j+i]=_buffer[j+i]; \
+ } \
+ } \
+ } \
+ } else { \
+ for(j = (dest_y+h-1)*client->width; j >= dest_y*client->width; j-=client->width) { \
+ if (dest_x < src_x) { \
+ for(i = dest_x; i < dest_x+w; i++) { \
+ ((uint##BPP##_t*)client->frameBuffer)[j+i]=_buffer[j+i]; \
+ } \
+ } else { \
+ for(i = dest_x+w-1; i >= dest_x; i--) { \
+ ((uint##BPP##_t*)client->frameBuffer)[j+i]=_buffer[j+i]; \
+ } \
+ } \
+ } \
+ } \
+ }
+
+ switch(client->format.bitsPerPixel) {
+ case 8: COPY_RECT_FROM_RECT(8); break;
+ case 16: COPY_RECT_FROM_RECT(16); break;
+ case 32: COPY_RECT_FROM_RECT(32); break;
+ default:
+ rfbClientLog("Unsupported bitsPerPixel: %d\n",client->format.bitsPerPixel);
+ }
+}
+
static void initAppData(AppData* data) {
data->shareDesktop=TRUE;
data->viewOnly=FALSE;
@@ -157,7 +276,7 @@ rfbClient* rfbGetClient(int bitsPerSample,int samplesPerPixel,
client->format.depth = bitsPerSample*samplesPerPixel;
client->appData.requestedDepth=client->format.depth;
client->format.bigEndian = *(char *)&client->endianTest?FALSE:TRUE;
- client->format.trueColour = TRUE;
+ client->format.trueColour = 1;
if (client->format.bitsPerPixel == 8) {
client->format.redMax = 7;
@@ -196,7 +315,6 @@ rfbClient* rfbGetClient(int bitsPerSample,int samplesPerPixel,
#ifdef LIBVNCSERVER_HAVE_LIBJPEG
memset(client->zlibStreamActive,0,sizeof(rfbBool)*4);
- client->jpegSrcManager = NULL;
#endif
#endif
@@ -204,6 +322,9 @@ rfbClient* rfbGetClient(int bitsPerSample,int samplesPerPixel,
client->SoftCursorLockArea = DummyRect;
client->SoftCursorUnlockScreen = Dummy;
client->GotFrameBufferUpdate = DummyRect;
+ client->GotCopyRect = CopyRectangleFromRectangle;
+ client->GotFillRect = FillRectangle;
+ client->GotBitmap = CopyRectangle;
client->FinishedFrameBufferUpdate = NULL;
client->GetPassword = ReadPassword;
client->MallocFrameBuffer = MallocFrameBuffer;
@@ -224,6 +345,13 @@ rfbClient* rfbGetClient(int bitsPerSample,int samplesPerPixel,
client->listen6Sock = -1;
client->listen6Address = NULL;
client->clientAuthSchemes = NULL;
+
+#ifdef LIBVNCSERVER_HAVE_SASL
+ client->GetSASLMechanism = NULL;
+ client->GetUser = NULL;
+ client->saslSecret = NULL;
+#endif /* LIBVNCSERVER_HAVE_SASL */
+
return client;
}
@@ -390,12 +518,15 @@ void rfbClientCleanup(rfbClient* client) {
client->decompStream.msg != NULL)
rfbClientLog("inflateEnd: %s\n", client->decompStream.msg );
}
-
- if (client->jpegSrcManager)
- free(client->jpegSrcManager);
#endif
#endif
+ if (client->ultra_buffer)
+ free(client->ultra_buffer);
+
+ if (client->raw_buffer)
+ free(client->raw_buffer);
+
FreeTLS(client);
while (client->clientData) {
@@ -414,5 +545,11 @@ void rfbClientCleanup(rfbClient* client) {
free(client->destHost);
if (client->clientAuthSchemes)
free(client->clientAuthSchemes);
+
+#ifdef LIBVNCSERVER_HAVE_SASL
+ if (client->saslSecret)
+ free(client->saslSecret);
+#endif /* LIBVNCSERVER_HAVE_SASL */
+
free(client);
}
diff --git a/libvncclient/zlib.c b/libvncclient/zlib.c
index e872d40..fc6f138 100644
--- a/libvncclient/zlib.c
+++ b/libvncclient/zlib.c
@@ -142,7 +142,7 @@ HandleZlibBPP (rfbClient* client, int rx, int ry, int rw, int rh)
if ( inflateResult == Z_OK ) {
/* Put the uncompressed contents of the update on the screen. */
- CopyRectangle(client, (uint8_t *)client->raw_buffer, rx, ry, rw, rh);
+ client->GotBitmap(client, (uint8_t *)client->raw_buffer, rx, ry, rw, rh);
}
else {
diff --git a/libvncclient/zrle.c b/libvncclient/zrle.c
index 0128146..ceba15a 100644
--- a/libvncclient/zrle.c
+++ b/libvncclient/zrle.c
@@ -278,7 +278,7 @@ static int HandleZRLETile(rfbClient* client,
for(i=x; i<x+w; i++,buffer+=REALBPP/8)
((CARDBPP*)client->frameBuffer)[j+i] = UncompressCPixel(buffer);
#else
- CopyRectangle(client, buffer, x, y, w, h);
+ client->GotBitmap(client, buffer, x, y, w, h);
buffer+=w*h*REALBPP/8;
#endif
}
@@ -289,7 +289,7 @@ static int HandleZRLETile(rfbClient* client,
if(1+REALBPP/8>buffer_length)
return -4;
- FillRectangle(client, x, y, w, h, color);
+ client->GotFillRect(client, x, y, w, h, color);
buffer+=REALBPP/8;
@@ -420,8 +420,8 @@ static int HandleZRLETile(rfbClient* client,
#undef HandleZRLE
#undef HandleZRLETile
#undef UncompressCPixel
-#undef REALBPP
#endif
#undef UNCOMP
+#undef REALBPP
diff --git a/libvncserver-config.in b/libvncserver-config.in
deleted file mode 100644
index ea0bef8..0000000
--- a/libvncserver-config.in
+++ /dev/null
@@ -1,78 +0,0 @@
-#!/bin/sh
-
-prefix=@prefix@
-exec_prefix=@exec_prefix@
-exec_prefix_set=no
-includedir=@includedir@
-libdir=@libdir@
-
-# if this script is in the same directory as libvncserver-config.in, assume not installed
-if [ -f "`dirname "$0"`/libvncserver-config.in" ]; then
- dir="`dirname "$0"`"
- prefix="`cd "$dir"; pwd`"
- includedir="$prefix"
- libdir="$prefix/libvncserver/.libs $prefix/libvncclient/.libs"
-fi
-
-usage="\
-Usage: @PACKAGE@-config [--prefix[=DIR]] [--exec-prefix[=DIR]] [--version] [--link] [--libs] [--cflags]"
-
-if test $# -eq 0; then
- echo "${usage}" 1>&2
- exit 1
-fi
-
-while test $# -gt 0; do
- case "$1" in
- -*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
- *) optarg= ;;
- esac
-
- case $1 in
- --prefix=*)
- prefix=$optarg
- if test $exec_prefix_set = no ; then
- exec_prefix=$optarg
- fi
- ;;
- --prefix)
- echo $prefix
- ;;
- --exec-prefix=*)
- exec_prefix=$optarg
- exec_prefix_set=yes
- ;;
- --exec-prefix)
- echo $exec_prefix
- ;;
- --version)
- echo @VERSION@
- ;;
- --cflags)
- if [ "$includedir" != /usr/include ]; then
- includes=-I"$includedir"
- fi
- echo "$includes"
- ;;
- --libs)
- libs=""
- for dir in $libdir; do
- libs="$libs -L$dir"
- if [ "`uname`" = "SunOS" ]; then
- # why only Solaris??
- libs="$libs -R$dir"
- fi
- done
- echo "$libs" -lvncserver -lvncclient @LIBS@ @WSOCKLIB@
- ;;
- --link)
- echo @CC@
- ;;
- *)
- echo "${usage}" 1>&2
- exit 1
- ;;
- esac
- shift
-done
-
diff --git a/libvncserver.pc.cmakein b/libvncserver.pc.cmakein
new file mode 100644
index 0000000..f38d74f
--- /dev/null
+++ b/libvncserver.pc.cmakein
@@ -0,0 +1,13 @@
+prefix=@CMAKE_INSTALL_PREFIX@
+exec_prefix=@CMAKE_INSTALL_PREFIX@
+libdir=@CMAKE_INSTALL_PREFIX@/lib
+includedir=@CMAKE_INSTALL_PREFIX@/include
+
+Name: LibVNCServer
+Description: A library for easy implementation of a VNC server.
+Version: @PACKAGE_VERSION@
+Requires:
+Requires.private: zlib
+Libs: -L${libdir} -lvncserver
+Libs.private: @PRIVATE_LIBS@
+Cflags: -I${includedir}
diff --git a/libvncserver.pc.in b/libvncserver.pc.in
deleted file mode 100644
index d246052..0000000
--- a/libvncserver.pc.in
+++ /dev/null
@@ -1,14 +0,0 @@
-prefix=@prefix@
-exec_prefix=@exec_prefix@
-libdir=@libdir@
-includedir=@includedir@
-
-Name: LibVNCServer
-Description: A library for easy implementation of a VNC server.
-Version: @VERSION@
-Requires:
-Requires.private: zlib
-Libs: -L${libdir} -lvncserver
-Libs.private: @LIBS@ @WSOCKLIB@
-Cflags: -I${includedir}
-
diff --git a/libvncserver/Makefile.am b/libvncserver/Makefile.am
deleted file mode 100644
index e25784b..0000000
--- a/libvncserver/Makefile.am
+++ /dev/null
@@ -1,80 +0,0 @@
-AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/common
-
-if WITH_TIGHTVNC_FILETRANSFER
-TIGHTVNCFILETRANSFERHDRS=tightvnc-filetransfer/filelistinfo.h \
- tightvnc-filetransfer/filetransfermsg.h \
- tightvnc-filetransfer/handlefiletransferrequest.h \
- tightvnc-filetransfer/rfbtightproto.h
-
-TIGHTVNCFILETRANSFERSRCS = tightvnc-filetransfer/rfbtightserver.c \
- tightvnc-filetransfer/handlefiletransferrequest.c \
- tightvnc-filetransfer/filetransfermsg.c \
- tightvnc-filetransfer/filelistinfo.c
-endif
-
-if WITH_WEBSOCKETS
-
-if HAVE_GNUTLS
-WEBSOCKETSSSLSRCS = rfbssl_gnutls.c rfbcrypto_gnutls.c
-WEBSOCKETSSSLLIBS = @GNUTLS_LIBS@
-else
-if HAVE_LIBSSL
-WEBSOCKETSSSLSRCS = rfbssl_openssl.c rfbcrypto_openssl.c
-WEBSOCKETSSSLLIBS = @SSL_LIBS@ @CRYPT_LIBS@
-else
-WEBSOCKETSSSLSRCS = rfbssl_none.c rfbcrypto_included.c ../common/md5.c ../common/sha1.c
-endif
-endif
-
-WEBSOCKETSSRCS = websockets.c $(WEBSOCKETSSSLSRCS)
-endif
-
-includedir=$(prefix)/include/rfb
-
-include_HEADERS=../rfb/rfb.h ../rfb/rfbconfig.h \
- ../rfb/rfbproto.h ../rfb/keysym.h ../rfb/rfbregion.h ../rfb/rfbclient.h
-
-noinst_HEADERS=../common/d3des.h ../rfb/default8x16.h zrleoutstream.h \
- zrlepalettehelper.h zrletypes.h private.h scale.h rfbssl.h rfbcrypto.h \
- ../common/minilzo.h ../common/lzoconf.h ../common/lzodefs.h ../common/md5.h ../common/sha.h ../common/sha-private.h \
- $(TIGHTVNCFILETRANSFERHDRS)
-
-EXTRA_DIST=tableinit24.c tableinittctemplate.c tabletranstemplate.c \
- tableinitcmtemplate.c tabletrans24template.c \
- zrleencodetemplate.c
-
-if HAVE_LIBZ
-ZLIBSRCS = zlib.c zrle.c zrleoutstream.c zrlepalettehelper.c ../common/zywrletemplate.c
-if HAVE_LIBJPEG
-TIGHTSRCS = tight.c ../common/turbojpeg.c
-endif
-endif
-
-LIB_SRCS = main.c rfbserver.c rfbregion.c auth.c sockets.c $(WEBSOCKETSSRCS) \
- stats.c corre.c hextile.c rre.c translate.c cutpaste.c \
- httpd.c cursor.c font.c \
- draw.c selbox.c ../common/d3des.c ../common/vncauth.c cargs.c ../common/minilzo.c ultra.c scale.c \
- $(ZLIBSRCS) $(TIGHTSRCS) $(TIGHTVNCFILETRANSFERSRCS)
-
-libvncserver_la_SOURCES=$(LIB_SRCS)
-libvncserver_la_LIBADD=$(WEBSOCKETSSSLLIBS)
-
-if WITH_SYSTEMD
-AM_CPPFLAGS += -DLIBVNCSERVER_WITH_SYSTEMD
-libvncserver_la_CFLAGS = $(LIBSYSTEMD_CFLAGS)
-libvncserver_la_LIBADD += $(LIBSYSTEMD_LIBS)
-endif
-
-lib_LTLIBRARIES=libvncserver.la
-libvncserver_la_LDFLAGS = -version-info 1:0:0
-
-if HAVE_RPM
-$(PACKAGE)-$(VERSION).tar.gz: dist
-
-# Rule to build RPM distribution package
-rpm: $(PACKAGE)-$(VERSION).tar.gz libvncserver.spec
- cp $(PACKAGE)-$(VERSION).tar.gz @RPMSOURCEDIR@
- rpmbuild -ba libvncserver.spec
-endif
-
-
diff --git a/libvncserver/cargs.c b/libvncserver/cargs.c
index 4da04b5..85b937d 100644
--- a/libvncserver/cargs.c
+++ b/libvncserver/cargs.c
@@ -43,6 +43,10 @@ rfbUsage(void)
"new non-shared\n"
" connection comes in (refuse new connection "
"instead)\n");
+#ifdef LIBVNCSERVER_WITH_WEBSOCKETS
+ fprintf(stderr, "-sslkeyfile path set path to private key file for encrypted WebSockets connections\n");
+ fprintf(stderr, "-sslcertfile path set path to certificate file for encrypted WebSockets connections\n");
+#endif
fprintf(stderr, "-httpdir dir-path enable http server using dir-path home\n");
fprintf(stderr, "-httpport portnum use portnum for http connection\n");
#ifdef LIBVNCSERVER_IPv6
diff --git a/libvncserver/cursor.c b/libvncserver/cursor.c
index c071dd9..8779470 100644
--- a/libvncserver/cursor.c
+++ b/libvncserver/cursor.c
@@ -456,10 +456,10 @@ void rfbMakeRichCursorFromXCursor(rfbScreenInfoPtr rfbScreen,rfbCursorPtr cursor
fore+=4-bpp;
}
- background=cursor->backRed<<format->redShift|
- cursor->backGreen<<format->greenShift|cursor->backBlue<<format->blueShift;
- foreground=cursor->foreRed<<format->redShift|
- cursor->foreGreen<<format->greenShift|cursor->foreBlue<<format->blueShift;
+ background=(uint32_t)cursor->backRed<<format->redShift|
+ (uint32_t)cursor->backGreen<<format->greenShift|(uint32_t)cursor->backBlue<<format->blueShift;
+ foreground=(uint32_t)cursor->foreRed<<format->redShift|
+ (uint32_t)cursor->foreGreen<<format->greenShift|(uint32_t)cursor->foreBlue<<format->blueShift;
for(j=0;j<cursor->height;j++)
for(i=0,bit=0x80;i<cursor->width;i++,bit=(bit&1)?0x80:bit>>1,cp+=bpp)
diff --git a/libvncserver/font.c b/libvncserver/font.c
index a9091d2..9935e91 100644
--- a/libvncserver/font.c
+++ b/libvncserver/font.c
@@ -174,6 +174,7 @@ rfbFontDataPtr rfbLoadConsoleFont(char *filename)
if(1!=fread(p->data,4096,1,f)) {
free(p->data);
free(p);
+ fclose(f);
return NULL;
}
fclose(f);
diff --git a/libvncserver/httpd.c b/libvncserver/httpd.c
index 80adbcf..a3ef74d 100644
--- a/libvncserver/httpd.c
+++ b/libvncserver/httpd.c
@@ -42,6 +42,7 @@
#include <winsock2.h>
#include <ws2tcpip.h>
#define close closesocket
+#define strcasecmp _stricmp
#if defined(_MSC_VER)
#include <BaseTsd.h> /* For the missing ssize_t */
#define ssize_t SSIZE_T
@@ -456,6 +457,8 @@ httpProcessInput(rfbScreenInfoPtr rfbScreen)
contentType = "Content-Type: text/css\r\n";
else if(ext && strcasecmp(ext, ".svg") == 0)
contentType = "Content-Type: image/svg+xml\r\n";
+ else if(ext && strcasecmp(ext, ".js") == 0)
+ contentType = "Content-Type: application/javascript\r\n";
rfbWriteExact(&cl, contentType, strlen(contentType));
/* end the header */
rfbWriteExact(&cl, "\r\n", 2);
diff --git a/libvncserver/main.c b/libvncserver/main.c
index c185eb8..74010d0 100644
--- a/libvncserver/main.c
+++ b/libvncserver/main.c
@@ -32,6 +32,7 @@ extern "C" {
#include <sys/socket.h>
#include <netinet/in.h>
#include <unistd.h>
+ #include <fcntl.h>
#endif
#include <signal.h>
@@ -282,7 +283,16 @@ rfbLogProc rfbErr=rfbDefaultLog;
void rfbLogPerror(const char *str)
{
+#ifdef WIN32
+ wchar_t *s = NULL;
+ FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
+ NULL, errno, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
+ (LPWSTR)&s, 0, NULL);
+ rfbErr("%s: %S\n", str, s);
+ LocalFree(s);
+#else
rfbErr("%s: %s\n", str, strerror(errno));
+#endif
}
void rfbScheduleCopyRegion(rfbScreenInfoPtr rfbScreen,sraRegionPtr copyRegion,int dx,int dy)
@@ -550,6 +560,7 @@ clientInput(void *data)
FD_ZERO(&rfds);
FD_SET(cl->sock, &rfds);
+ FD_SET(cl->pipe_notify_client_thread[0], &rfds);
FD_ZERO(&efds);
FD_SET(cl->sock, &efds);
@@ -558,9 +569,13 @@ clientInput(void *data)
if ((cl->fileTransfer.fd!=-1) && (cl->fileTransfer.sending==1))
FD_SET(cl->sock, &wfds);
+ int nfds = cl->pipe_notify_client_thread[0] > cl->sock ? cl->pipe_notify_client_thread[0] : cl->sock;
+
tv.tv_sec = 60; /* 1 minute */
tv.tv_usec = 0;
- n = select(cl->sock + 1, &rfds, &wfds, &efds, &tv);
+
+ n = select(nfds + 1, &rfds, &wfds, &efds, &tv);
+
if (n < 0) {
rfbLogPerror("ReadExact: select");
break;
@@ -575,6 +590,13 @@ clientInput(void *data)
if (FD_ISSET(cl->sock, &wfds))
rfbSendFileTransferChunk(cl);
+ if (FD_ISSET(cl->pipe_notify_client_thread[0], &rfds))
+ {
+ /* Reset the pipe */
+ char buf;
+ while (read(cl->pipe_notify_client_thread[0], &buf, sizeof(buf)) == sizeof(buf));
+ }
+
if (FD_ISSET(cl->sock, &rfds) || FD_ISSET(cl->sock, &efds))
{
#ifdef LIBVNCSERVER_WITH_WEBSOCKETS
@@ -669,8 +691,15 @@ rfbStartOnHoldClient(rfbClientPtr cl)
{
cl->onHold = FALSE;
#ifdef LIBVNCSERVER_HAVE_LIBPTHREAD
- if(cl->screen->backgroundLoop)
- pthread_create(&cl->client_thread, NULL, clientInput, (void *)cl);
+ if(cl->screen->backgroundLoop) {
+ if (pipe(cl->pipe_notify_client_thread) == -1) {
+ cl->pipe_notify_client_thread[0] = -1;
+ cl->pipe_notify_client_thread[1] = -1;
+ }
+ fcntl(cl->pipe_notify_client_thread[0], F_SETFL, O_NONBLOCK);
+
+ pthread_create(&cl->client_thread, NULL, clientInput, (void *)cl);
+ }
#endif
}
@@ -1119,7 +1148,15 @@ void rfbInitServer(rfbScreenInfoPtr screen)
{
#ifdef WIN32
WSADATA trash;
- WSAStartup(MAKEWORD(2,2),&trash);
+ static rfbBool WSAinitted=FALSE;
+ if(!WSAinitted) {
+ int i=WSAStartup(MAKEWORD(2,0),&trash);
+ if(i!=0) {
+ rfbErr("Couldn't init Windows Sockets\n");
+ return;
+ }
+ WSAinitted=TRUE;
+ }
#endif
rfbInitSockets(screen);
rfbHttpInitSockets(screen);
@@ -1131,15 +1168,32 @@ void rfbInitServer(rfbScreenInfoPtr screen)
void rfbShutdownServer(rfbScreenInfoPtr screen,rfbBool disconnectClients) {
if(disconnectClients) {
- rfbClientPtr cl;
rfbClientIteratorPtr iter = rfbGetClientIterator(screen);
- while( (cl = rfbClientIteratorNext(iter)) ) {
- if (cl->sock > -1) {
- /* we don't care about maxfd here, because the server goes away */
- rfbCloseClient(cl);
- rfbClientConnectionGone(cl);
+ rfbClientPtr nextCl, currentCl = rfbClientIteratorNext(iter);
+
+ while(currentCl) {
+ nextCl = rfbClientIteratorNext(iter);
+ if (currentCl->sock > -1) {
+ /* we don't care about maxfd here, because the server goes away */
+ rfbCloseClient(currentCl);
}
+
+#ifdef LIBVNCSERVER_HAVE_LIBPTHREAD
+ /*
+ Notify the thread. This simply writes a NULL byte to the notify pipe in order to get past the select()
+ in clientInput(), the loop in there will then break because the rfbCloseClient() above has set
+ currentCl->sock to -1.
+ */
+ write(currentCl->pipe_notify_client_thread[1], "\x00", 1);
+ /* And wait for it to finish. */
+ pthread_join(currentCl->client_thread, NULL);
+#else
+ rfbClientConnectionGone(currentCl);
+#endif
+
+ currentCl = nextCl;
}
+
rfbReleaseClientIterator(iter);
}
diff --git a/libvncserver/rfbcrypto_polarssl.c b/libvncserver/rfbcrypto_polarssl.c
deleted file mode 100644
index 55e3a7b..0000000
--- a/libvncserver/rfbcrypto_polarssl.c
+++ /dev/null
@@ -1,26 +0,0 @@
-#include <string.h>
-#include <polarssl/md5.h>
-#include <polarssl/sha1.h>
-#include "rfbcrypto.h"
-
-void digestmd5(const struct iovec *iov, int iovcnt, void *dest)
-{
- md5_context c;
- int i;
-
- md5_starts(&c);
- for (i = 0; i < iovcnt; i++)
- md5_update(&c, iov[i].iov_base, iov[i].iov_len);
- md5_finish(&c, dest);
-}
-
-void digestsha1(const struct iovec *iov, int iovcnt, void *dest)
-{
- sha1_context c;
- int i;
-
- sha1_starts(&c);
- for (i = 0; i < iovcnt; i++)
- sha1_update(&c, iov[i].iov_base, iov[i].iov_len);
- sha1_finish(&c, dest);
-}
diff --git a/libvncserver/rfbserver.c b/libvncserver/rfbserver.c
index fa8423d..182d18b 100644
--- a/libvncserver/rfbserver.c
+++ b/libvncserver/rfbserver.c
@@ -32,6 +32,7 @@
#include <rfb/rfb.h>
#include <rfb/rfbregion.h>
#include "private.h"
+#include "rfb/rfbconfig.h"
#ifdef LIBVNCSERVER_HAVE_FCNTL_H
#include <fcntl.h>
@@ -69,7 +70,9 @@
/* stst() */
#include <sys/types.h>
#include <sys/stat.h>
+#if LIBVNCSERVER_HAVE_UNISTD_H
#include <unistd.h>
+#endif
#ifndef WIN32
/* readdir() */
@@ -457,9 +460,7 @@ rfbNewTCPOrUDPClient(rfbScreenInfoPtr rfbScreen,
#ifdef LIBVNCSERVER_WITH_WEBSOCKETS
/*
- * Wait a few ms for the client to send one of:
- * - Flash policy request
- * - WebSockets connection (TLS/SSL or plain)
+ * Wait a few ms for the client to send WebSockets connection (TLS/SSL or plain)
*/
if (!webSocketsCheck(cl)) {
/* Error reporting handled in webSocketsHandshake */
@@ -615,6 +616,11 @@ rfbClientConnectionGone(rfbClientPtr cl)
UNLOCK(cl->sendMutex);
TINI_MUTEX(cl->sendMutex);
+#ifdef LIBVNCSERVER_HAVE_LIBPTHREAD
+ close(cl->pipe_notify_client_thread[0]);
+ close(cl->pipe_notify_client_thread[1]);
+#endif
+
rfbPrintStats(cl);
rfbResetStats(cl);
@@ -1457,11 +1463,21 @@ char *rfbProcessFileTransferReadBuffer(rfbClientPtr cl, uint32_t length)
int n=0;
FILEXFER_ALLOWED_OR_CLOSE_AND_RETURN("", cl, NULL);
+
/*
- rfbLog("rfbProcessFileTransferReadBuffer(%dlen)\n", length);
+ We later alloc length+1, which might wrap around on 32-bit systems if length equals
+ 0XFFFFFFFF, i.e. SIZE_MAX for 32-bit systems. On 64-bit systems, a length of 0XFFFFFFFF
+ will safely be allocated since this check will never trigger and malloc() can digest length+1
+ without problems as length is a uint32_t.
*/
+ if(length == SIZE_MAX) {
+ rfbErr("rfbProcessFileTransferReadBuffer: too big file transfer length requested: %u", (unsigned int)length);
+ rfbCloseClient(cl);
+ return NULL;
+ }
+
if (length>0) {
- buffer=malloc(length+1);
+ buffer=malloc((size_t)length+1);
if (buffer!=NULL) {
if ((n = rfbReadExact(cl, (char *)buffer, length)) <= 0) {
if (n != 0)
@@ -1993,11 +2009,6 @@ rfbProcessClientNormalMessage(rfbClientPtr cl)
char encBuf[64];
char encBuf2[64];
-#ifdef LIBVNCSERVER_WITH_WEBSOCKETS
- if (cl->wsctx && webSocketCheckDisconnect(cl))
- return;
-#endif
-
if ((n = rfbReadExact(cl, (char *)&msg, 1)) <= 0) {
if (n != 0)
rfbLogPerror("rfbProcessClientNormalMessage: read");
@@ -2582,7 +2593,22 @@ rfbProcessClientNormalMessage(rfbClientPtr cl)
msg.cct.length = Swap32IfLE(msg.cct.length);
- str = (char *)malloc(msg.cct.length);
+ /* uint32_t input is passed to malloc()'s size_t argument,
+ * to rfbReadExact()'s int argument, to rfbStatRecordMessageRcvd()'s int
+ * argument increased of sz_rfbClientCutTextMsg, and to setXCutText()'s int
+ * argument. Here we impose a limit of 1 MB so that the value fits
+ * into all of the types to prevent from misinterpretation and thus
+ * from accessing uninitialized memory (CVE-2018-7225) and also to
+ * prevent from a denial-of-service by allocating too much memory in
+ * the server. */
+ if (msg.cct.length > 1<<20) {
+ rfbLog("rfbClientCutText: too big cut text length requested: %u B > 1 MB\n", (unsigned int)msg.cct.length);
+ rfbCloseClient(cl);
+ return;
+ }
+
+ /* Allow zero-length client cut text. */
+ str = (char *)calloc(msg.cct.length ? msg.cct.length : 1, 1);
if (str == NULL) {
rfbLogPerror("rfbProcessClientNormalMessage: not enough memory");
rfbCloseClient(cl);
diff --git a/libvncserver/scale.c b/libvncserver/scale.c
index bf67f8e..7a63e86 100644
--- a/libvncserver/scale.c
+++ b/libvncserver/scale.c
@@ -63,7 +63,18 @@
(double) ((int) (x)) : (double) ((int) (x) + 1) )
#define FLOOR(x) ( (double) ((int) (x)) )
-static inline int pad4(int value)
+#ifdef WIN32
+#define InlineX __inline
+#else
+# ifndef __STRICT_ANSI__
+# define InlineX inline
+# else
+# define InlineX
+# endif
+#endif
+
+
+static InlineX int pad4(int value)
{
int remainder = value & 3;
if (!remainder) return value;
diff --git a/libvncserver/sockets.c b/libvncserver/sockets.c
index e4fc52b..4556197 100644
--- a/libvncserver/sockets.c
+++ b/libvncserver/sockets.c
@@ -100,7 +100,13 @@ int deny_severity=LOG_WARNING;
#pragma warning (disable: 4018 4761)
#endif
#define read(sock,buf,len) recv(sock,buf,len,0)
+#ifdef EWOULDBLOCK
+#undef EWOULDBLOCK
+#endif
#define EWOULDBLOCK WSAEWOULDBLOCK
+#ifdef ETIMEDOUT
+#undef ETIMEDOUT
+#endif
#define ETIMEDOUT WSAETIMEDOUT
#define write(sock,buf,len) send(sock,buf,len,0)
#else
diff --git a/libvncserver/tableinit24.c b/libvncserver/tableinit24.c
index 39e9920..5c5823c 100644
--- a/libvncserver/tableinit24.c
+++ b/libvncserver/tableinit24.c
@@ -147,11 +147,12 @@ rfbInitOneRGBTable24 (uint8_t *table, int inMax, int outMax, int outShift,
for (i = 0; i < nEntries; i++) {
outValue = ((i * outMax + inMax / 2) / inMax) << outShift;
*(uint32_t *)&table[3*i] = outValue;
- if(!rfbEndianTest)
+ if(!rfbEndianTest) {
memmove(table+3*i,table+3*i+1,3);
- if (swap) {
- c = table[3*i]; table[3*i] = table[3*i+2];
- table[3*i+2] = c;
- }
+ }
+ if (swap) {
+ c = table[3*i]; table[3*i] = table[3*i+2];
+ table[3*i+2] = c;
+ }
}
}
diff --git a/libvncserver/tight.c b/libvncserver/tight.c
index bca374d..d6f4749 100644
--- a/libvncserver/tight.c
+++ b/libvncserver/tight.c
@@ -57,10 +57,11 @@
* that we resort to using thread local storage instead of having
* per-client data.
*/
-#if LIBVNCSERVER_HAVE_LIBPTHREAD && LIBVNCSERVER_HAVE_TLS && !defined(TLS) && defined(__linux__)
+#if defined(__GNUC__)
#define TLS __thread
-#endif
-#ifndef TLS
+#elif defined(_MSC_VER)
+#define TLS __declspec(thread)
+#else
#define TLS
#endif
@@ -191,7 +192,6 @@ static rfbBool CheckSolidTile32 (rfbClientPtr cl, int x, int y, int w, int h,
static rfbBool SendRectSimple (rfbClientPtr cl, int x, int y, int w, int h);
static rfbBool SendSubrect (rfbClientPtr cl, int x, int y, int w, int h);
-static rfbBool SendTightHeader (rfbClientPtr cl, int x, int y, int w, int h);
static rfbBool SendSolidRect (rfbClientPtr cl);
static rfbBool SendMonoRect (rfbClientPtr cl, int x, int y, int w, int h);
@@ -200,8 +200,6 @@ static rfbBool SendFullColorRect (rfbClientPtr cl, int x, int y, int w, int h);
static rfbBool CompressData (rfbClientPtr cl, int streamId, int dataLen,
int zlibLevel, int zlibStrategy);
-static rfbBool SendCompressedData (rfbClientPtr cl, char *buf,
- int compressedLen);
static void FillPalette8 (int count);
static void FillPalette16 (int count);
@@ -430,7 +428,7 @@ SendRectEncodingTight(rfbClientPtr cl,
/* Send solid-color rectangle. */
- if (!SendTightHeader(cl, x_best, y_best, w_best, h_best))
+ if (!rfbSendTightHeader(cl, x_best, y_best, w_best, h_best))
return FALSE;
fbptr = (cl->scaledScreen->frameBuffer +
@@ -683,7 +681,7 @@ SendSubrect(rfbClientPtr cl,
return FALSE;
}
- if (!SendTightHeader(cl, x, y, w, h))
+ if (!rfbSendTightHeader(cl, x, y, w, h))
return FALSE;
fbptr = (cl->scaledScreen->frameBuffer
@@ -767,8 +765,8 @@ SendSubrect(rfbClientPtr cl,
return success;
}
-static rfbBool
-SendTightHeader(rfbClientPtr cl,
+rfbBool
+rfbSendTightHeader(rfbClientPtr cl,
int x,
int y,
int w,
@@ -1044,7 +1042,7 @@ CompressData(rfbClientPtr cl,
}
if (zlibLevel == 0)
- return SendCompressedData (cl, tightBeforeBuf, dataLen);
+ return rfbSendCompressedDataTight(cl, tightBeforeBuf, dataLen);
pz = &cl->zsStruct[streamId];
@@ -1083,12 +1081,12 @@ CompressData(rfbClientPtr cl,
return FALSE;
}
- return SendCompressedData(cl, tightAfterBuf,
- tightAfterBufSize - pz->avail_out);
+ return rfbSendCompressedDataTight(cl, tightAfterBuf,
+ tightAfterBufSize - pz->avail_out);
}
-static rfbBool SendCompressedData(rfbClientPtr cl, char *buf,
- int compressedLen)
+rfbBool rfbSendCompressedDataTight(rfbClientPtr cl, char *buf,
+ int compressedLen)
{
int i, portionLen;
@@ -1665,7 +1663,7 @@ SendJpegRect(rfbClientPtr cl, int x, int y, int w, int h, int quality)
cl->updateBuf[cl->ublen++] = (char)(rfbTightJpeg << 4);
rfbStatRecordEncodingSentAdd(cl, cl->tightEncoding, 1);
- return SendCompressedData(cl, tightAfterBuf, (int)size);
+ return rfbSendCompressedDataTight(cl, tightAfterBuf, (int)size);
}
static void
@@ -1899,6 +1897,6 @@ static rfbBool SendPngRect(rfbClientPtr cl, int x, int y, int w, int h) {
rfbStatRecordEncodingSentAdd(cl, cl->tightEncoding, 1);
/* rfbLog("<< SendPngRect\n"); */
- return SendCompressedData(cl, tightAfterBuf, pngDstDataLen);
+ return rfbSendCompressedDataTight(cl, tightAfterBuf, pngDstDataLen);
}
#endif
diff --git a/libvncserver/tightvnc-filetransfer/filetransfermsg.c b/libvncserver/tightvnc-filetransfer/filetransfermsg.c
index 153f123..0003b11 100644
--- a/libvncserver/tightvnc-filetransfer/filetransfermsg.c
+++ b/libvncserver/tightvnc-filetransfer/filetransfermsg.c
@@ -56,7 +56,9 @@
#endif
#include <errno.h>
+#if LIBVNCSERVER_HAVE_UNISTD_H
#include <unistd.h>
+#endif
#include <sys/stat.h>
#include <sys/types.h>
@@ -670,7 +672,7 @@ ChkFileUploadWriteErr(rfbClientPtr cl, rfbTightClientPtr rtcp, char* pBuf)
char reason[] = "Error writing file data";
int reasonLen = strlen(reason);
ftm = CreateFileUploadErrMsg(reason, reasonLen);
- CloseUndoneFileTransfer(cl, rtcp);
+ CloseUndoneFileUpload(cl, rtcp);
}
return ftm;
}
@@ -733,7 +735,7 @@ CreateFileUploadErrMsg(char* reason, unsigned int reasonLen)
******************************************************************************/
void
-CloseUndoneFileTransfer(rfbClientPtr cl, rfbTightClientPtr rtcp)
+CloseUndoneFileUpload(rfbClientPtr cl, rfbTightClientPtr rtcp)
{
/* TODO :: File Upload case is not handled currently */
/* TODO :: In case of concurrency we need to use Critical Section */
@@ -757,9 +759,19 @@ CloseUndoneFileTransfer(rfbClientPtr cl, rfbTightClientPtr rtcp)
memset(rtcp->rcft.rcfu.fName, 0 , PATH_MAX);
}
+}
+
+
+void
+CloseUndoneFileDownload(rfbClientPtr cl, rfbTightClientPtr rtcp)
+{
+ if(cl == NULL)
+ return;
if(rtcp->rcft.rcfd.downloadInProgress == TRUE) {
rtcp->rcft.rcfd.downloadInProgress = FALSE;
+ /* the thread will return if downloadInProgress is FALSE */
+ pthread_join(rtcp->rcft.rcfd.downloadThread, NULL);
if(rtcp->rcft.rcfd.downloadFD != -1) {
close(rtcp->rcft.rcfd.downloadFD);
diff --git a/libvncserver/tightvnc-filetransfer/filetransfermsg.h b/libvncserver/tightvnc-filetransfer/filetransfermsg.h
index 3b27bd0..bbb9148 100644
--- a/libvncserver/tightvnc-filetransfer/filetransfermsg.h
+++ b/libvncserver/tightvnc-filetransfer/filetransfermsg.h
@@ -51,7 +51,8 @@ FileTransferMsg ChkFileUploadWriteErr(rfbClientPtr cl, rfbTightClientPtr data, c
void CreateDirectory(char* dirName);
void FileUpdateComplete(rfbClientPtr cl, rfbTightClientPtr data);
-void CloseUndoneFileTransfer(rfbClientPtr cl, rfbTightClientPtr data);
+void CloseUndoneFileUpload(rfbClientPtr cl, rfbTightClientPtr data);
+void CloseUndoneFileDownload(rfbClientPtr cl, rfbTightClientPtr data);
void FreeFileTransferMsg(FileTransferMsg ftm);
diff --git a/libvncserver/tightvnc-filetransfer/handlefiletransferrequest.c b/libvncserver/tightvnc-filetransfer/handlefiletransferrequest.c
index b235fa0..71fb085 100644
--- a/libvncserver/tightvnc-filetransfer/handlefiletransferrequest.c
+++ b/libvncserver/tightvnc-filetransfer/handlefiletransferrequest.c
@@ -29,7 +29,9 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#if LIBVNCSERVER_HAVE_UNISTD_H
#include <unistd.h>
+#endif
#ifndef _MSC_VER
#include <dirent.h>
#include <pthread.h>
@@ -487,12 +489,6 @@ RunFileDownloadThread(void* client)
if(rfbWriteExact(cl, fileDownloadMsg.data, fileDownloadMsg.length) < 0) {
rfbLog("File [%s]: Method [%s]: Error while writing to socket \n"
, __FILE__, __FUNCTION__);
-
- if(cl != NULL) {
- rfbCloseClient(cl);
- CloseUndoneFileTransfer(cl, rtcp);
- }
-
FreeFileTransferMsg(fileDownloadMsg);
return NULL;
}
@@ -506,7 +502,6 @@ RunFileDownloadThread(void* client)
void
HandleFileDownload(rfbClientPtr cl, rfbTightClientPtr rtcp)
{
- pthread_t fileDownloadThread;
FileTransferMsg fileDownloadMsg;
memset(&fileDownloadMsg, 0, sizeof(FileTransferMsg));
@@ -516,10 +511,9 @@ HandleFileDownload(rfbClientPtr cl, rfbTightClientPtr rtcp)
FreeFileTransferMsg(fileDownloadMsg);
return;
}
- rtcp->rcft.rcfd.downloadInProgress = FALSE;
- rtcp->rcft.rcfd.downloadFD = -1;
+ CloseUndoneFileDownload(cl, rtcp);
- if(pthread_create(&fileDownloadThread, NULL, RunFileDownloadThread, (void*)
+ if(pthread_create(&rtcp->rcft.rcfd.downloadThread, NULL, RunFileDownloadThread, (void*)
cl) != 0) {
FileTransferMsg ftm = GetFileDownLoadErrMsg();
@@ -583,13 +577,15 @@ HandleFileDownloadCancelRequest(rfbClientPtr cl, rfbTightClientPtr rtcp)
"FileDownloadCancelMsg\n", __FILE__, __FUNCTION__);
rfbCloseClient(cl);
+ free(reason);
+ return;
}
rfbLog("File [%s]: Method [%s]: File Download Cancel Request received:"
" reason <%s>\n", __FILE__, __FUNCTION__, reason);
pthread_mutex_lock(&fileDownloadMutex);
- CloseUndoneFileTransfer(cl, rtcp);
+ CloseUndoneFileDownload(cl, rtcp);
pthread_mutex_unlock(&fileDownloadMutex);
if(reason != NULL) {
@@ -832,7 +828,7 @@ HandleFileUploadDataRequest(rfbClientPtr cl, rfbTightClientPtr rtcp)
FreeFileTransferMsg(ftm);
}
- CloseUndoneFileTransfer(cl, rtcp);
+ CloseUndoneFileUpload(cl, rtcp);
if(pBuf != NULL) {
free(pBuf);
@@ -932,7 +928,7 @@ HandleFileUploadFailedRequest(rfbClientPtr cl, rfbTightClientPtr rtcp)
rfbLog("File [%s]: Method [%s]: File Upload Failed Request received:"
" reason <%s>\n", __FILE__, __FUNCTION__, reason);
- CloseUndoneFileTransfer(cl, rtcp);
+ CloseUndoneFileUpload(cl, rtcp);
if(reason != NULL) {
free(reason);
diff --git a/libvncserver/tightvnc-filetransfer/rfbtightproto.h b/libvncserver/tightvnc-filetransfer/rfbtightproto.h
index d0fe642..30fc5f5 100644
--- a/libvncserver/tightvnc-filetransfer/rfbtightproto.h
+++ b/libvncserver/tightvnc-filetransfer/rfbtightproto.h
@@ -148,6 +148,7 @@ typedef struct _rfbClientFileDownload {
int downloadInProgress;
unsigned long mTime;
int downloadFD;
+ pthread_t downloadThread;
} rfbClientFileDownload ;
typedef struct _rfbClientFileUpload {
diff --git a/libvncserver/tightvnc-filetransfer/rfbtightserver.c b/libvncserver/tightvnc-filetransfer/rfbtightserver.c
index 67d4cb5..651d8fb 100644
--- a/libvncserver/tightvnc-filetransfer/rfbtightserver.c
+++ b/libvncserver/tightvnc-filetransfer/rfbtightserver.c
@@ -26,6 +26,7 @@
#include <rfb/rfb.h>
#include "rfbtightproto.h"
#include "handlefiletransferrequest.h"
+#include "filetransfermsg.h"
/*
* Get my data!
@@ -448,9 +449,11 @@ rfbTightExtensionMsgHandler(struct _rfbClientRec* cl, void* data,
void
rfbTightExtensionClientClose(rfbClientPtr cl, void* data) {
- if(data != NULL)
+ if(data != NULL) {
+ CloseUndoneFileUpload(cl, data);
+ CloseUndoneFileDownload(cl, data);
free(data);
-
+ }
}
void
diff --git a/libvncserver/ultra.c b/libvncserver/ultra.c
index 83bddaa..cd625a5 100644
--- a/libvncserver/ultra.c
+++ b/libvncserver/ultra.c
@@ -8,7 +8,11 @@
*/
#include <rfb/rfb.h>
+#ifdef LIBVNCSERVER_HAVE_LZO
+#include <lzo/lzo1x.h>
+#else
#include "minilzo.h"
+#endif
/*
* cl->beforeEncBuf contains pixel data in the client's format.
diff --git a/libvncserver/websockets.c b/libvncserver/websockets.c
index f5dd120..4361bdd 100644
--- a/libvncserver/websockets.c
+++ b/libvncserver/websockets.c
@@ -30,10 +30,6 @@
/* errno */
#include <errno.h>
-#ifndef _MSC_VER
-#include <resolv.h> /* __b64_ntop */
-#endif
-
#ifdef LIBVNCSERVER_HAVE_ENDIAN_H
#include <endian.h>
#elif LIBVNCSERVER_HAVE_SYS_ENDIAN_H
@@ -45,24 +41,14 @@
#endif
#include <string.h>
+#if LIBVNCSERVER_UNISTD_H
#include <unistd.h>
+#endif
#include "rfb/rfbconfig.h"
#include "rfbssl.h"
#include "rfbcrypto.h"
-
-#define WS_NTOH64(n) htobe64(n)
-#define WS_NTOH32(n) htobe32(n)
-#define WS_NTOH16(n) htobe16(n)
-#define WS_HTON64(n) htobe64(n)
-#define WS_HTON16(n) htobe16(n)
-
-#define B64LEN(__x) (((__x + 2) / 3) * 12 / 3)
-#define WSHLENMAX 14 /* 2 + sizeof(uint64_t) + sizeof(uint32_t) */
-
-enum {
- WEBSOCKETS_VERSION_HIXIE,
- WEBSOCKETS_VERSION_HYBI
-};
+#include "ws_decode.h"
+#include "base64.h"
#if 0
#include <sys/syscall.h>
@@ -71,77 +57,12 @@ static int gettid() {
}
#endif
-typedef int (*wsEncodeFunc)(rfbClientPtr cl, const char *src, int len, char **dst);
-typedef int (*wsDecodeFunc)(rfbClientPtr cl, char *dst, int len);
-
-typedef struct ws_ctx_s {
- char codeBufDecode[B64LEN(UPDATE_BUF_SIZE) + WSHLENMAX]; /* base64 + maximum frame header length */
- char codeBufEncode[B64LEN(UPDATE_BUF_SIZE) + WSHLENMAX]; /* base64 + maximum frame header length */
- char readbuf[8192];
- int readbufstart;
- int readbuflen;
- int dblen;
- char carryBuf[3]; /* For base64 carry-over */
- int carrylen;
- int version;
- int base64;
- wsEncodeFunc encode;
- wsDecodeFunc decode;
-} ws_ctx_t;
-
-typedef union ws_mask_s {
- char c[4];
- uint32_t u;
-} ws_mask_t;
-
-/* XXX: The union and the structs do not need to be named.
- * We are working around a bug present in GCC < 4.6 which prevented
- * it from recognizing anonymous structs and unions.
- * See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=4784
- */
-typedef struct __attribute__ ((__packed__)) ws_header_s {
- unsigned char b0;
- unsigned char b1;
- union {
- struct __attribute__ ((__packed__)) {
- uint16_t l16;
- ws_mask_t m16;
- } s16;
- struct __attribute__ ((__packed__)) {
- uint64_t l64;
- ws_mask_t m64;
- } s64;
- ws_mask_t m;
- } u;
-} ws_header_t;
-
-enum
-{
- WS_OPCODE_CONTINUATION = 0x0,
- WS_OPCODE_TEXT_FRAME,
- WS_OPCODE_BINARY_FRAME,
- WS_OPCODE_CLOSE = 0x8,
- WS_OPCODE_PING,
- WS_OPCODE_PONG
-};
-
-#define FLASH_POLICY_RESPONSE "<cross-domain-policy><allow-access-from domain=\"*\" to-ports=\"*\" /></cross-domain-policy>\n"
-#define SZ_FLASH_POLICY_RESPONSE 93
-
/*
* draft-ietf-hybi-thewebsocketprotocol-10
* 5.2.2. Sending the Server's Opening Handshake
*/
#define GUID "258EAFA5-E914-47DA-95CA-C5AB0DC85B11"
-#define SERVER_HANDSHAKE_HIXIE "HTTP/1.1 101 Web Socket Protocol Handshake\r\n\
-Upgrade: WebSocket\r\n\
-Connection: Upgrade\r\n\
-%sWebSocket-Origin: %s\r\n\
-%sWebSocket-Location: %s://%s%s\r\n\
-%sWebSocket-Protocol: %s\r\n\
-\r\n%s"
-
#define SERVER_HANDSHAKE_HYBI "HTTP/1.1 101 Switching Protocols\r\n\
Upgrade: websocket\r\n\
Connection: Upgrade\r\n\
@@ -168,12 +89,11 @@ struct timeval
#endif
static rfbBool webSocketsHandshake(rfbClientPtr cl, char *scheme);
-void webSocketsGenMd5(char * target, char *key1, char *key2, char *key3);
static int webSocketsEncodeHybi(rfbClientPtr cl, const char *src, int len, char **dst);
-static int webSocketsEncodeHixie(rfbClientPtr cl, const char *src, int len, char **dst);
-static int webSocketsDecodeHybi(rfbClientPtr cl, char *dst, int len);
-static int webSocketsDecodeHixie(rfbClientPtr cl, char *dst, int len);
+
+static int ws_read(void *cl, char *buf, size_t len);
+
static int
min (int a, int b) {
@@ -190,8 +110,8 @@ static void webSocketsGenSha1Key(char *target, int size, char *key)
iov[1].iov_base = GUID;
iov[1].iov_len = sizeof(GUID) - 1;
digestsha1(iov, 2, hash);
- if (-1 == __b64_ntop(hash, sizeof(hash), target, size))
- rfbErr("b64_ntop failed\n");
+ if (-1 == rfbBase64NtoP(hash, sizeof(hash), target, size))
+ rfbErr("rfbBase64NtoP failed\n");
}
/*
@@ -214,13 +134,9 @@ webSocketsCheck (rfbClientPtr cl)
return FALSE;
}
- if (strncmp(bbuf, "<", 1) == 0) {
- rfbLog("Got Flash policy request, sending response\n");
- if (rfbWriteExact(cl, FLASH_POLICY_RESPONSE,
- SZ_FLASH_POLICY_RESPONSE) < 0) {
- rfbErr("webSocketsHandshake: failed sending Flash policy response");
- }
- return FALSE;
+ if (strncmp(bbuf, "RFB ", 4) == 0) {
+ rfbLog("Normal socket connection\n");
+ return TRUE;
} else if (strncmp(bbuf, "\x16", 1) == 0 || strncmp(bbuf, "\x80", 1) == 0) {
rfbLog("Got TLS/SSL WebSockets connection\n");
if (-1 == rfbssl_init(cl)) {
@@ -278,10 +194,13 @@ webSocketsHandshake(rfbClientPtr cl, char *scheme)
if ((n < 0) && (errno == ETIMEDOUT)) {
break;
}
- if (n == 0)
+ if (n == 0) {
rfbLog("webSocketsHandshake: client gone\n");
- else
+ }
+ else {
rfbLogPerror("webSocketsHandshake: read");
+ }
+
free(response);
free(buf);
return FALSE;
@@ -336,24 +255,33 @@ webSocketsHandshake(rfbClientPtr cl, char *scheme)
/* rfbLog("Got key2: %s\n", key2); */
/* HyBI */
- } else if ((strncasecmp("sec-websocket-protocol: ", line, min(llen,24))) == 0) {
+ } else if ((strncasecmp("sec-websocket-protocol: ", line, min(llen,24))) == 0) {
protocol = line+24;
buf[len-2] = '\0';
rfbLog("Got protocol: %s\n", protocol);
} else if ((strncasecmp("sec-websocket-origin: ", line, min(llen,22))) == 0) {
- sec_ws_origin = line+22;
+ sec_ws_origin = line+22;
buf[len-2] = '\0';
} else if ((strncasecmp("sec-websocket-key: ", line, min(llen,19))) == 0) {
- sec_ws_key = line+19;
+ sec_ws_key = line+19;
buf[len-2] = '\0';
} else if ((strncasecmp("sec-websocket-version: ", line, min(llen,23))) == 0) {
- sec_ws_version = strtol(line+23, NULL, 10);
+ sec_ws_version = strtol(line+23, NULL, 10);
buf[len-2] = '\0';
- }
+ }
linestart = len;
}
}
+
+ /* older hixie handshake, this could be removed if
+ * a final standard is established -- removed now */
+ if (!sec_ws_version) {
+ rfbErr("Hixie no longer supported\n");
+ free(response);
+ free(buf);
+ return FALSE;
+ }
if (!(path && host && (origin || sec_ws_origin))) {
rfbErr("webSocketsHandshake: incomplete client handshake\n");
@@ -363,12 +291,6 @@ webSocketsHandshake(rfbClientPtr cl, char *scheme)
}
if ((protocol) && (strstr(protocol, "binary"))) {
- if (! sec_ws_version) {
- rfbErr("webSocketsHandshake: 'binary' protocol not supported with Hixie\n");
- free(response);
- free(buf);
- return FALSE;
- }
rfbLog(" - webSocketsHandshake: using binary/raw encoding\n");
base64 = FALSE;
protocol = "binary";
@@ -386,32 +308,16 @@ webSocketsHandshake(rfbClientPtr cl, char *scheme)
* Generate the WebSockets server response based on the the headers sent
* by the client.
*/
+ char accept[B64LEN(SHA1_HASH_SIZE) + 1];
+ rfbLog(" - WebSockets client version hybi-%02d\n", sec_ws_version);
+ webSocketsGenSha1Key(accept, sizeof(accept), sec_ws_key);
- if (sec_ws_version) {
- char accept[B64LEN(SHA1_HASH_SIZE) + 1];
- rfbLog(" - WebSockets client version hybi-%02d\n", sec_ws_version);
- webSocketsGenSha1Key(accept, sizeof(accept), sec_ws_key);
- if(strlen(protocol) > 0)
- len = snprintf(response, WEBSOCKETS_MAX_HANDSHAKE_LEN,
- SERVER_HANDSHAKE_HYBI, accept, protocol);
- else
- len = snprintf(response, WEBSOCKETS_MAX_HANDSHAKE_LEN,
- SERVER_HANDSHAKE_HYBI_NO_PROTOCOL, accept);
+ if(strlen(protocol) > 0) {
+ len = snprintf(response, WEBSOCKETS_MAX_HANDSHAKE_LEN,
+ SERVER_HANDSHAKE_HYBI, accept, protocol);
} else {
- /* older hixie handshake, this could be removed if
- * a final standard is established */
- if (!(key1 && key2 && key3)) {
- rfbLog(" - WebSockets client version hixie-75\n");
- prefix[0] = '\0';
- trailer[0] = '\0';
- } else {
- rfbLog(" - WebSockets client version hixie-76\n");
- snprintf(prefix, 5, "Sec-");
- webSocketsGenMd5(trailer, key1, key2, key3);
- }
- len = snprintf(response, WEBSOCKETS_MAX_HANDSHAKE_LEN,
- SERVER_HANDSHAKE_HIXIE, prefix, origin, prefix, scheme,
- host, path, prefix, protocol, trailer);
+ len = snprintf(response, WEBSOCKETS_MAX_HANDSHAKE_LEN,
+ SERVER_HANDSHAKE_HYBI_NO_PROTOCOL, accept);
}
if (rfbWriteExact(cl, response, len) < 0) {
@@ -424,357 +330,30 @@ webSocketsHandshake(rfbClientPtr cl, char *scheme)
free(response);
free(buf);
-
wsctx = calloc(1, sizeof(ws_ctx_t));
- if (sec_ws_version) {
- wsctx->version = WEBSOCKETS_VERSION_HYBI;
- wsctx->encode = webSocketsEncodeHybi;
- wsctx->decode = webSocketsDecodeHybi;
- } else {
- wsctx->version = WEBSOCKETS_VERSION_HIXIE;
- wsctx->encode = webSocketsEncodeHixie;
- wsctx->decode = webSocketsDecodeHixie;
- }
+ wsctx->encode = webSocketsEncodeHybi;
+ wsctx->decode = webSocketsDecodeHybi;
+ wsctx->ctxInfo.readFunc = ws_read;
wsctx->base64 = base64;
+ hybiDecodeCleanupComplete(wsctx);
cl->wsctx = (wsCtx *)wsctx;
return TRUE;
}
-
-void
-webSocketsGenMd5(char * target, char *key1, char *key2, char *key3)
-{
- unsigned int i, spaces1 = 0, spaces2 = 0;
- unsigned long num1 = 0, num2 = 0;
- unsigned char buf[17];
- struct iovec iov[1];
-
- for (i=0; i < strlen(key1); i++) {
- if (key1[i] == ' ') {
- spaces1 += 1;
- }
- if ((key1[i] >= 48) && (key1[i] <= 57)) {
- num1 = num1 * 10 + (key1[i] - 48);
- }
- }
- num1 = num1 / spaces1;
-
- for (i=0; i < strlen(key2); i++) {
- if (key2[i] == ' ') {
- spaces2 += 1;
- }
- if ((key2[i] >= 48) && (key2[i] <= 57)) {
- num2 = num2 * 10 + (key2[i] - 48);
- }
- }
- num2 = num2 / spaces2;
-
- /* Pack it big-endian */
- buf[0] = (num1 & 0xff000000) >> 24;
- buf[1] = (num1 & 0xff0000) >> 16;
- buf[2] = (num1 & 0xff00) >> 8;
- buf[3] = num1 & 0xff;
-
- buf[4] = (num2 & 0xff000000) >> 24;
- buf[5] = (num2 & 0xff0000) >> 16;
- buf[6] = (num2 & 0xff00) >> 8;
- buf[7] = num2 & 0xff;
-
- strncpy((char *)buf+8, key3, 8);
- buf[16] = '\0';
-
- iov[0].iov_base = buf;
- iov[0].iov_len = 16;
- digestmd5(iov, 1, target);
- target[16] = '\0';
-
- return;
-}
static int
-webSocketsEncodeHixie(rfbClientPtr cl, const char *src, int len, char **dst)
-{
- int sz = 0;
- ws_ctx_t *wsctx = (ws_ctx_t *)cl->wsctx;
-
- wsctx->codeBufEncode[sz++] = '\x00';
- len = __b64_ntop((unsigned char *)src, len, wsctx->codeBufEncode+sz, sizeof(wsctx->codeBufEncode) - (sz + 1));
- if (len < 0) {
- return len;
- }
- sz += len;
-
- wsctx->codeBufEncode[sz++] = '\xff';
- *dst = wsctx->codeBufEncode;
- return sz;
-}
-
-static int
-ws_read(rfbClientPtr cl, char *buf, int len)
+ws_read(void *ctxPtr, char *buf, size_t len)
{
int n;
+ rfbClientPtr cl = ctxPtr;
if (cl->sslctx) {
- n = rfbssl_read(cl, buf, len);
+ n = rfbssl_read(cl, buf, len);
} else {
- n = read(cl->sock, buf, len);
+ n = read(cl->sock, buf, len);
}
return n;
}
static int
-ws_peek(rfbClientPtr cl, char *buf, int len)
-{
- int n;
- if (cl->sslctx) {
- n = rfbssl_peek(cl, buf, len);
- } else {
- while (-1 == (n = recv(cl->sock, buf, len, MSG_PEEK))) {
- if (errno != EAGAIN)
- break;
- }
- }
- return n;
-}
-
-static int
-webSocketsDecodeHixie(rfbClientPtr cl, char *dst, int len)
-{
- int retlen = 0, n, i, avail, modlen, needlen;
- char *buf, *end = NULL;
- ws_ctx_t *wsctx = (ws_ctx_t *)cl->wsctx;
-
- buf = wsctx->codeBufDecode;
-
- n = ws_peek(cl, buf, len*2+2);
-
- if (n <= 0) {
- /* save errno because rfbErr() will tamper it */
- int olderrno = errno;
- rfbErr("%s: peek (%d) %m\n", __func__, errno);
- errno = olderrno;
- return n;
- }
-
-
- /* Base64 encoded WebSockets stream */
-
- if (buf[0] == '\xff') {
- i = ws_read(cl, buf, 1); /* Consume marker */
- buf++;
- n--;
- }
- if (n == 0) {
- errno = EAGAIN;
- return -1;
- }
- if (buf[0] == '\x00') {
- i = ws_read(cl, buf, 1); /* Consume marker */
- buf++;
- n--;
- }
- if (n == 0) {
- errno = EAGAIN;
- return -1;
- }
-
- /* end = memchr(buf, '\xff', len*2+2); */
- end = memchr(buf, '\xff', n);
- if (!end) {
- end = buf + n;
- }
- avail = end - buf;
-
- len -= wsctx->carrylen;
-
- /* Determine how much base64 data we need */
- modlen = len + (len+2)/3;
- needlen = modlen;
- if (needlen % 4) {
- needlen += 4 - (needlen % 4);
- }
-
- if (needlen > avail) {
- /* rfbLog("Waiting for more base64 data\n"); */
- errno = EAGAIN;
- return -1;
- }
-
- /* Any carryover from previous decode */
- for (i=0; i < wsctx->carrylen; i++) {
- /* rfbLog("Adding carryover %d\n", wsctx->carryBuf[i]); */
- dst[i] = wsctx->carryBuf[i];
- retlen += 1;
- }
-
- /* Decode the rest of what we need */
- buf[needlen] = '\x00'; /* Replace end marker with end of string */
- /* rfbLog("buf: %s\n", buf); */
- n = __b64_pton(buf, (unsigned char *)dst+retlen, 2+len);
- if (n < len) {
- rfbErr("Base64 decode error\n");
- errno = EIO;
- return -1;
- }
- retlen += n;
-
- /* Consume the data from socket */
- i = ws_read(cl, buf, needlen);
-
- wsctx->carrylen = n - len;
- retlen -= wsctx->carrylen;
- for (i=0; i < wsctx->carrylen; i++) {
- /* rfbLog("Saving carryover %d\n", dst[retlen + i]); */
- wsctx->carryBuf[i] = dst[retlen + i];
- }
-
- /* rfbLog("<< webSocketsDecode, retlen: %d\n", retlen); */
- return retlen;
-}
-
-static int
-webSocketsDecodeHybi(rfbClientPtr cl, char *dst, int len)
-{
- char *buf, *payload;
- uint32_t *payload32;
- int ret = -1, result = -1;
- int total = 0;
- ws_mask_t mask;
- ws_header_t *header;
- int i;
- unsigned char opcode;
- ws_ctx_t *wsctx = (ws_ctx_t *)cl->wsctx;
- int flength, fhlen;
- /* int fin; */ /* not used atm */
-
- /* rfbLog(" <== %s[%d]: %d cl: %p, wsctx: %p-%p (%d)\n", __func__, gettid(), len, cl, wsctx, (char *)wsctx + sizeof(ws_ctx_t), sizeof(ws_ctx_t)); */
-
- if (wsctx->readbuflen) {
- /* simply return what we have */
- if (wsctx->readbuflen > len) {
- memcpy(dst, wsctx->readbuf + wsctx->readbufstart, len);
- result = len;
- wsctx->readbuflen -= len;
- wsctx->readbufstart += len;
- } else {
- memcpy(dst, wsctx->readbuf + wsctx->readbufstart, wsctx->readbuflen);
- result = wsctx->readbuflen;
- wsctx->readbuflen = 0;
- wsctx->readbufstart = 0;
- }
- goto spor;
- }
-
- buf = wsctx->codeBufDecode;
- header = (ws_header_t *)wsctx->codeBufDecode;
-
- ret = ws_peek(cl, buf, B64LEN(len) + WSHLENMAX);
-
- if (ret < 2) {
- /* save errno because rfbErr() will tamper it */
- if (-1 == ret) {
- int olderrno = errno;
- rfbErr("%s: peek; %m\n", __func__);
- errno = olderrno;
- } else if (0 == ret) {
- result = 0;
- } else {
- errno = EAGAIN;
- }
- goto spor;
- }
-
- opcode = header->b0 & 0x0f;
- /* fin = (header->b0 & 0x80) >> 7; */ /* not used atm */
- flength = header->b1 & 0x7f;
-
- /*
- * 4.3. Client-to-Server Masking
- *
- * The client MUST mask all frames sent to the server. A server MUST
- * close the connection upon receiving a frame with the MASK bit set to 0.
- **/
- if (!(header->b1 & 0x80)) {
- rfbErr("%s: got frame without mask\n", __func__, ret);
- errno = EIO;
- goto spor;
- }
-
- if (flength < 126) {
- fhlen = 2;
- mask = header->u.m;
- } else if (flength == 126 && 4 <= ret) {
- flength = WS_NTOH16(header->u.s16.l16);
- fhlen = 4;
- mask = header->u.s16.m16;
- } else if (flength == 127 && 10 <= ret) {
- flength = WS_NTOH64(header->u.s64.l64);
- fhlen = 10;
- mask = header->u.s64.m64;
- } else {
- /* Incomplete frame header */
- rfbErr("%s: incomplete frame header\n", __func__, ret);
- errno = EIO;
- goto spor;
- }
-
- /* absolute length of frame */
- total = fhlen + flength + 4;
- payload = buf + fhlen + 4; /* header length + mask */
-
- if (-1 == (ret = ws_read(cl, buf, total))) {
- int olderrno = errno;
- rfbErr("%s: read; %m", __func__);
- errno = olderrno;
- return ret;
- } else if (ret < total) {
- /* GT TODO: hmm? */
- rfbLog("%s: read; got partial data\n", __func__);
- } else {
- buf[ret] = '\0';
- }
-
- /* process 1 frame (32 bit op) */
- payload32 = (uint32_t *)payload;
- for (i = 0; i < flength / 4; i++) {
- payload32[i] ^= mask.u;
- }
- /* process the remaining bytes (if any) */
- for (i*=4; i < flength; i++) {
- payload[i] ^= mask.c[i % 4];
- }
-
- switch (opcode) {
- case WS_OPCODE_CLOSE:
- rfbLog("got closure, reason %d\n", WS_NTOH16(((uint16_t *)payload)[0]));
- errno = ECONNRESET;
- break;
- case WS_OPCODE_TEXT_FRAME:
- if (-1 == (flength = __b64_pton(payload, (unsigned char *)wsctx->codeBufDecode, sizeof(wsctx->codeBufDecode)))) {
- rfbErr("%s: Base64 decode error; %m\n", __func__);
- break;
- }
- payload = wsctx->codeBufDecode;
- /* fall through */
- case WS_OPCODE_BINARY_FRAME:
- if (flength > len) {
- memcpy(wsctx->readbuf, payload + len, flength - len);
- wsctx->readbufstart = 0;
- wsctx->readbuflen = flength - len;
- flength = len;
- }
- memcpy(dst, payload, flength);
- result = flength;
- break;
- default:
- rfbErr("%s: unhandled opcode %d, b0: %02x, b1: %02x\n", __func__, (int)opcode, header->b0, header->b1);
- }
-
- /* single point of return, if someone has questions :-) */
-spor:
- /* rfbLog("%s: ret: %d/%d\n", __func__, result, len); */
- return result;
-}
-
-static int
webSocketsEncodeHybi(rfbClientPtr cl, const char *src, int len, char **dst)
{
int blen, ret = -1, sz = 0;
@@ -799,12 +378,12 @@ webSocketsEncodeHybi(rfbClientPtr cl, const char *src, int len, char **dst)
header = (ws_header_t *)wsctx->codeBufEncode;
if (wsctx->base64) {
- opcode = WS_OPCODE_TEXT_FRAME;
- /* calculate the resulting size */
- blen = B64LEN(len);
+ opcode = WS_OPCODE_TEXT_FRAME;
+ /* calculate the resulting size */
+ blen = B64LEN(len);
} else {
- opcode = WS_OPCODE_BINARY_FRAME;
- blen = len;
+ opcode = WS_OPCODE_BINARY_FRAME;
+ blen = len;
}
header->b0 = 0x80 | (opcode & 0x0f);
@@ -822,16 +401,16 @@ webSocketsEncodeHybi(rfbClientPtr cl, const char *src, int len, char **dst)
}
if (wsctx->base64) {
- if (-1 == (ret = __b64_ntop((unsigned char *)src, len, wsctx->codeBufEncode + sz, sizeof(wsctx->codeBufEncode) - sz))) {
- rfbErr("%s: Base 64 encode failed\n", __func__);
- } else {
- if (ret != blen)
- rfbErr("%s: Base 64 encode; something weird happened\n", __func__);
- ret += sz;
- }
+ if (-1 == (ret = rfbBase64NtoP((unsigned char *)src, len, wsctx->codeBufEncode + sz, sizeof(wsctx->codeBufEncode) - sz))) {
+ rfbErr("%s: Base 64 encode failed\n", __func__);
+ } else {
+ if (ret != blen)
+ rfbErr("%s: Base 64 encode; something weird happened\n", __func__);
+ ret += sz;
+ }
} else {
- memcpy(wsctx->codeBufEncode + sz, src, len);
- ret = sz + len;
+ memcpy(wsctx->codeBufEncode + sz, src, len);
+ ret = sz + len;
}
*dst = wsctx->codeBufEncode;
@@ -842,76 +421,28 @@ webSocketsEncodeHybi(rfbClientPtr cl, const char *src, int len, char **dst)
int
webSocketsEncode(rfbClientPtr cl, const char *src, int len, char **dst)
{
- return ((ws_ctx_t *)cl->wsctx)->encode(cl, src, len, dst);
+ return webSocketsEncodeHybi(cl, src, len, dst);
}
int
webSocketsDecode(rfbClientPtr cl, char *dst, int len)
{
- return ((ws_ctx_t *)cl->wsctx)->decode(cl, dst, len);
+ ws_ctx_t *wsctx = (ws_ctx_t *)cl->wsctx;
+ wsctx->ctxInfo.ctxPtr = cl;
+ return webSocketsDecodeHybi(wsctx, dst, len);
}
-
-/* returns TRUE if client sent a close frame or a single 'end of frame'
- * marker was received, FALSE otherwise
- *
- * Note: This is a Hixie-only hack!
- **/
+/**
+ * This is a stub function that was once used for Hixie-encoding.
+ * We keep it for API compatibility.
+ */
rfbBool
webSocketCheckDisconnect(rfbClientPtr cl)
{
- ws_ctx_t *wsctx = (ws_ctx_t *)cl->wsctx;
- /* With Base64 encoding we need at least 4 bytes */
- char peekbuf[4];
- int n;
-
- if (wsctx->version == WEBSOCKETS_VERSION_HYBI)
- return FALSE;
-
- if (cl->sslctx)
- n = rfbssl_peek(cl, peekbuf, 4);
- else
- n = recv(cl->sock, peekbuf, 4, MSG_PEEK);
-
- if (n <= 0) {
- if (n != 0)
- rfbErr("%s: peek; %m", __func__);
- rfbCloseClient(cl);
- return TRUE;
- }
-
- if (peekbuf[0] == '\xff') {
- int doclose = 0;
- /* Make sure we don't miss a client disconnect on an end frame
- * marker. Because we use a peek buffer in some cases it is not
- * applicable to wait for more data per select(). */
- switch (n) {
- case 3:
- if (peekbuf[1] == '\xff' && peekbuf[2] == '\x00')
- doclose = 1;
- break;
- case 2:
- if (peekbuf[1] == '\x00')
- doclose = 1;
- break;
- default:
- return FALSE;
- }
-
- if (cl->sslctx)
- n = rfbssl_read(cl, peekbuf, n);
- else
- n = read(cl->sock, peekbuf, n);
-
- if (doclose) {
- rfbErr("%s: websocket close frame received\n", __func__);
- rfbCloseClient(cl);
- }
- return TRUE;
- }
return FALSE;
}
+
/* returns TRUE if there is data waiting to be read in our internal buffer
* or if is there any pending data in the buffer of the SSL implementation
*/
@@ -920,8 +451,8 @@ webSocketsHasDataInBuffer(rfbClientPtr cl)
{
ws_ctx_t *wsctx = (ws_ctx_t *)cl->wsctx;
- if (wsctx && wsctx->readbuflen)
- return TRUE;
+ if (wsctx && wsctx->readlen)
+ return TRUE;
return (cl->sslctx && rfbssl_pending(cl) > 0);
}
diff --git a/libvncserver/ws_decode.c b/libvncserver/ws_decode.c
new file mode 100644
index 0000000..441ebc7
--- /dev/null
+++ b/libvncserver/ws_decode.c
@@ -0,0 +1,563 @@
+#include "ws_decode.h"
+#include "base64.h"
+
+#include <string.h>
+#include <errno.h>
+
+#define WS_HYBI_MASK_LEN 4
+#define WS_HYBI_HEADER_LEN_SHORT 2 + WS_HYBI_MASK_LEN
+#define WS_HYBI_HEADER_LEN_EXTENDED 4 + WS_HYBI_MASK_LEN
+#define WS_HYBI_HEADER_LEN_LONG 10 + WS_HYBI_MASK_LEN
+
+#undef WS_DECODE_DEBUG
+/* set to 1 to produce very fine debugging output */
+#define WS_DECODE_DEBUG 0
+
+#if WS_DECODE_DEBUG == 1
+#define ws_dbg(fmt, ...) rfbLog((fmt), ##__VA_ARGS)
+#else
+#define ws_dbg(fmt, ...)
+#endif
+
+
+static inline int
+isControlFrame(ws_ctx_t *wsctx)
+{
+ return 0 != (wsctx->header.opcode & 0x08);
+}
+
+static uint64_t
+hybiRemaining(ws_ctx_t *wsctx)
+{
+ return wsctx->header.payloadLen - wsctx->nReadPayload;
+}
+
+static void
+hybiDecodeCleanupBasics(ws_ctx_t *wsctx)
+{
+ /* keep opcode, cleanup rest */
+ wsctx->header.opcode = WS_OPCODE_INVALID;
+ wsctx->header.payloadLen = 0;
+ wsctx->header.mask.u = 0;
+ wsctx->header.headerLen = 0;
+ wsctx->header.data = NULL;
+ wsctx->header.nRead = 0;
+ wsctx->nReadPayload = 0;
+ wsctx->carrylen = 0;
+ wsctx->readPos = (unsigned char *)wsctx->codeBufDecode;
+ wsctx->readlen = 0;
+ wsctx->hybiDecodeState = WS_HYBI_STATE_HEADER_PENDING;
+ wsctx->writePos = NULL;
+}
+
+static void
+hybiDecodeCleanupForContinuation(ws_ctx_t *wsctx)
+{
+ hybiDecodeCleanupBasics(wsctx);
+ ws_dbg("clean up frame, but expect continuation with opcode %d\n", wsctx->continuation_opcode);
+}
+
+void
+hybiDecodeCleanupComplete(ws_ctx_t *wsctx)
+{
+ hybiDecodeCleanupBasics(wsctx);
+ wsctx->continuation_opcode = WS_OPCODE_INVALID;
+ ws_dbg("cleaned up wsctx completely\n");
+}
+
+
+/**
+ * Return payload data that has been decoded/unmasked from
+ * a websocket frame.
+ *
+ * @param[out] dst destination buffer
+ * @param[in] len bytes to copy to destination buffer
+ * @param[in,out] wsctx internal state of decoding procedure
+ * @param[out] number of bytes actually written to dst buffer
+ * @return next hybi decoding state
+ */
+static int
+hybiReturnData(char *dst, int len, ws_ctx_t *wsctx, int *nWritten)
+{
+ int nextState = WS_HYBI_STATE_ERR;
+
+ /* if we have something already decoded copy and return */
+ if (wsctx->readlen > 0) {
+ /* simply return what we have */
+ if (wsctx->readlen > len) {
+ ws_dbg("copy to %d bytes to dst buffer; readPos=%p, readLen=%d\n", len, wsctx->readPos, wsctx->readlen);
+ memcpy(dst, wsctx->readPos, len);
+ *nWritten = len;
+ wsctx->readlen -= len;
+ wsctx->readPos += len;
+ nextState = WS_HYBI_STATE_DATA_AVAILABLE;
+ } else {
+ ws_dbg("copy to %d bytes to dst buffer; readPos=%p, readLen=%d\n", wsctx->readlen, wsctx->readPos, wsctx->readlen);
+ memcpy(dst, wsctx->readPos, wsctx->readlen);
+ *nWritten = wsctx->readlen;
+ wsctx->readlen = 0;
+ wsctx->readPos = NULL;
+ if (hybiRemaining(wsctx) == 0) {
+ nextState = WS_HYBI_STATE_FRAME_COMPLETE;
+ } else {
+ nextState = WS_HYBI_STATE_DATA_NEEDED;
+ }
+ }
+ ws_dbg("after copy: readPos=%p, readLen=%d\n", wsctx->readPos, wsctx->readlen);
+ } else {
+ /* it may happen that we read some bytes but could not decode them,
+ * in that case, set errno to EAGAIN and return -1 */
+ nextState = wsctx->hybiDecodeState;
+ errno = EAGAIN;
+ *nWritten = -1;
+ }
+ return nextState;
+}
+
+/**
+ * Read an RFC 6455 websocket frame (IETF hybi working group).
+ *
+ * Internal state is updated according to bytes received and the
+ * decoding of header information.
+ *
+ * @param[in] cl client ptr with ptr to raw socket and ws_ctx_t ptr
+ * @param[out] sockRet emulated recv return value
+ * @param[out] nPayload number of payload bytes already read
+ * @return next hybi decoding state; WS_HYBI_STATE_HEADER_PENDING indicates
+ * that the header was not received completely.
+ */
+static int
+hybiReadHeader(ws_ctx_t *wsctx, int *sockRet, int *nPayload)
+{
+ int ret;
+ char *headerDst = wsctx->codeBufDecode + wsctx->header.nRead;
+ int n = ((uint64_t)WSHLENMAX) - wsctx->header.nRead;
+
+
+ ws_dbg("header_read to %p with len=%d\n", headerDst, n);
+ ret = wsctx->ctxInfo.readFunc(wsctx->ctxInfo.ctxPtr, headerDst, n);
+ ws_dbg("read %d bytes from socket\n", ret);
+ if (ret <= 0) {
+ if (-1 == ret) {
+ /* save errno because rfbErr() will tamper it */
+ int olderrno = errno;
+ rfbErr("%s: read; %s\n", __func__, strerror(errno));
+ errno = olderrno;
+ goto err_cleanup_state;
+ } else {
+ *sockRet = 0;
+ goto err_cleanup_state_sock_closed;
+ }
+ }
+
+ wsctx->header.nRead += ret;
+ if (wsctx->header.nRead < 2) {
+ /* cannot decode header with less than two bytes */
+ goto ret_header_pending;
+ }
+
+ /* first two header bytes received; interpret header data and get rest */
+ wsctx->header.data = (ws_header_t *)wsctx->codeBufDecode;
+
+ wsctx->header.opcode = wsctx->header.data->b0 & 0x0f;
+ wsctx->header.fin = (wsctx->header.data->b0 & 0x80) >> 7;
+ if (isControlFrame(wsctx)) {
+ ws_dbg("is control frame\n");
+ /* is a control frame, leave remembered continuation opcode unchanged;
+ * just check if there is a wrong fragmentation */
+ if (wsctx->header.fin == 0) {
+
+ /* we only accept text/binary continuation frames; RFC6455:
+ * Control frames (see Section 5.5) MAY be injected in the middle of
+ * a fragmented message. Control frames themselves MUST NOT be
+ * fragmented. */
+ rfbErr("control frame with FIN bit cleared received, aborting\n");
+ errno = EPROTO;
+ goto err_cleanup_state;
+ }
+ } else {
+ ws_dbg("not a control frame\n");
+ /* not a control frame, check for continuation opcode */
+ if (wsctx->header.opcode == WS_OPCODE_CONTINUATION) {
+ ws_dbg("cont_frame\n");
+ /* do we have state (i.e., opcode) for continuation frame? */
+ if (wsctx->continuation_opcode == WS_OPCODE_INVALID) {
+ rfbErr("no continuation state\n");
+ errno = EPROTO;
+ goto err_cleanup_state;
+ }
+
+ /* otherwise, set opcode = continuation_opcode */
+ wsctx->header.opcode = wsctx->continuation_opcode;
+ ws_dbg("set opcode to continuation_opcode: %d\n", wsctx->header.opcode);
+ } else {
+ if (wsctx->header.fin == 0) {
+ wsctx->continuation_opcode = wsctx->header.opcode;
+ } else {
+ wsctx->continuation_opcode = WS_OPCODE_INVALID;
+ }
+ ws_dbg("set continuation_opcode to %d\n", wsctx->continuation_opcode);
+ }
+ }
+
+ wsctx->header.payloadLen = (uint64_t)(wsctx->header.data->b1 & 0x7f);
+ ws_dbg("first header bytes received; opcode=%d lenbyte=%d fin=%d\n", wsctx->header.opcode, wsctx->header.payloadLen, wsctx->header.fin);
+
+ /*
+ * 4.3. Client-to-Server Masking
+ *
+ * The client MUST mask all frames sent to the server. A server MUST
+ * close the connection upon receiving a frame with the MASK bit set to 0.
+ **/
+ if (!(wsctx->header.data->b1 & 0x80)) {
+ rfbErr("%s: got frame without mask; ret=%d\n", __func__, ret);
+ errno = EPROTO;
+ goto err_cleanup_state;
+ }
+
+
+ if (wsctx->header.payloadLen < 126 && wsctx->header.nRead >= 6) {
+ wsctx->header.headerLen = WS_HYBI_HEADER_LEN_SHORT;
+ wsctx->header.mask = wsctx->header.data->u.m;
+ } else if (wsctx->header.payloadLen == 126 && 8 <= wsctx->header.nRead) {
+ wsctx->header.headerLen = WS_HYBI_HEADER_LEN_EXTENDED;
+ wsctx->header.payloadLen = WS_NTOH16(wsctx->header.data->u.s16.l16);
+ wsctx->header.mask = wsctx->header.data->u.s16.m16;
+ } else if (wsctx->header.payloadLen == 127 && 14 <= wsctx->header.nRead) {
+ wsctx->header.headerLen = WS_HYBI_HEADER_LEN_LONG;
+ wsctx->header.payloadLen = WS_NTOH64(wsctx->header.data->u.s64.l64);
+ wsctx->header.mask = wsctx->header.data->u.s64.m64;
+ } else {
+ /* Incomplete frame header, try again */
+ rfbErr("%s: incomplete frame header; ret=%d\n", __func__, ret);
+ goto ret_header_pending;
+ }
+
+ char *h = wsctx->codeBufDecode;
+ int i;
+ ws_dbg("Header:\n");
+ for (i=0; i <10; i++) {
+ ws_dbg("0x%02X\n", (unsigned char)h[i]);
+ }
+ ws_dbg("\n");
+
+ /* while RFC 6455 mandates that lengths MUST be encoded with the minimum
+ * number of bytes, it does not specify for the server how to react on
+ * 'wrongly' encoded frames --- this implementation rejects them*/
+ if ((wsctx->header.headerLen > WS_HYBI_HEADER_LEN_SHORT
+ && wsctx->header.payloadLen < (uint64_t)126)
+ || (wsctx->header.headerLen > WS_HYBI_HEADER_LEN_EXTENDED
+ && wsctx->header.payloadLen < (uint64_t)65536)) {
+ rfbErr("%s: invalid length field; headerLen=%d payloadLen=%llu\n", __func__, wsctx->header.headerLen, wsctx->header.payloadLen);
+ errno = EPROTO;
+ goto err_cleanup_state;
+ }
+
+ /* update write position for next bytes */
+ wsctx->writePos = wsctx->codeBufDecode + wsctx->header.nRead;
+
+ /* set payload pointer just after header */
+ wsctx->readPos = (unsigned char *)(wsctx->codeBufDecode + wsctx->header.headerLen);
+
+ *nPayload = wsctx->header.nRead - wsctx->header.headerLen;
+ wsctx->nReadPayload = *nPayload;
+
+ ws_dbg("header complete: state=%d headerlen=%d payloadlen=%llu writeTo=%p nPayload=%d\n", wsctx->hybiDecodeState, wsctx->header.headerLen, wsctx->header.payloadLen, wsctx->writePos, *nPayload);
+
+ return WS_HYBI_STATE_DATA_NEEDED;
+
+ret_header_pending:
+ errno = EAGAIN;
+ *sockRet = -1;
+ return WS_HYBI_STATE_HEADER_PENDING;
+
+err_cleanup_state:
+ *sockRet = -1;
+err_cleanup_state_sock_closed:
+ hybiDecodeCleanupComplete(wsctx);
+ return WS_HYBI_STATE_ERR;
+}
+
+static int
+hybiWsFrameComplete(ws_ctx_t *wsctx)
+{
+ return wsctx != NULL && hybiRemaining(wsctx) == 0;
+}
+
+static char *
+hybiPayloadStart(ws_ctx_t *wsctx)
+{
+ return wsctx->codeBufDecode + wsctx->header.headerLen;
+}
+
+
+/**
+ * Read the remaining payload bytes from associated raw socket.
+ *
+ * - try to read remaining bytes from socket
+ * - unmask all multiples of 4
+ * - if frame incomplete but some bytes are left, these are copied to
+ * the carry buffer
+ * - if opcode is TEXT: Base64-decode all unmasked received bytes
+ * - set state for reading decoded data
+ * - reset write position to begin of buffer (+ header)
+ * --> before we retrieve more data we let the caller clear all bytes
+ * from the reception buffer
+ * - execute return data routine
+ *
+ * Sets errno corresponding to what it gets from the underlying
+ * socket or EPROTO if some invalid data is in the received frame
+ * or ECONNRESET if a close reason + message is received. EIO is used if
+ * an internal sanity check fails.
+ *
+ * @param[in] cl client ptr with raw socket reference
+ * @param[out] dst destination buffer
+ * @param[in] len size of destination buffer
+ * @param[out] sockRet emulated recv return value
+ * @param[in] nInBuf number of undecoded bytes before writePos from header read
+ * @return next hybi decode state
+ */
+static int
+hybiReadAndDecode(ws_ctx_t *wsctx, char *dst, int len, int *sockRet, int nInBuf)
+{
+ int n;
+ int i;
+ int toReturn; /* number of data bytes to return */
+ int toDecode; /* number of bytes to decode starting at wsctx->writePos */
+ int bufsize;
+ int nextRead;
+ unsigned char *data;
+ uint32_t *data32;
+
+ /* if data was carried over, copy to start of buffer */
+ memcpy(wsctx->writePos, wsctx->carryBuf, wsctx->carrylen);
+ wsctx->writePos += wsctx->carrylen;
+
+ /* -1 accounts for potential '\0' terminator for base64 decoding */
+ bufsize = wsctx->codeBufDecode + ARRAYSIZE(wsctx->codeBufDecode) - wsctx->writePos - 1;
+ ws_dbg("bufsize=%d\n", bufsize);
+ if (hybiRemaining(wsctx) > bufsize) {
+ nextRead = bufsize;
+ } else {
+ nextRead = hybiRemaining(wsctx);
+ }
+
+ ws_dbg("calling read with buf=%p and len=%d (decodebuf=%p headerLen=%d)\n", wsctx->writePos, nextRead, wsctx->codeBufDecode, wsctx->header.headerLen);
+
+ if (nextRead > 0) {
+ /* decode more data */
+ if (-1 == (n = wsctx->ctxInfo.readFunc(wsctx->ctxInfo.ctxPtr, wsctx->writePos, nextRead))) {
+ int olderrno = errno;
+ rfbErr("%s: read; %s", __func__, strerror(errno));
+ errno = olderrno;
+ *sockRet = -1;
+ return WS_HYBI_STATE_ERR;
+ } else if (n == 0) {
+ *sockRet = 0;
+ return WS_HYBI_STATE_ERR;
+ } else {
+ ws_dbg("read %d bytes from socket; nRead=%d\n", n, wsctx->nReadPayload);
+ }
+ } else {
+ n = 0;
+ }
+
+ wsctx->nReadPayload += n;
+ wsctx->writePos += n;
+
+ if (hybiRemaining(wsctx) == 0) {
+ wsctx->hybiDecodeState = WS_HYBI_STATE_FRAME_COMPLETE;
+ }
+
+ /* number of not yet unmasked payload bytes: what we read here + what was
+ * carried over + what was read with the header */
+ toDecode = n + wsctx->carrylen + nInBuf;
+ ws_dbg("toDecode=%d from n=%d carrylen=%d headerLen=%d\n", toDecode, n, wsctx->carrylen, wsctx->header.headerLen);
+ if (toDecode < 0) {
+ rfbErr("%s: internal error; negative number of bytes to decode: %d", __func__, toDecode);
+ errno=EIO;
+ *sockRet = -1;
+ return WS_HYBI_STATE_ERR;
+ }
+
+ /* for a possible base64 decoding, we decode multiples of 4 bytes until
+ * the whole frame is received and carry over any remaining bytes in the carry buf*/
+ data = (unsigned char *)(wsctx->writePos - toDecode);
+ data32= (uint32_t *)data;
+
+ for (i = 0; i < (toDecode >> 2); i++) {
+ data32[i] ^= wsctx->header.mask.u;
+ }
+ ws_dbg("mask decoding; i=%d toDecode=%d\n", i, toDecode);
+
+ if (wsctx->hybiDecodeState == WS_HYBI_STATE_FRAME_COMPLETE) {
+ /* process the remaining bytes (if any) */
+ for (i*=4; i < toDecode; i++) {
+ data[i] ^= wsctx->header.mask.c[i % 4];
+ }
+
+ /* all data is here, no carrying */
+ wsctx->carrylen = 0;
+ } else {
+ /* carry over remaining, non-multiple-of-four bytes */
+ wsctx->carrylen = toDecode - (i * 4);
+ if (wsctx->carrylen < 0 || wsctx->carrylen > ARRAYSIZE(wsctx->carryBuf)) {
+ rfbErr("%s: internal error, invalid carry over size: carrylen=%d, toDecode=%d, i=%d", __func__, wsctx->carrylen, toDecode, i);
+ *sockRet = -1;
+ errno = EIO;
+ return WS_HYBI_STATE_ERR;
+ }
+ ws_dbg("carrying over %d bytes from %p to %p\n", wsctx->carrylen, wsctx->writePos + (i * 4), wsctx->carryBuf);
+ memcpy(wsctx->carryBuf, data + (i * 4), wsctx->carrylen);
+ wsctx->writePos -= wsctx->carrylen;
+ }
+
+ toReturn = toDecode - wsctx->carrylen;
+
+ switch (wsctx->header.opcode) {
+ case WS_OPCODE_CLOSE:
+ /* this data is not returned as payload data */
+ if (hybiWsFrameComplete(wsctx)) {
+ *(wsctx->writePos) = '\0';
+ ws_dbg("got close cmd %d, reason %d: %s\n", (int)(wsctx->writePos - hybiPayloadStart(wsctx)), WS_NTOH16(((uint16_t *)hybiPayloadStart(wsctx))[0]), &hybiPayloadStart(wsctx)[2]);
+ errno = ECONNRESET;
+ *sockRet = -1;
+ return WS_HYBI_STATE_FRAME_COMPLETE;
+ } else {
+ ws_dbg("got close cmd; waiting for %d more bytes to arrive\n", hybiRemaining(wsctx));
+ *sockRet = -1;
+ errno = EAGAIN;
+ return WS_HYBI_STATE_CLOSE_REASON_PENDING;
+ }
+ break;
+ case WS_OPCODE_TEXT_FRAME:
+ data[toReturn] = '\0';
+ ws_dbg("Initiate Base64 decoding in %p with max size %d and '\\0' at %p\n", data, bufsize, data + toReturn);
+ if (-1 == (wsctx->readlen = rfbBase64PtoN((char *)data, data, bufsize))) {
+ rfbErr("%s: Base64 decode error; %s\n", __func__, strerror(errno));
+ }
+ wsctx->writePos = hybiPayloadStart(wsctx);
+ break;
+ case WS_OPCODE_BINARY_FRAME:
+ wsctx->readlen = toReturn;
+ wsctx->writePos = hybiPayloadStart(wsctx);
+ ws_dbg("set readlen=%d writePos=%p\n", wsctx->readlen, wsctx->writePos);
+ break;
+ default:
+ rfbErr("%s: unhandled opcode %d, b0: %02x, b1: %02x\n", __func__, (int)wsctx->header.opcode, wsctx->header.data->b0, wsctx->header.data->b1);
+ }
+ wsctx->readPos = data;
+
+ return hybiReturnData(dst, len, wsctx, sockRet);
+}
+
+/**
+ * Read function for websocket-socket emulation.
+ *
+ * 0 1 2 3
+ * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+ * +-+-+-+-+-------+-+-------------+-------------------------------+
+ * |F|R|R|R| opcode|M| Payload len | Extended payload length |
+ * |I|S|S|S| (4) |A| (7) | (16/64) |
+ * |N|V|V|V| |S| | (if payload len==126/127) |
+ * | |1|2|3| |K| | |
+ * +-+-+-+-+-------+-+-------------+ - - - - - - - - - - - - - - - +
+ * | Extended payload length continued, if payload len == 127 |
+ * + - - - - - - - - - - - - - - - +-------------------------------+
+ * | |Masking-key, if MASK set to 1 |
+ * +-------------------------------+-------------------------------+
+ * | Masking-key (continued) | Payload Data |
+ * +-------------------------------- - - - - - - - - - - - - - - - +
+ * : Payload Data continued ... :
+ * + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
+ * | Payload Data continued ... |
+ * +---------------------------------------------------------------+
+ *
+ * Using the decode buffer, this function:
+ * - reads the complete header from the underlying socket
+ * - reads any remaining data bytes
+ * - unmasks the payload data using the provided mask
+ * - decodes Base64 encoded text data
+ * - copies len bytes of decoded payload data into dst
+ *
+ * Emulates a read call on a socket.
+ */
+int
+webSocketsDecodeHybi(ws_ctx_t *wsctx, char *dst, int len)
+{
+ int result = -1;
+ /* int fin; */ /* not used atm */
+
+ ws_dbg("%s_enter: len=%d; "
+ "CTX: readlen=%d readPos=%p "
+ "writeTo=%p "
+ "state=%d payloadtoRead=%d payloadRemaining=%llu "
+ " nReadPayload=%d carrylen=%d carryBuf=%p\n",
+ __func__, len,
+ wsctx->readlen, wsctx->readPos,
+ wsctx->writePos,
+ wsctx->hybiDecodeState, wsctx->header.payloadLen, hybiRemaining(wsctx),
+ wsctx->nReadPayload, wsctx->carrylen, wsctx->carryBuf);
+
+ switch (wsctx->hybiDecodeState){
+ int nInBuf;
+ case WS_HYBI_STATE_HEADER_PENDING:
+ wsctx->hybiDecodeState = hybiReadHeader(wsctx, &result, &nInBuf);
+ if (wsctx->hybiDecodeState == WS_HYBI_STATE_ERR) {
+ goto spor;
+ }
+ if (wsctx->hybiDecodeState != WS_HYBI_STATE_HEADER_PENDING) {
+
+ /* when header is complete, try to read some more data */
+ wsctx->hybiDecodeState = hybiReadAndDecode(wsctx, dst, len, &result, nInBuf);
+ }
+ break;
+ case WS_HYBI_STATE_DATA_AVAILABLE:
+ wsctx->hybiDecodeState = hybiReturnData(dst, len, wsctx, &result);
+ break;
+ case WS_HYBI_STATE_DATA_NEEDED:
+ wsctx->hybiDecodeState = hybiReadAndDecode(wsctx, dst, len, &result, 0);
+ break;
+ case WS_HYBI_STATE_CLOSE_REASON_PENDING:
+ wsctx->hybiDecodeState = hybiReadAndDecode(wsctx, dst, len, &result, 0);
+ break;
+ default:
+ /* invalid state */
+ rfbErr("%s: called with invalid state %d\n", wsctx->hybiDecodeState);
+ result = -1;
+ errno = EIO;
+ wsctx->hybiDecodeState = WS_HYBI_STATE_ERR;
+ }
+
+ /* single point of return, if someone has questions :-) */
+spor:
+ if (wsctx->hybiDecodeState == WS_HYBI_STATE_FRAME_COMPLETE) {
+ ws_dbg("frame received successfully, cleaning up: read=%d hlen=%d plen=%d\n", wsctx->header.nRead, wsctx->header.headerLen, wsctx->header.payloadLen);
+ if (wsctx->header.fin && !isControlFrame(wsctx)) {
+ /* frame finished, cleanup state */
+ hybiDecodeCleanupComplete(wsctx);
+ } else {
+ /* always retain continuation opcode for unfinished data frames
+ * or control frames, which may interleave with data frames */
+ hybiDecodeCleanupForContinuation(wsctx);
+ }
+ } else if (wsctx->hybiDecodeState == WS_HYBI_STATE_ERR) {
+ hybiDecodeCleanupComplete(wsctx);
+ }
+
+ ws_dbg("%s_exit: len=%d; "
+ "CTX: readlen=%d readPos=%p "
+ "writePos=%p "
+ "state=%d payloadtoRead=%d payloadRemaining=%d "
+ "nRead=%d carrylen=%d carryBuf=%p "
+ "result=%d "
+ "errno=%d\n",
+ __func__, len,
+ wsctx->readlen, wsctx->readPos,
+ wsctx->writePos,
+ wsctx->hybiDecodeState, wsctx->header.payloadLen, hybiRemaining(wsctx),
+ wsctx->nReadPayload, wsctx->carrylen, wsctx->carryBuf,
+ result,
+ errno);
+ return result;
+}
diff --git a/libvncserver/ws_decode.h b/libvncserver/ws_decode.h
new file mode 100644
index 0000000..eb774a4
--- /dev/null
+++ b/libvncserver/ws_decode.h
@@ -0,0 +1,145 @@
+#ifndef _WS_DECODE_H_
+#define _WS_DECODE_H_
+
+#include <stdint.h>
+#include <rfb/rfb.h>
+
+#if defined(__APPLE__)
+
+#include <libkern/OSByteOrder.h>
+#define WS_NTOH64(n) OSSwapBigToHostInt64(n)
+#define WS_NTOH32(n) OSSwapBigToHostInt32(n)
+#define WS_NTOH16(n) OSSwapBigToHostInt16(n)
+#define WS_HTON64(n) OSSwapHostToBigInt64(n)
+#define WS_HTON16(n) OSSwapHostToBigInt16(n)
+
+#else
+
+#define WS_NTOH64(n) htobe64(n)
+#define WS_NTOH32(n) htobe32(n)
+#define WS_NTOH16(n) htobe16(n)
+#define WS_HTON64(n) htobe64(n)
+#define WS_HTON16(n) htobe16(n)
+
+#endif
+
+#define B64LEN(__x) (((__x + 2) / 3) * 12 / 3)
+#define WSHLENMAX 14LL /* 2 + sizeof(uint64_t) + sizeof(uint32_t) */
+#define WS_HYBI_MASK_LEN 4
+
+#define ARRAYSIZE(a) ((sizeof(a) / sizeof((a[0]))) / (size_t)(!(sizeof(a) % sizeof((a[0])))))
+
+struct ws_ctx_s;
+typedef struct ws_ctx_s ws_ctx_t;
+
+typedef int (*wsEncodeFunc)(rfbClientPtr cl, const char *src, int len, char **dst);
+typedef int (*wsDecodeFunc)(ws_ctx_t *wsctx, char *dst, int len);
+
+typedef int (*wsReadFunc)(void *ctx, char *dst, size_t len);
+
+typedef struct ctxInfo_s{
+ void *ctxPtr;
+ wsReadFunc readFunc;
+} ctxInfo_t;
+
+enum {
+ /* header not yet received completely */
+ WS_HYBI_STATE_HEADER_PENDING,
+ /* data available */
+ WS_HYBI_STATE_DATA_AVAILABLE,
+ WS_HYBI_STATE_DATA_NEEDED,
+ /* received a complete frame */
+ WS_HYBI_STATE_FRAME_COMPLETE,
+ /* received part of a 'close' frame */
+ WS_HYBI_STATE_CLOSE_REASON_PENDING,
+ /* */
+ WS_HYBI_STATE_ERR
+};
+
+typedef union ws_mask_s {
+ char c[4];
+ uint32_t u;
+} ws_mask_t;
+
+/* XXX: The union and the structs do not need to be named.
+ * We are working around a bug present in GCC < 4.6 which prevented
+ * it from recognizing anonymous structs and unions.
+ * See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=4784
+ */
+typedef struct
+#if __GNUC__
+__attribute__ ((__packed__))
+#endif
+ws_header_s {
+ unsigned char b0;
+ unsigned char b1;
+ union {
+ struct
+#if __GNUC__
+ __attribute__ ((__packed__))
+#endif
+ {
+ uint16_t l16;
+ ws_mask_t m16;
+ } s16;
+ struct
+#if __GNUC__
+__attribute__ ((__packed__))
+#endif
+ {
+ uint64_t l64;
+ ws_mask_t m64;
+ } s64;
+ ws_mask_t m;
+ } u;
+} ws_header_t;
+
+typedef struct ws_header_data_s {
+ ws_header_t *data;
+ /** bytes read */
+ int nRead;
+ /** mask value */
+ ws_mask_t mask;
+ /** length of frame header including payload len, but without mask */
+ int headerLen;
+ /** length of the payload data */
+ uint64_t payloadLen;
+ /** opcode */
+ unsigned char opcode;
+ /** fin bit */
+ unsigned char fin;
+} ws_header_data_t;
+
+struct ws_ctx_s {
+ char codeBufDecode[2048 + WSHLENMAX]; /* base64 + maximum frame header length */
+ char codeBufEncode[B64LEN(UPDATE_BUF_SIZE) + WSHLENMAX]; /* base64 + maximum frame header length */
+ char *writePos;
+ unsigned char *readPos;
+ int readlen;
+ int hybiDecodeState;
+ char carryBuf[3]; /* For base64 carry-over */
+ int carrylen;
+ int base64;
+ ws_header_data_t header;
+ uint64_t nReadPayload;
+ unsigned char continuation_opcode;
+ wsEncodeFunc encode;
+ wsDecodeFunc decode;
+ ctxInfo_t ctxInfo;
+};
+
+enum
+{
+ WS_OPCODE_CONTINUATION = 0x00,
+ WS_OPCODE_TEXT_FRAME = 0x01,
+ WS_OPCODE_BINARY_FRAME = 0x02,
+ WS_OPCODE_CLOSE = 0x08,
+ WS_OPCODE_PING = 0x09,
+ WS_OPCODE_PONG = 0x0A,
+ WS_OPCODE_INVALID = 0xFF
+};
+
+int webSocketsDecodeHybi(ws_ctx_t *wsctx, char *dst, int len);
+
+void hybiDecodeCleanupComplete(ws_ctx_t *wsctx);
+#endif
diff --git a/libvncserver/zlib.c b/libvncserver/zlib.c
index 45a1314..6fee4df 100644
--- a/libvncserver/zlib.c
+++ b/libvncserver/zlib.c
@@ -45,10 +45,11 @@
* tight. N.B. ZRLE does it the traditional way with per-client storage
* (and so at least ZRLE will work threaded on older systems.)
*/
-#if LIBVNCSERVER_HAVE_LIBPTHREAD && LIBVNCSERVER_HAVE_TLS && !defined(TLS) && defined(__linux__)
+#if defined(__GNUC__)
#define TLS __thread
-#endif
-#ifndef TLS
+#elif defined(_MSC_VER)
+#define TLS __declspec(thread)
+#else
#define TLS
#endif
diff --git a/m4/.gitignore b/m4/.gitignore
deleted file mode 100644
index 7c9f9ac..0000000
--- a/m4/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-*.m4 \ No newline at end of file
diff --git a/m4/ax_prefix_config_h.m4 b/m4/ax_prefix_config_h.m4
deleted file mode 100644
index c17563f..0000000
--- a/m4/ax_prefix_config_h.m4
+++ /dev/null
@@ -1,203 +0,0 @@
-# ===========================================================================
-# http://www.gnu.org/software/autoconf-archive/ax_prefix_config_h.html
-# ===========================================================================
-#
-# SYNOPSIS
-#
-# AX_PREFIX_CONFIG_H [(OUTPUT-HEADER [,PREFIX [,ORIG-HEADER]])]
-#
-# DESCRIPTION
-#
-# Generate an installable config.h.
-#
-# A package should not normally install its config.h as a system header,
-# but if it must, this macro can be used to avoid namespace pollution by
-# making a copy of config.h with a prefix added to all the macro names.
-#
-# Each "#define SOMEDEF" line of the configuration header has the given
-# prefix added, in the same case as the first character of the macro name.
-#
-# Defaults:
-#
-# OUTPUT-HEADER = $PACKAGE-config.h
-# PREFIX = $PACKAGE
-# ORIG-HEADER, from AM_CONFIG_HEADER(config.h)
-#
-# Your configure.ac script should contain both macros in this order.
-#
-# Example:
-#
-# AC_INIT(config.h.in) # config.h.in as created by "autoheader"
-# AM_INIT_AUTOMAKE(testpkg, 0.1.1) # makes #undef VERSION and PACKAGE
-# AM_CONFIG_HEADER(config.h) # prep config.h from config.h.in
-# AX_PREFIX_CONFIG_H(mylib/_config.h) # prep mylib/_config.h from it..
-# AC_MEMORY_H # makes "#undef NEED_MEMORY_H"
-# AC_C_CONST_H # makes "#undef const"
-# AC_OUTPUT(Makefile) # creates the "config.h" now
-# # and also mylib/_config.h
-#
-# If the argument to AX_PREFIX_CONFIG_H would have been omitted then the
-# default output file would have been called simply "testpkg-config.h",
-# but even under the name "mylib/_config.h" it contains prefix-defines
-# like
-#
-# #ifndef TESTPKG_VERSION
-# #define TESTPKG_VERSION "0.1.1"
-# #endif
-# #ifndef TESTPKG_NEED_MEMORY_H
-# #define TESTPKG_NEED_MEMORY_H 1
-# #endif
-# #ifndef _testpkg_const
-# #define _testpkg_const _const
-# #endif
-#
-# and this "mylib/_config.h" can be installed along with other header
-# files, which is most convenient when creating a shared library (that has
-# some headers) whose functionality depends on features detected at
-# compile-time. No need to invent some "mylib-confdefs.h.in" manually.
-#
-# Note that some AC_DEFINEs that end up in the config.h file are actually
-# self-referential - e.g. AC_C_INLINE, AC_C_CONST, and the AC_TYPE_OFF_T
-# say that they "will define inline|const|off_t if the system does not do
-# it by itself". You might want to clean up about these - consider an
-# extra mylib/conf.h that reads something like:
-#
-# #include <mylib/_config.h>
-# #ifndef _testpkg_const
-# #define _testpkg_const const
-# #endif
-#
-# and then start using _testpkg_const in the header files. That is also a
-# good thing to differentiate whether some library-user has starting to
-# take up with a different compiler, so perhaps it could read something
-# like this:
-#
-# #ifdef _MSC_VER
-# #include <mylib/_msvc.h>
-# #else
-# #include <mylib/_config.h>
-# #endif
-# #ifndef _testpkg_const
-# #define _testpkg_const const
-# #endif
-#
-# LICENSE
-#
-# Copyright (c) 2014 Reuben Thomas <rrt@sc3d.org>
-# Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de>
-# Copyright (c) 2008 Marten Svantesson
-# Copyright (c) 2008 Gerald Point <Gerald.Point@labri.fr>
-#
-# This program is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License as published by the
-# Free Software Foundation; either version 3 of the License, or (at your
-# option) any later version.
-#
-# This program is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
-# Public License for more details.
-#
-# You should have received a copy of the GNU General Public License along
-# with this program. If not, see <http://www.gnu.org/licenses/>.
-#
-# As a special exception, the respective Autoconf Macro's copyright owner
-# gives unlimited permission to copy, distribute and modify the configure
-# scripts that are the output of Autoconf when processing the Macro. You
-# need not follow the terms of the GNU General Public License when using
-# or distributing such scripts, even though portions of the text of the
-# Macro appear in them. The GNU General Public License (GPL) does govern
-# all other use of the material that constitutes the Autoconf Macro.
-#
-# This special exception to the GPL applies to versions of the Autoconf
-# Macro released by the Autoconf Archive. When you make and distribute a
-# modified version of the Autoconf Macro, you may extend this special
-# exception to the GPL to apply to your modified version as well.
-
-#serial 15
-
-AC_DEFUN([AX_PREFIX_CONFIG_H],[dnl
-AC_PREREQ([2.62])
-AC_BEFORE([AC_CONFIG_HEADERS],[$0])dnl
-AC_CONFIG_COMMANDS(m4_default([$1], [$PACKAGE-config.h]),[dnl
-AS_VAR_PUSHDEF([_OUT],[ac_prefix_conf_OUT])dnl
-AS_VAR_PUSHDEF([_DEF],[ac_prefix_conf_DEF])dnl
-AS_VAR_PUSHDEF([_PKG],[ac_prefix_conf_PKG])dnl
-AS_VAR_PUSHDEF([_LOW],[ac_prefix_conf_LOW])dnl
-AS_VAR_PUSHDEF([_UPP],[ac_prefix_conf_UPP])dnl
-AS_VAR_PUSHDEF([_INP],[ac_prefix_conf_INP])dnl
-m4_pushdef([_script],[conftest.prefix])dnl
-m4_pushdef([_symbol],[m4_cr_Letters[]m4_cr_digits[]_])dnl
-_OUT=`echo m4_default([$1], [$PACKAGE-config.h])`
-_DEF=`echo _$_OUT | sed -e "y:m4_cr_letters:m4_cr_LETTERS[]:" -e "s/@<:@^m4_cr_Letters@:>@/_/g"`
-_PKG=`echo m4_default([$2], [$PACKAGE])`
-_LOW=`echo _$_PKG | sed -e "y:m4_cr_LETTERS-:m4_cr_letters[]_:"`
-_UPP=`echo $_PKG | sed -e "y:m4_cr_letters-:m4_cr_LETTERS[]_:" -e "/^@<:@m4_cr_digits@:>@/s/^/_/"`
-_INP=`echo "$3" | sed -e 's/ *//'`
-if test ".$_INP" = "."; then
- for ac_file in : $CONFIG_HEADERS; do test "_$ac_file" = _: && continue
- case "$ac_file" in
- *.h) _INP=$ac_file ;;
- *)
- esac
- test ".$_INP" != "." && break
- done
-fi
-if test ".$_INP" = "."; then
- case "$_OUT" in
- */*) _INP=`basename "$_OUT"`
- ;;
- *-*) _INP=`echo "$_OUT" | sed -e "s/@<:@_symbol@:>@*-//"`
- ;;
- *) _INP=config.h
- ;;
- esac
-fi
-if test -z "$_PKG" ; then
- AC_MSG_ERROR([no prefix for _PREFIX_PKG_CONFIG_H])
-else
- if test ! -f "$_INP" ; then if test -f "$srcdir/$_INP" ; then
- _INP="$srcdir/$_INP"
- fi fi
- AC_MSG_NOTICE(creating $_OUT - prefix $_UPP for $_INP defines)
- if test -f $_INP ; then
- AS_ECHO(["s/^@%:@undef *\\(@<:@m4_cr_LETTERS[]_@:>@\\)/@%:@undef $_UPP""_\\1/"]) > _script
- AS_ECHO(["s/^@%:@undef *\\(@<:@m4_cr_letters@:>@\\)/@%:@undef $_LOW""_\\1/"]) >> _script
- AS_ECHO(["s/^@%:@def[]ine *\\(@<:@m4_cr_LETTERS[]_@:>@@<:@_symbol@:>@*\\)\\(.*\\)/@%:@ifndef $_UPP""_\\1\\"]) >> _script
- AS_ECHO(["@%:@def[]ine $_UPP""_\\1\\2\\"]) >> _script
- AS_ECHO(["@%:@endif/"]) >> _script
- AS_ECHO(["s/^@%:@def[]ine *\\(@<:@m4_cr_letters@:>@@<:@_symbol@:>@*\\)\\(.*\\)/@%:@ifndef $_LOW""_\\1\\"]) >> _script
- AS_ECHO(["@%:@define $_LOW""_\\1\\2\\"]) >> _script
- AS_ECHO(["@%:@endif/"]) >> _script
- # now executing _script on _DEF input to create _OUT output file
- echo "@%:@ifndef $_DEF" >$tmp/pconfig.h
- echo "@%:@def[]ine $_DEF 1" >>$tmp/pconfig.h
- echo ' ' >>$tmp/pconfig.h
- echo /'*' $_OUT. Generated automatically at end of configure. '*'/ >>$tmp/pconfig.h
-
- sed -f _script $_INP >>$tmp/pconfig.h
- echo ' ' >>$tmp/pconfig.h
- echo '/* once:' $_DEF '*/' >>$tmp/pconfig.h
- echo "@%:@endif" >>$tmp/pconfig.h
- if cmp -s $_OUT $tmp/pconfig.h 2>/dev/null; then
- AC_MSG_NOTICE([$_OUT is unchanged])
- else
- ac_dir=`AS_DIRNAME(["$_OUT"])`
- AS_MKDIR_P(["$ac_dir"])
- rm -f "$_OUT"
- mv $tmp/pconfig.h "$_OUT"
- fi
- else
- AC_MSG_ERROR([input file $_INP does not exist - skip generating $_OUT])
- fi
- rm -f conftest.*
-fi
-m4_popdef([_symbol])dnl
-m4_popdef([_script])dnl
-AS_VAR_POPDEF([_INP])dnl
-AS_VAR_POPDEF([_UPP])dnl
-AS_VAR_POPDEF([_LOW])dnl
-AS_VAR_POPDEF([_PKG])dnl
-AS_VAR_POPDEF([_DEF])dnl
-AS_VAR_POPDEF([_OUT])dnl
-],[PACKAGE="$PACKAGE"])])
diff --git a/m4/ax_type_socklen_t.m4 b/m4/ax_type_socklen_t.m4
deleted file mode 100644
index 834c4cf..0000000
--- a/m4/ax_type_socklen_t.m4
+++ /dev/null
@@ -1,61 +0,0 @@
-# ===========================================================================
-# http://www.gnu.org/software/autoconf-archive/ax_type_socklen_t.html
-# ===========================================================================
-#
-# SYNOPSIS
-#
-# AX_TYPE_SOCKLEN_T
-#
-# DESCRIPTION
-#
-# Check whether sys/socket.h defines type socklen_t. Please note that some
-# systems require sys/types.h to be included before sys/socket.h can be
-# compiled.
-#
-# LICENSE
-#
-# Copyright (c) 2008 Lars Brinkhoff <lars@nocrew.org>
-#
-# This program is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License as published by the
-# Free Software Foundation; either version 2 of the License, or (at your
-# option) any later version.
-#
-# This program is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
-# Public License for more details.
-#
-# You should have received a copy of the GNU General Public License along
-# with this program. If not, see <http://www.gnu.org/licenses/>.
-#
-# As a special exception, the respective Autoconf Macro's copyright owner
-# gives unlimited permission to copy, distribute and modify the configure
-# scripts that are the output of Autoconf when processing the Macro. You
-# need not follow the terms of the GNU General Public License when using
-# or distributing such scripts, even though portions of the text of the
-# Macro appear in them. The GNU General Public License (GPL) does govern
-# all other use of the material that constitutes the Autoconf Macro.
-#
-# This special exception to the GPL applies to versions of the Autoconf
-# Macro released by the Autoconf Archive. When you make and distribute a
-# modified version of the Autoconf Macro, you may extend this special
-# exception to the GPL to apply to your modified version as well.
-
-#serial 5
-
-AU_ALIAS([TYPE_SOCKLEN_T], [AX_TYPE_SOCKLEN_T])
-AC_DEFUN([AX_TYPE_SOCKLEN_T],
-[AC_CACHE_CHECK([for socklen_t], ac_cv_ax_type_socklen_t,
-[
- AC_TRY_COMPILE(
- [#include <sys/types.h>
- #include <sys/socket.h>],
- [socklen_t len = 42; return 0;],
- ac_cv_ax_type_socklen_t=yes,
- ac_cv_ax_type_socklen_t=no)
-])
- if test $ac_cv_ax_type_socklen_t != yes; then
- AC_DEFINE(socklen_t, int, [Substitute for socklen_t])
- fi
-])
diff --git a/m4/libgcrypt.m4 b/m4/libgcrypt.m4
deleted file mode 100644
index 831dc0c..0000000
--- a/m4/libgcrypt.m4
+++ /dev/null
@@ -1,123 +0,0 @@
-dnl Autoconf macros for libgcrypt
-dnl Copyright (C) 2002, 2004 Free Software Foundation, Inc.
-dnl
-dnl This file is free software; as a special exception the author gives
-dnl unlimited permission to copy and/or distribute it, with or without
-dnl modifications, as long as this notice is preserved.
-dnl
-dnl This file is distributed in the hope that it will be useful, but
-dnl WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
-dnl implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-
-
-dnl AM_PATH_LIBGCRYPT([MINIMUM-VERSION,
-dnl [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND ]]])
-dnl Test for libgcrypt and define LIBGCRYPT_CFLAGS and LIBGCRYPT_LIBS.
-dnl MINIMUN-VERSION is a string with the version number optionalliy prefixed
-dnl with the API version to also check the API compatibility. Example:
-dnl a MINIMUN-VERSION of 1:1.2.5 won't pass the test unless the installed
-dnl version of libgcrypt is at least 1.2.5 *and* the API number is 1. Using
-dnl this features allows to prevent build against newer versions of libgcrypt
-dnl with a changed API.
-dnl
-AC_DEFUN([AM_PATH_LIBGCRYPT],
-[ AC_ARG_WITH(libgcrypt-prefix,
- AC_HELP_STRING([--with-libgcrypt-prefix=PFX],
- [prefix where LIBGCRYPT is installed (optional)]),
- libgcrypt_config_prefix="$withval", libgcrypt_config_prefix="")
- if test x$libgcrypt_config_prefix != x ; then
- if test x${LIBGCRYPT_CONFIG+set} != xset ; then
- LIBGCRYPT_CONFIG=$libgcrypt_config_prefix/bin/libgcrypt-config
- fi
- fi
-
- AC_PATH_TOOL(LIBGCRYPT_CONFIG, libgcrypt-config, no)
- tmp=ifelse([$1], ,1:1.2.0,$1)
- if echo "$tmp" | grep ':' >/dev/null 2>/dev/null ; then
- req_libgcrypt_api=`echo "$tmp" | sed 's/\(.*\):\(.*\)/\1/'`
- min_libgcrypt_version=`echo "$tmp" | sed 's/\(.*\):\(.*\)/\2/'`
- else
- req_libgcrypt_api=0
- min_libgcrypt_version="$tmp"
- fi
-
- AC_MSG_CHECKING(for LIBGCRYPT - version >= $min_libgcrypt_version)
- ok=no
- if test "$LIBGCRYPT_CONFIG" != "no" ; then
- req_major=`echo $min_libgcrypt_version | \
- sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
- req_minor=`echo $min_libgcrypt_version | \
- sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
- req_micro=`echo $min_libgcrypt_version | \
- sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
- libgcrypt_config_version=`$LIBGCRYPT_CONFIG --version`
- major=`echo $libgcrypt_config_version | \
- sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`
- minor=`echo $libgcrypt_config_version | \
- sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`
- micro=`echo $libgcrypt_config_version | \
- sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\3/'`
- if test "$major" -gt "$req_major"; then
- ok=yes
- else
- if test "$major" -eq "$req_major"; then
- if test "$minor" -gt "$req_minor"; then
- ok=yes
- else
- if test "$minor" -eq "$req_minor"; then
- if test "$micro" -ge "$req_micro"; then
- ok=yes
- fi
- fi
- fi
- fi
- fi
- fi
- if test $ok = yes; then
- AC_MSG_RESULT([yes ($libgcrypt_config_version)])
- else
- AC_MSG_RESULT(no)
- fi
- if test $ok = yes; then
- # If we have a recent libgcrypt, we should also check that the
- # API is compatible
- if test "$req_libgcrypt_api" -gt 0 ; then
- tmp=`$LIBGCRYPT_CONFIG --api-version 2>/dev/null || echo 0`
- if test "$tmp" -gt 0 ; then
- AC_MSG_CHECKING([LIBGCRYPT API version])
- if test "$req_libgcrypt_api" -eq "$tmp" ; then
- AC_MSG_RESULT([okay])
- else
- ok=no
- AC_MSG_RESULT([does not match. want=$req_libgcrypt_api got=$tmp])
- fi
- fi
- fi
- fi
- if test $ok = yes; then
- LIBGCRYPT_CFLAGS=`$LIBGCRYPT_CONFIG --cflags`
- LIBGCRYPT_LIBS=`$LIBGCRYPT_CONFIG --libs`
- ifelse([$2], , :, [$2])
- if test x"$host" != x ; then
- libgcrypt_config_host=`$LIBGCRYPT_CONFIG --host 2>/dev/null || echo none`
- if test x"$libgcrypt_config_host" != xnone ; then
- if test x"$libgcrypt_config_host" != x"$host" ; then
- AC_MSG_WARN([[
-***
-*** The config script $LIBGCRYPT_CONFIG was
-*** built for $libgcrypt_config_host and thus may not match the
-*** used host $host.
-*** You may want to use the configure option --with-libgcrypt-prefix
-*** to specify a matching config script.
-***]])
- fi
- fi
- fi
- else
- LIBGCRYPT_CFLAGS=""
- LIBGCRYPT_LIBS=""
- ifelse([$3], , :, [$3])
- fi
- AC_SUBST(LIBGCRYPT_CFLAGS)
- AC_SUBST(LIBGCRYPT_LIBS)
-])
diff --git a/rfb/default8x16.h b/rfb/default8x16.h
index 252f411..6096b1c 100644
--- a/rfb/default8x16.h
+++ b/rfb/default8x16.h
@@ -1,3 +1,6 @@
+#ifndef _DEFAULT_8_X_16_H
+#define _DEFAULT_8_X_16_H
+
static unsigned char default8x16FontData[4096+1]={
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x7e,0x81,0xa5,0x81,0x81,0xbd,0x99,0x81,0x81,0x7e,0x00,0x00,0x00,0x00,
@@ -259,3 +262,5 @@ static unsigned char default8x16FontData[4096+1]={
static int default8x16FontMetaData[256*5+1]={
0,8,16,0,0,16,8,16,0,0,32,8,16,0,0,48,8,16,0,0,64,8,16,0,0,80,8,16,0,0,96,8,16,0,0,112,8,16,0,0,128,8,16,0,0,144,8,16,0,0,160,8,16,0,0,176,8,16,0,0,192,8,16,0,0,208,8,16,0,0,224,8,16,0,0,240,8,16,0,0,256,8,16,0,0,272,8,16,0,0,288,8,16,0,0,304,8,16,0,0,320,8,16,0,0,336,8,16,0,0,352,8,16,0,0,368,8,16,0,0,384,8,16,0,0,400,8,16,0,0,416,8,16,0,0,432,8,16,0,0,448,8,16,0,0,464,8,16,0,0,480,8,16,0,0,496,8,16,0,0,512,8,16,0,0,528,8,16,0,0,544,8,16,0,0,560,8,16,0,0,576,8,16,0,0,592,8,16,0,0,608,8,16,0,0,624,8,16,0,0,640,8,16,0,0,656,8,16,0,0,672,8,16,0,0,688,8,16,0,0,704,8,16,0,0,720,8,16,0,0,736,8,16,0,0,752,8,16,0,0,768,8,16,0,0,784,8,16,0,0,800,8,16,0,0,816,8,16,0,0,832,8,16,0,0,848,8,16,0,0,864,8,16,0,0,880,8,16,0,0,896,8,16,0,0,912,8,16,0,0,928,8,16,0,0,944,8,16,0,0,960,8,16,0,0,976,8,16,0,0,992,8,16,0,0,1008,8,16,0,0,1024,8,16,0,0,1040,8,16,0,0,1056,8,16,0,0,1072,8,16,0,0,1088,8,16,0,0,1104,8,16,0,0,1120,8,16,0,0,1136,8,16,0,0,1152,8,16,0,0,1168,8,16,0,0,1184,8,16,0,0,1200,8,16,0,0,1216,8,16,0,0,1232,8,16,0,0,1248,8,16,0,0,1264,8,16,0,0,1280,8,16,0,0,1296,8,16,0,0,1312,8,16,0,0,1328,8,16,0,0,1344,8,16,0,0,1360,8,16,0,0,1376,8,16,0,0,1392,8,16,0,0,1408,8,16,0,0,1424,8,16,0,0,1440,8,16,0,0,1456,8,16,0,0,1472,8,16,0,0,1488,8,16,0,0,1504,8,16,0,0,1520,8,16,0,0,1536,8,16,0,0,1552,8,16,0,0,1568,8,16,0,0,1584,8,16,0,0,1600,8,16,0,0,1616,8,16,0,0,1632,8,16,0,0,1648,8,16,0,0,1664,8,16,0,0,1680,8,16,0,0,1696,8,16,0,0,1712,8,16,0,0,1728,8,16,0,0,1744,8,16,0,0,1760,8,16,0,0,1776,8,16,0,0,1792,8,16,0,0,1808,8,16,0,0,1824,8,16,0,0,1840,8,16,0,0,1856,8,16,0,0,1872,8,16,0,0,1888,8,16,0,0,1904,8,16,0,0,1920,8,16,0,0,1936,8,16,0,0,1952,8,16,0,0,1968,8,16,0,0,1984,8,16,0,0,2000,8,16,0,0,2016,8,16,0,0,2032,8,16,0,0,2048,8,16,0,0,2064,8,16,0,0,2080,8,16,0,0,2096,8,16,0,0,2112,8,16,0,0,2128,8,16,0,0,2144,8,16,0,0,2160,8,16,0,0,2176,8,16,0,0,2192,8,16,0,0,2208,8,16,0,0,2224,8,16,0,0,2240,8,16,0,0,2256,8,16,0,0,2272,8,16,0,0,2288,8,16,0,0,2304,8,16,0,0,2320,8,16,0,0,2336,8,16,0,0,2352,8,16,0,0,2368,8,16,0,0,2384,8,16,0,0,2400,8,16,0,0,2416,8,16,0,0,2432,8,16,0,0,2448,8,16,0,0,2464,8,16,0,0,2480,8,16,0,0,2496,8,16,0,0,2512,8,16,0,0,2528,8,16,0,0,2544,8,16,0,0,2560,8,16,0,0,2576,8,16,0,0,2592,8,16,0,0,2608,8,16,0,0,2624,8,16,0,0,2640,8,16,0,0,2656,8,16,0,0,2672,8,16,0,0,2688,8,16,0,0,2704,8,16,0,0,2720,8,16,0,0,2736,8,16,0,0,2752,8,16,0,0,2768,8,16,0,0,2784,8,16,0,0,2800,8,16,0,0,2816,8,16,0,0,2832,8,16,0,0,2848,8,16,0,0,2864,8,16,0,0,2880,8,16,0,0,2896,8,16,0,0,2912,8,16,0,0,2928,8,16,0,0,2944,8,16,0,0,2960,8,16,0,0,2976,8,16,0,0,2992,8,16,0,0,3008,8,16,0,0,3024,8,16,0,0,3040,8,16,0,0,3056,8,16,0,0,3072,8,16,0,0,3088,8,16,0,0,3104,8,16,0,0,3120,8,16,0,0,3136,8,16,0,0,3152,8,16,0,0,3168,8,16,0,0,3184,8,16,0,0,3200,8,16,0,0,3216,8,16,0,0,3232,8,16,0,0,3248,8,16,0,0,3264,8,16,0,0,3280,8,16,0,0,3296,8,16,0,0,3312,8,16,0,0,3328,8,16,0,0,3344,8,16,0,0,3360,8,16,0,0,3376,8,16,0,0,3392,8,16,0,0,3408,8,16,0,0,3424,8,16,0,0,3440,8,16,0,0,3456,8,16,0,0,3472,8,16,0,0,3488,8,16,0,0,3504,8,16,0,0,3520,8,16,0,0,3536,8,16,0,0,3552,8,16,0,0,3568,8,16,0,0,3584,8,16,0,0,3600,8,16,0,0,3616,8,16,0,0,3632,8,16,0,0,3648,8,16,0,0,3664,8,16,0,0,3680,8,16,0,0,3696,8,16,0,0,3712,8,16,0,0,3728,8,16,0,0,3744,8,16,0,0,3760,8,16,0,0,3776,8,16,0,0,3792,8,16,0,0,3808,8,16,0,0,3824,8,16,0,0,3840,8,16,0,0,3856,8,16,0,0,3872,8,16,0,0,3888,8,16,0,0,3904,8,16,0,0,3920,8,16,0,0,3936,8,16,0,0,3952,8,16,0,0,3968,8,16,0,0,3984,8,16,0,0,4000,8,16,0,0,4016,8,16,0,0,4032,8,16,0,0,4048,8,16,0,0,4064,8,16,0,0,4080,8,16,0,0,};
static rfbFontData default8x16Font = { default8x16FontData, default8x16FontMetaData };
+
+#endif
diff --git a/rfb/rfb.h b/rfb/rfb.h
index db89367..c20fde6 100644
--- a/rfb/rfb.h
+++ b/rfb/rfb.h
@@ -55,6 +55,7 @@ extern "C"
#ifdef WIN32
#undef SOCKET
+typedef UINT32 in_addr_t;
#include <winsock2.h>
#ifdef LIBVNCSERVER_HAVE_WS2TCPIP_H
#undef socklen_t
@@ -382,10 +383,8 @@ typedef struct _rfbScreenInfo
rfbDisplayFinishedHookPtr displayFinishedHook;
/** xvpHook is called to handle an xvp client message */
rfbXvpHookPtr xvpHook;
-#ifdef LIBVNCSERVER_WITH_WEBSOCKETS
char *sslkeyfile;
char *sslcertfile;
-#endif
int ipv6port; /**< The port to listen on when using IPv6. */
char* listen6Interface;
/* We have an additional IPv6 listen socket since there are systems that
@@ -699,11 +698,11 @@ typedef struct _rfbClientRec {
int turboQualityLevel; /* 1-100 scale */
#endif
#endif
-
-#ifdef LIBVNCSERVER_WITH_WEBSOCKETS
rfbSslCtx *sslctx;
wsCtx *wsctx;
char *wspath; /* Requests path component */
+#ifdef LIBVNCSERVER_HAVE_LIBPTHREAD
+ int pipe_notify_client_thread[2];
#endif
} rfbClientRec, *rfbClientPtr;
@@ -904,6 +903,8 @@ extern rfbBool rfbTightDisableGradient;
extern int rfbNumCodedRectsTight(rfbClientPtr cl, int x,int y,int w,int h);
extern rfbBool rfbSendRectEncodingTight(rfbClientPtr cl, int x,int y,int w,int h);
+extern rfbBool rfbSendTightHeader(rfbClientPtr cl, int x, int y, int w, int h);
+extern rfbBool rfbSendCompressedDataTight(rfbClientPtr cl, char *buf, int compressedLen);
#if defined(LIBVNCSERVER_HAVE_LIBPNG)
extern rfbBool rfbSendRectEncodingTightPng(rfbClientPtr cl, int x,int y,int w,int h);
diff --git a/rfb/rfbclient.h b/rfb/rfbclient.h
index 17ddba6..2eea004 100644
--- a/rfb/rfbclient.h
+++ b/rfb/rfbclient.h
@@ -7,6 +7,7 @@
*/
/*
+ * Copyright (C) 2017 D. R. Commander. All Rights Reserved.
* Copyright (C) 2000, 2001 Const Kaplinsky. All Rights Reserved.
* Copyright (C) 2000 Tridia Corporation. All Rights Reserved.
* Copyright (C) 1999 AT&T Laboratories Cambridge. All Rights Reserved.
@@ -35,14 +36,27 @@
#define WIN32_LEAN_AND_MEAN /* Prevent loading any Winsock 1.x headers from windows.h */
#endif
+#if defined(ANDROID) || defined(LIBVNCSERVER_HAVE_ANDROID)
+#include <arpa/inet.h>
+#include <sys/select.h>
+#endif
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#if LIBVNCSERVER_HAVE_SYS_TIME_H
#include <sys/time.h>
+#endif
+#if LIBVNCSERVER_HAVE_UNISTD_H
#include <unistd.h>
+#endif
#include <rfb/rfbproto.h>
#include <rfb/keysym.h>
+#ifdef LIBVNCSERVER_HAVE_SASL
+#include <sasl/sasl.h>
+#endif /* LIBVNCSERVER_HAVE_SASL */
+
#define rfbClientSwap16IfLE(s) \
(*(char *)&client->endianTest ? ((((s) & 0xff) << 8) | (((s) >> 8) & 0xff)) : (s))
@@ -127,6 +141,7 @@ typedef union _rfbCredential
char *x509CACrlFile;
char *x509ClientCertFile;
char *x509ClientKeyFile;
+ uint8_t x509CrlVerifyMode; /* Only required for OpenSSL - see meanings below */
} x509Credential;
/** Plain (VeNCrypt), MSLogon (UltraVNC) */
struct
@@ -139,6 +154,13 @@ typedef union _rfbCredential
#define rfbCredentialTypeX509 1
#define rfbCredentialTypeUser 2
+/* When using OpenSSL, CRLs can be included in both the x509CACrlFile and appended
+ to the x509CACertFile as is common with OpenSSL. When rfbX509CrlVerifyAll is
+ specified the CRL list must include CRLs for all certificates in the chain */
+#define rfbX509CrlVerifyNone 0 /* No CRL checking is performed */
+#define rfbX509CrlVerifyClient 1 /* Only the leaf server certificate is checked */
+#define rfbX509CrlVerifyAll 2 /* All certificates in the server chain are checked */
+
struct _rfbClient;
/**
@@ -184,9 +206,17 @@ 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 void (*GotFillRectProc)(struct _rfbClient* client, int x, int y, int w, int h, uint32_t colour);
+typedef void (*GotBitmapProc)(struct _rfbClient* client, const uint8_t* buffer, int x, int y, int w, int h);
+typedef rfbBool (*GotJpegProc)(struct _rfbClient* client, const uint8_t* buffer, int length, int x, int y, int w, int h);
typedef rfbBool (*LockWriteToTLSProc)(struct _rfbClient* client);
typedef rfbBool (*UnlockWriteToTLSProc)(struct _rfbClient* client);
+#ifdef LIBVNCSERVER_HAVE_SASL
+typedef char* (*GetUserProc)(struct _rfbClient* client);
+typedef char* (*GetSASLMechanismProc)(struct _rfbClient* client, char* mechlist);
+#endif /* LIBVNCSERVER_HAVE_SASL */
+
typedef struct _rfbClient {
uint8_t* frameBuffer;
int width, height;
@@ -268,7 +298,7 @@ typedef struct _rfbClient {
uint8_t tightPrevRow[2048*3*sizeof(uint16_t)];
#ifdef LIBVNCSERVER_HAVE_LIBJPEG
- /** JPEG decoder state. */
+ /** JPEG decoder state (obsolete-- do not use). */
rfbBool jpegError;
struct jpeg_source_mgr* jpegSrcManager;
@@ -371,6 +401,40 @@ typedef struct _rfbClient {
LockWriteToTLSProc LockWriteToTLS;
UnlockWriteToTLSProc UnlockWriteToTLS;
+ /** Hooks for custom rendering
+ *
+ * VNC rendering boils down to 3 activities:
+ * - GotCopyRect: copy an area of the framebuffer
+ * - GotFillRect: fill an area of the framebuffer with a solid color
+ * - GotBitmap: copy the bitmap in the buffer into the framebuffer
+ * The client application should either set all three of these or none!
+ */
+ GotFillRectProc GotFillRect;
+ GotBitmapProc GotBitmap;
+ /** Hook for custom JPEG decoding and rendering */
+ GotJpegProc GotJpeg;
+
+#ifdef LIBVNCSERVER_HAVE_SASL
+ sasl_conn_t *saslconn;
+ const char *saslDecoded;
+ unsigned int saslDecodedLength;
+ unsigned int saslDecodedOffset;
+ sasl_secret_t *saslSecret;
+
+ /* Callback to allow the client to choose a preferred mechanism. The string returned will
+ be freed once no longer required. */
+ GetSASLMechanismProc GetSASLMechanism;
+ GetUserProc GetUser;
+
+#endif /* LIBVNCSERVER_HAVE_SASL */
+
+#ifdef LIBVNCSERVER_HAVE_LIBZ
+#ifdef LIBVNCSERVER_HAVE_LIBJPEG
+ /** JPEG decoder state. */
+ void *tjhnd;
+
+#endif
+#endif
} rfbClient;
/* cursor.c */
@@ -560,6 +624,9 @@ typedef struct _rfbClientProtocolExtension {
rfbBool (*handleMessage)(rfbClient* cl,
rfbServerToClientMsg* message);
struct _rfbClientProtocolExtension* next;
+ uint32_t const* securityTypes;
+ /** returns TRUE if it handled the authentication */
+ rfbBool (*handleAuthentication)(rfbClient* cl, uint32_t authScheme);
} rfbClientProtocolExtension;
void rfbClientRegisterExtension(rfbClientProtocolExtension* e);
diff --git a/rfb/rfbconfig.h.cmake b/rfb/rfbconfig.h.cmakein
index 5bd6569..f5d8d78 100644
--- a/rfb/rfbconfig.h.cmake
+++ b/rfb/rfbconfig.h.cmakein
@@ -18,6 +18,48 @@
/* Define to 1 if you have the `gettimeofday' function. */
#cmakedefine LIBVNCSERVER_HAVE_GETTIMEOFDAY 1
+/* Define to 1 if you have the `ftime' function. */
+#cmakedefine LIBVNCSERVER_HAVE_FTIME 1
+
+/* Define to 1 if you have the `gethostbyname' function. */
+#cmakedefine LIBVNCSERVER_HAVE_GETHOSTBYNAME 1
+
+/* Define to 1 if you have the `gethostname' function. */
+#cmakedefine LIBVNCSERVER_HAVE_GETHOSTNAME 1
+
+/* Define to 1 if you have the `inet_ntoa' function. */
+#cmakedefine LIBVNCSERVER_HAVE_INET_NTOA 1
+
+/* Define to 1 if you have the `memmove' function. */
+#cmakedefine LIBVNCSERVER_HAVE_MEMMOVE 1
+
+/* Define to 1 if you have the `memset' function. */
+#cmakedefine LIBVNCSERVER_HAVE_MEMSET 1
+
+/* Define to 1 if you have the `mkfifo' function. */
+#cmakedefine LIBVNCSERVER_HAVE_MKFIFO 1
+
+/* Define to 1 if you have the `select' function. */
+#cmakedefine LIBVNCSERVER_HAVE_SELECT 1
+
+/* Define to 1 if you have the `socket' function. */
+#cmakedefine LIBVNCSERVER_HAVE_SOCKET 1
+
+/* Define to 1 if you have the `strchr' function. */
+#cmakedefine LIBVNCSERVER_HAVE_STRCHR 1
+
+/* Define to 1 if you have the `strcspn' function. */
+#cmakedefine LIBVNCSERVER_HAVE_STRCSPN 1
+
+/* Define to 1 if you have the `strdup' function. */
+#cmakedefine LIBVNCSERVER_HAVE_STRDUP 1
+
+/* Define to 1 if you have the `strerror' function. */
+#cmakedefine LIBVNCSERVER_HAVE_STRERROR 1
+
+/* Define to 1 if you have the `strstr' function. */
+#cmakedefine LIBVNCSERVER_HAVE_STRSTR 1
+
/* Define to 1 if you have the `jpeg' library (-ljpeg). */
#cmakedefine LIBVNCSERVER_HAVE_LIBJPEG 1
@@ -30,6 +72,9 @@
/* Define to 1 if you have the `z' library (-lz). */
#cmakedefine LIBVNCSERVER_HAVE_LIBZ 1
+/* Define to 1 if you have the `lzo2' library (-llzo2). */
+#cmakedefine LIBVNCSERVER_HAVE_LZO 1
+
/* Define to 1 if you have the <netinet/in.h> header file. */
#cmakedefine LIBVNCSERVER_HAVE_NETINET_IN_H 1
@@ -51,6 +96,9 @@
/* Define to 1 if you have <sys/wait.h> that is POSIX.1 compatible. */
#cmakedefine LIBVNCSERVER_HAVE_SYS_WAIT_H 1
+/* Define to 1 if you have <sys/uio.h> */
+#cmakedefine LIBVNCSERVER_HAVE_SYS_UIO_H 1
+
/* Define to 1 if you have the <unistd.h> header file. */
#cmakedefine LIBVNCSERVER_HAVE_UNISTD_H 1
@@ -69,6 +117,12 @@
/* Define to 1 if `vfork' works. */
#cmakedefine LIBVNCSERVER_HAVE_WORKING_VFORK 1
+/* Define to 1 if `mmap' exists. */
+#cmakedefine LIBVNCSERVER_HAVE_MMAP 1
+
+/* Define to 1 if `fork' exists. */
+#cmakedefine LIBVNCSERVER_HAVE_FORK 1
+
/* Define to 1 if you have the <ws2tcpip.h> header file. */
#cmakedefine LIBVNCSERVER_HAVE_WS2TCPIP_H 1
@@ -92,7 +146,13 @@
#cmakedefine LIBVNCSERVER_WITH_CLIENT_GCRYPT 1
/* Define to 1 if GnuTLS is present */
-#cmakedefine LIBVNCSERVER_WITH_CLIENT_TLS 1
+#cmakedefine LIBVNCSERVER_HAVE_GNUTLS 1
+
+/* Define to 1 if OpenSSL is present */
+#cmakedefine LIBVNCSERVER_HAVE_LIBSSL 1
+
+/* Define to 1 if Cyrus SASL is present */
+#cmakedefine LIBVNCSERVER_HAVE_SASL 1
/* Define to 1 to build with websockets */
#cmakedefine LIBVNCSERVER_WITH_WEBSOCKETS 1
diff --git a/rfb/rfbint.h.cmake b/rfb/rfbint.h.cmake
deleted file mode 100644
index 17de6cd..0000000
--- a/rfb/rfbint.h.cmake
+++ /dev/null
@@ -1,4 +0,0 @@
-#ifndef _RFB_RFBINT_H
-#define _RFB_RFBINT_H 1
-/* empty ... */
-#endif
diff --git a/rfb/rfbproto.h b/rfb/rfbproto.h
index 6c1a2fb..8f7c2f9 100644
--- a/rfb/rfbproto.h
+++ b/rfb/rfbproto.h
@@ -65,14 +65,11 @@
#if defined(WIN32) && !defined(__MINGW32__)
#define LIBVNCSERVER_WORDS_BIGENDIAN
-#define rfbBool int
+typedef int8_t rfbBool;
#include <sys/timeb.h>
#include <winsock2.h>
-#undef SOCKET
-#define SOCKET int
-#else
-#include <rfb/rfbconfig.h>
#endif
+#include <rfb/rfbconfig.h>
#ifdef LIBVNCSERVER_HAVE_LIBZ
#include <zlib.h>
@@ -298,6 +295,7 @@ typedef char rfbProtocolVersionMsg[13]; /* allow extra byte for null */
#define rfbUltra 17
#define rfbTLS 18
#define rfbVeNCrypt 19
+#define rfbSASL 20
#define rfbARD 30
#define rfbMSLogon 0xfffffffa
@@ -449,6 +447,7 @@ typedef struct {
#define rfbEncodingTightPng 0xFFFFFEFC /* -260 */
#define rfbEncodingZlibHex 8
#define rfbEncodingUltra 9
+#define rfbEncodingTRLE 15
#define rfbEncodingZRLE 16
#define rfbEncodingZYWRLE 17
diff --git a/test/Makefile.am b/test/Makefile.am
deleted file mode 100644
index f07fc82..0000000
--- a/test/Makefile.am
+++ /dev/null
@@ -1,28 +0,0 @@
-check_PROGRAMS =
-
-if HAVE_LIBJPEG
-# TurboJPEG wrapper tests
-check_PROGRAMS += tjunittest tjbench
-tjunittest_SOURCES=tjunittest.c ../common/turbojpeg.c ../common/turbojpeg.h \
- tjutil.c tjutil.h
-tjbench_SOURCES=tjbench.c ../common/turbojpeg.c ../common/turbojpeg.h \
- tjutil.c tjutil.h bmp.c bmp.h
-tjbench_LDADD=$(LDADD) -lm
-endif
-
-AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/common
-LDADD = ../libvncserver/libvncserver.la ../libvncclient/libvncclient.la @WSOCKLIB@
-
-if HAVE_LIBPTHREAD
-BACKGROUND_TEST=blooptest
-ENCODINGS_TEST=encodingstest
-endif
-
-copyrecttest_LDADD=$(LDADD) -lm
-
-check_PROGRAMS += $(ENCODINGS_TEST) cargstest copyrecttest $(BACKGROUND_TEST) \
- cursortest
-
-test: encodingstest$(EXEEXT) cargstest$(EXEEXT) copyrecttest$(EXEEXT)
- ./encodingstest && ./cargstest
-
diff --git a/test/copyrecttest.c b/test/copyrecttest.c
index 3564c0e..d53c32d 100644
--- a/test/copyrecttest.c
+++ b/test/copyrecttest.c
@@ -1,4 +1,5 @@
#include <rfb/rfb.h>
+#define _USE_MATH_DEFINES
#include <math.h>
static void initBackground(rfbScreenInfoPtr server)
diff --git a/test/tjbench.c b/test/tjbench.c
index 29aa153..87e1591 100644
--- a/test/tjbench.c
+++ b/test/tjbench.c
@@ -178,7 +178,8 @@ int decomptest(unsigned char *srcbuf, unsigned char **jpegbuf,
int y=(int)((double)srcbuf[rindex]*0.299
+ (double)srcbuf[gindex]*0.587
+ (double)srcbuf[bindex]*0.114 + 0.5);
- if(y>255) y=255; if(y<0) y=0;
+ if(y>255) y=255;
+ if(y<0) y=0;
dstbuf[rindex]=abs(dstbuf[rindex]-y);
dstbuf[gindex]=abs(dstbuf[gindex]-y);
dstbuf[bindex]=abs(dstbuf[bindex]-y);
@@ -226,7 +227,8 @@ void dotest(unsigned char *srcbuf, int w, int h, int subsamp, int jpegqual,
for(tilew=dotile? 8:w, tileh=dotile? 8:h; ; tilew*=2, tileh*=2)
{
- if(tilew>w) tilew=w; if(tileh>h) tileh=h;
+ if(tilew>w) tilew=w;
+ if(tileh>h) tileh=h;
ntilesw=(w+tilew-1)/tilew; ntilesh=(h+tileh-1)/tileh;
if((jpegbuf=(unsigned char **)malloc(sizeof(unsigned char *)
@@ -323,7 +325,7 @@ void dotest(unsigned char *srcbuf, int w, int h, int subsamp, int jpegqual,
for(i=0; i<ntilesw*ntilesh; i++)
{
- if(jpegbuf[i]) free(jpegbuf[i]); jpegbuf[i]=NULL;
+ if(jpegbuf[i]) {free(jpegbuf[i]); jpegbuf[i]=NULL;}
}
free(jpegbuf); jpegbuf=NULL;
free(jpegsize); jpegsize=NULL;
@@ -337,7 +339,7 @@ void dotest(unsigned char *srcbuf, int w, int h, int subsamp, int jpegqual,
{
for(i=0; i<ntilesw*ntilesh; i++)
{
- if(jpegbuf[i]) free(jpegbuf[i]); jpegbuf[i]=NULL;
+ if(jpegbuf[i]) {free(jpegbuf[i]); jpegbuf[i]=NULL;}
}
free(jpegbuf); jpegbuf=NULL;
}
@@ -392,7 +394,8 @@ void dodecomptest(char *filename)
for(tilew=dotile? 16:w, tileh=dotile? 16:h; ; tilew*=2, tileh*=2)
{
- if(tilew>w) tilew=w; if(tileh>h) tileh=h;
+ if(tilew>w) tilew=w;
+ if(tileh>h) tileh=h;
ntilesw=(w+tilew-1)/tilew; ntilesh=(h+tileh-1)/tileh;
if((jpegbuf=(unsigned char **)malloc(sizeof(unsigned char *)
@@ -455,7 +458,7 @@ void dodecomptest(char *filename)
{
for(i=0; i<ntilesw*ntilesh; i++)
{
- if(jpegbuf[i]) free(jpegbuf[i]); jpegbuf[i]=NULL;
+ if(jpegbuf[i]) {free(jpegbuf[i]); jpegbuf[i]=NULL;}
}
free(jpegbuf); jpegbuf=NULL;
}
diff --git a/test/wsmaketestframe.py b/test/wsmaketestframe.py
new file mode 100755
index 0000000..fc03e39
--- /dev/null
+++ b/test/wsmaketestframe.py
@@ -0,0 +1,131 @@
+#!/usr/bin/env python3
+# Copyright (C)2017 Andreas Weigel. All Rights Reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are met:
+#
+# - Redistributions of source code must retain the above copyright notice,
+# this list of conditions and the following disclaimer.
+# - Redistributions in binary form must reproduce the above copyright notice,
+# this list of conditions and the following disclaimer in the documentation
+# and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS",
+# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
+# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+
+import websockets
+import base64
+
+'''
+ Create websocket frames for the wstest websocket decoding unit test.
+
+ Generates c ws_frame_test structure definitions
+ included by wstest.c.
+'''
+
+
+def add_field(s, name, value, first=False):
+ deli = ",\n\t\t"
+ if first:
+ deli = "\t\t"
+ s += "{2}.{0}={1}".format(name, value, deli)
+ return s
+
+
+class Testframe():
+ def __init__(self, frame, descr, modify_bytes={}, experrno=0, mask=True, opcode_overwrite=False):
+ self.frame = frame
+ self.descr = descr
+ self.modify_bytes = modify_bytes
+ self.experrno = experrno
+ self.b64 = True if frame.opcode == 1 or opcode_overwrite == 1 else False
+ self.mask = mask
+
+ def to_carray_initializer(self, buf):
+ values = []
+ for i in range(len(buf)):
+ values.append("0X{0:02X}".format(buf[i]))
+
+ if self.modify_bytes != {}:
+ for k in self.modify_bytes:
+ values[k] = "0X{0:02X}".format(self.modify_bytes[k])
+
+ return "{{{0}}}".format(",".join(values))
+
+
+ def set_frame_buf(self, buf):
+ self.frame_carray = self.to_carray_initializer(buf)
+ self.framelen = len(buf)
+
+ def __str__(self):
+ print("processing frame: {0}".format(self.descr))
+ the_frame = self.frame
+ if self.b64:
+ olddata = self.frame.data
+ newdata = base64.b64encode(self.frame.data)
+ #print("converting\n{0}\nto{1}\n".format(olddata, newdata))
+ the_frame = websockets.framing.Frame(self.frame.fin, self.frame.opcode, base64.b64encode(olddata))
+ websockets.framing.write_frame(the_frame, self.set_frame_buf, self.mask)
+ s = "\t{\n"
+ s = add_field(s, "frame", "{0}".format(self.frame_carray), True)
+ s = add_field(s, "expectedDecodeBuf", self.to_carray_initializer(self.frame.data))
+ s = add_field(s, "frame_len", self.framelen)
+ s = add_field(s, "raw_payload_len", len(self.frame.data))
+ s = add_field(s, "expected_errno", self.experrno)
+ s = add_field(s, "descr", "\"{0}\"".format(self.descr))
+ s = add_field(s, "i", "0")
+ s = add_field(s, "simulate_sock_malfunction_at", "0")
+ s = add_field(s, "errno_val", "0")
+ s = add_field(s, "close_sock_at", "0")
+ s += "\n\t}"
+ return s
+
+### create test frames
+flist = []
+### standard text frames with different lengths
+flist.append(Testframe(websockets.framing.Frame(1, 1, bytearray("Testit", encoding="utf-8")), "Short valid text frame"))
+flist.append(Testframe(websockets.framing.Frame(1, 1, bytearray("Frame2 does contain much more text and even goes beyond the 126 byte len field. Frame2 does contain much more text and even goes beyond the 126 byte len field.", encoding="utf-8")),
+ "Mid-long valid text frame"))
+#flist.append(Testframe(websockets.framing.Frame(1, 1, bytearray([(x % 26) + 65 for x in range(100000)])), "100k text frame (ABC..YZABC..)"))
+
+### standard binary frames with different lengths
+flist.append(Testframe(websockets.framing.Frame(1, 2, bytearray("Testit", encoding="utf-8")), "Short valid binary frame"))
+flist.append(Testframe(websockets.framing.Frame(1, 2, bytearray("Frame2 does contain much more text and even goes beyond the 126 byte len field. Frame2 does contain much more text and even goes beyond the 126 byte len field.", encoding="utf-8")),
+ "Mid-long valid binary frame"))
+#flist.append(Testframe(websockets.framing.Frame(1, 2, bytearray([(x % 26) + 65 for x in range(100000)])), "100k binary frame (ABC..YZABC..)"))
+
+### some conn reset frames, one with no close message, one with close message
+flist.append(Testframe(websockets.framing.Frame(1, 8, bytearray(list([0x03, 0xEB]))), "Close frame (Reason 1003)", experrno="ECONNRESET"))
+flist.append(Testframe(websockets.framing.Frame(1, 8, bytearray(list([0x03, 0xEB])) + bytearray("I'm a close reason and much more than that!", encoding="utf-8")), "Close frame (Reason 1003) and msg", experrno="ECONNRESET"))
+
+### invalid header values
+flist.append(Testframe(websockets.framing.Frame(1, 1, bytearray("Testit", encoding="utf-8")), "Invalid frame: Wrong masking", experrno="EPROTO", mask=False))
+flist.append(Testframe(websockets.framing.Frame(1, 1, bytearray("..Lore Ipsum", encoding="utf-8")), "Invalid frame: Length of < 126 with add. 16 bit len field", experrno="EPROTO", modify_bytes={ 1: 0xFE, 2: 0x00, 3: 0x0F}))
+flist.append(Testframe(websockets.framing.Frame(1, 1, bytearray("........Lore Ipsum", encoding="utf-8")), "Invalid frame: Length of < 126 with add. 64 bit len field", experrno="EPROTO", modify_bytes={ 1: 0xFF, 2: 0x00, 3: 0x00, 4: 0x00, 5: 0x00, 6: 0x00, 7: 0x00, 8: 0x80, 9: 0x40}))
+
+frag1 = websockets.framing.Frame(0, 1, bytearray("This is a fragmented websocket...", encoding="utf-8"))
+frag2 = websockets.framing.Frame(0, 0, bytearray("... and it goes on...", encoding="utf-8"))
+frag3 = websockets.framing.Frame(1, 0, bytearray("and on and stop", encoding="utf-8"))
+flist.append(Testframe(frag1, "Continuation test frag1"))
+flist.append(Testframe(frag2, "Continuation test frag2", opcode_overwrite=1))
+flist.append(Testframe(frag3, "Continuation test frag3", opcode_overwrite=1))
+
+s = "struct ws_frame_test tests[] = {\n"
+for i in range(len(flist)):
+ s += flist[i].__str__()
+ if (i + 1 < len(flist)):
+ s += ","
+ s += "\n"
+s += "};\n"
+
+with open("wstestdata.inc", "w") as cdatafile:
+ cdatafile.write(s)
diff --git a/test/wstest.c b/test/wstest.c
new file mode 100644
index 0000000..042b75b
--- /dev/null
+++ b/test/wstest.c
@@ -0,0 +1,206 @@
+/*
+ * Copyright (C)2017 Andreas Weigel. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS",
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _WIN32
+
+#include <ws_decode.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdarg.h>
+#include <unistd.h>
+#include <errno.h>
+
+/* incoming data frames should not be larger than that */
+#define TEST_BUF_SIZE B64LEN(131072) + WSHLENMAX
+
+/* seed is fixed deliberately to get reproducible test cases */
+#define RND_SEED 100
+
+enum {
+ OK,
+ FAIL_DATA,
+ FAIL_ERRNO,
+ FAIL_CLOSED,
+};
+
+const char *result_descr[] = {
+ "",
+ "Data buffers do not match",
+ "Wrong errno",
+ "Wrongly reported closed socket",
+ "Internal test error"
+};
+
+struct ws_frame_test {
+ char frame[TEST_BUF_SIZE];
+ char *pos;
+ char expectedDecodeBuf[TEST_BUF_SIZE];
+ uint64_t n_compare;
+ uint64_t frame_len;
+ uint64_t raw_payload_len;
+ int expected_errno;
+ const char *descr;
+ int ret_bytes[16];
+ int ret_bytes_len;
+ int i;
+ int simulate_sock_malfunction_at;
+ int errno_val;
+ int close_sock_at;
+};
+
+#include "wstestdata.inc"
+
+char el_log[1000000];
+char *el_pos;
+
+static void logtest(const char *fmt, ...)
+{
+ va_list args;
+ va_start(args, fmt);
+ size_t left = el_log + sizeof(el_log) - el_pos;
+ size_t off = vsnprintf(el_pos, left, fmt, args);
+ el_pos += off;
+ va_end(args);
+}
+
+static int emu_read(void *ctx, char *dst, size_t len);
+
+static int emu_read(void *ctx, char *dst, size_t len)
+{
+ struct ws_frame_test *ft = (struct ws_frame_test *)ctx;
+ ssize_t nret;
+ int r;
+ ssize_t modu;
+
+ rfbLog("emu_read called with dst=%p and len=%lu\n", dst, len);
+ if (ft->simulate_sock_malfunction_at > 0 && ft->simulate_sock_malfunction_at == ft->i) {
+ rfbLog("simulating IO error with errno=%d\n", ft->errno_val);
+ errno = ft->errno_val;
+ return -1;
+ }
+
+ /* return something */
+ r = rand();
+ modu = (ft->frame + ft->frame_len) - ft->pos;
+ rfbLog("r=%d modu=%ld frame=%p pos=%p\n", r, modu, ft->frame, ft->pos);
+ nret = (r % modu) + 1;
+ nret = nret > len ? len : nret;
+
+ rfbLog("copy and return %ld bytes\n", nret);
+ memcpy(dst, ft->pos, nret);
+ ft->pos += nret;
+ rfbLog("leaving %s; pos=%p framebuf=%p nret=%ld\n", __func__, ft->pos, ft->frame, nret);
+ return nret;
+}
+
+static uint64_t run_test(struct ws_frame_test *ft, ws_ctx_t *ctx)
+{
+ uint64_t nleft = ft->raw_payload_len;
+ char dstbuf[ft->raw_payload_len];
+ char *dst = dstbuf;
+ ssize_t n;
+
+ ft->pos = ft->frame;
+
+ ctx->ctxInfo.ctxPtr = (void *)ft;
+
+ while (nleft > 0) {
+ rfbLog("calling ws_decode with dst=%p, len=%lu\n", dst, nleft);
+ n = ctx->decode(ctx, dst, nleft);
+ rfbLog("read n=%ld\n", n);
+ if (n == 0) {
+ if (ft->close_sock_at > 0) {
+ return OK;
+ } else {
+ return FAIL_CLOSED;
+ }
+ } else if (n < 0) {
+ if (errno == EAGAIN || errno == EWOULDBLOCK) {
+ /* ok, just call again */
+ } else {
+ if (ft->expected_errno == errno) {
+ rfbLog("errno=%d as expected\n", errno);
+ return OK;
+ } else {
+ rfbLog("errno=%d != expected(%d)\n", errno, ft->expected_errno);
+ return FAIL_ERRNO;
+ }
+ }
+ } else {
+ nleft -= n;
+ dst += n;
+ rfbLog("read n=%ld from decode; dst=%p, nleft=%lu\n", n, dst, nleft);
+ }
+ }
+
+ if (memcmp(ft->expectedDecodeBuf, dstbuf, ft->raw_payload_len) != 0) {
+ ft->expectedDecodeBuf[ft->raw_payload_len] = '\0';
+ dstbuf[ft->raw_payload_len] = '\0';
+ rfbLog("decoded result not equal:\nexpected:\n%s\ngot\n%s\n\n", ft->expectedDecodeBuf, dstbuf);
+ return FAIL_DATA;
+ }
+
+ return OK;
+}
+
+
+int main()
+{
+ ws_ctx_t ctx;
+ int retall= 0;
+ int i;
+ srand(RND_SEED);
+
+ hybiDecodeCleanupComplete(&ctx);
+ ctx.decode = webSocketsDecodeHybi;
+ ctx.ctxInfo.readFunc = emu_read;
+ rfbLog = logtest;
+ rfbErr = logtest;
+
+ for (i = 0; i < ARRAYSIZE(tests); i++) {
+ int ret;
+
+ /* reset output log buffer to begin */
+ el_pos = el_log;
+
+ ret = run_test(&tests[i], &ctx);
+ printf("%s: \"%s\"\n", ret == 0 ? "PASS" : "FAIL", tests[i].descr);
+ if (ret != 0) {
+ *el_pos = '\0';
+ printf("%s", el_log);
+ retall = -1;
+ }
+ }
+ return retall;
+}
+
+#else
+
+int main() {
+ return 0;
+}
+
+#endif
diff --git a/test/wstestdata.inc b/test/wstestdata.inc
new file mode 100644
index 0000000..595b891
--- /dev/null
+++ b/test/wstestdata.inc
@@ -0,0 +1,146 @@
+struct ws_frame_test tests[] = {
+ {
+ .frame={0X81,0X88,0X2F,0X2A,0X17,0X41,0X79,0X6D,0X41,0X3B,0X4B,0X6D,0X7B,0X71},
+ .expectedDecodeBuf={0X54,0X65,0X73,0X74,0X69,0X74},
+ .frame_len=14,
+ .raw_payload_len=6,
+ .expected_errno=0,
+ .descr="Short valid text frame",
+ .i=0,
+ .simulate_sock_malfunction_at=0,
+ .errno_val=0,
+ .close_sock_at=0
+ },
+ {
+ .frame={0X81,0XFE,0X00,0XD4,0X66,0X27,0XE5,0X24,0X34,0X49,0XAF,0X4C,0X04,0X70,0XB0,0X5D,0X2F,0X60,0XB7,0X52,0X3C,0X7F,0XA8,0X43,0X3F,0X15,0XDC,0X51,0X02,0X60,0XA3,0X54,0X04,0X4E,0XA7,0X50,0X02,0X70,0XAB,0X4B,0X2F,0X60,0XD4,0X52,0X05,0X4A,0XB0,0X43,0X02,0X60,0XB3,0X10,0X02,0X64,0XA7,0X4C,0X04,0X4A,0XB4,0X43,0X3C,0X7F,0XBF,0X48,0X04,0X4E,0XA7,0X4A,0X04,0X15,0XB3,0X5E,0X2F,0X60,0XAF,0X48,0X03,0X70,0XDC,0X51,0X3C,0X64,0XA7,0X14,0X07,0X60,0XB0,0X43,0X2B,0X73,0XAC,0X16,0X2F,0X60,0XAF,0X11,0X02,0X60,0XB0,0X43,0X04,0X60,0XB3,0X51,0X2F,0X60,0XBF,0X54,0X3C,0X70,0X9D,0X4F,0X2A,0X4E,0XA7,0X63,0X05,0X4A,0XA3,0X50,0X3C,0X73,0XAC,0X43,0X3C,0X60,0XDC,0X48,0X05,0X5E,0XA7,0X4E,0X04,0X15,0XD0,0X14,0X3F,0X70,0X89,0X51,0X2F,0X60,0XD4,0X15,0X3F,0X15,0X82,0X43,0X04,0X70,0XDC,0X5D,0X3C,0X74,0XA7,0X14,0X3C,0X7F,0X8D,0X14,0X2F,0X60,0XA3,0X51,0X3C,0X64,0XA7,0X48,0X02,0X4A,0XB3,0X51,0X2F,0X60,0X81,0X52,0X3C,0X7F,0XA8,0X43,0X3F,0X4A,0XB3,0X11,0X04,0X15,0XD0,0X4F,0X2F,0X6F,0XB7,0X4B,0X3C,0X74,0XA4,0X5C,0X2B,0X4D,0XBC,0X43,0X3F,0X49,0X89,0X14,0X3C,0X74,0XA7,0X57,0X3C,0X70,0XD1,0X43,0X3C,0X4A,0X89,0X48,0X04,0X60,0XB4,0X51},
+ .expectedDecodeBuf={0X46,0X72,0X61,0X6D,0X65,0X32,0X20,0X64,0X6F,0X65,0X73,0X20,0X63,0X6F,0X6E,0X74,0X61,0X69,0X6E,0X20,0X6D,0X75,0X63,0X68,0X20,0X6D,0X6F,0X72,0X65,0X20,0X74,0X65,0X78,0X74,0X20,0X61,0X6E,0X64,0X20,0X65,0X76,0X65,0X6E,0X20,0X67,0X6F,0X65,0X73,0X20,0X62,0X65,0X79,0X6F,0X6E,0X64,0X20,0X74,0X68,0X65,0X20,0X31,0X32,0X36,0X20,0X62,0X79,0X74,0X65,0X20,0X6C,0X65,0X6E,0X20,0X66,0X69,0X65,0X6C,0X64,0X2E,0X20,0X46,0X72,0X61,0X6D,0X65,0X32,0X20,0X64,0X6F,0X65,0X73,0X20,0X63,0X6F,0X6E,0X74,0X61,0X69,0X6E,0X20,0X6D,0X75,0X63,0X68,0X20,0X6D,0X6F,0X72,0X65,0X20,0X74,0X65,0X78,0X74,0X20,0X61,0X6E,0X64,0X20,0X65,0X76,0X65,0X6E,0X20,0X67,0X6F,0X65,0X73,0X20,0X62,0X65,0X79,0X6F,0X6E,0X64,0X20,0X74,0X68,0X65,0X20,0X31,0X32,0X36,0X20,0X62,0X79,0X74,0X65,0X20,0X6C,0X65,0X6E,0X20,0X66,0X69,0X65,0X6C,0X64,0X2E},
+ .frame_len=220,
+ .raw_payload_len=159,
+ .expected_errno=0,
+ .descr="Mid-long valid text frame",
+ .i=0,
+ .simulate_sock_malfunction_at=0,
+ .errno_val=0,
+ .close_sock_at=0
+ },
+ {
+ .frame={0X82,0X86,0XDD,0X9B,0XD8,0X56,0X89,0XFE,0XAB,0X22,0XB4,0XEF},
+ .expectedDecodeBuf={0X54,0X65,0X73,0X74,0X69,0X74},
+ .frame_len=12,
+ .raw_payload_len=6,
+ .expected_errno=0,
+ .descr="Short valid binary frame",
+ .i=0,
+ .simulate_sock_malfunction_at=0,
+ .errno_val=0,
+ .close_sock_at=0
+ },
+ {
+ .frame={0X82,0XFE,0X00,0X9F,0XB5,0X6E,0X7F,0X4C,0XF3,0X1C,0X1E,0X21,0XD0,0X5C,0X5F,0X28,0XDA,0X0B,0X0C,0X6C,0XD6,0X01,0X11,0X38,0XD4,0X07,0X11,0X6C,0XD8,0X1B,0X1C,0X24,0X95,0X03,0X10,0X3E,0XD0,0X4E,0X0B,0X29,0XCD,0X1A,0X5F,0X2D,0XDB,0X0A,0X5F,0X29,0XC3,0X0B,0X11,0X6C,0XD2,0X01,0X1A,0X3F,0X95,0X0C,0X1A,0X35,0XDA,0X00,0X1B,0X6C,0XC1,0X06,0X1A,0X6C,0X84,0X5C,0X49,0X6C,0XD7,0X17,0X0B,0X29,0X95,0X02,0X1A,0X22,0X95,0X08,0X16,0X29,0XD9,0X0A,0X51,0X6C,0XF3,0X1C,0X1E,0X21,0XD0,0X5C,0X5F,0X28,0XDA,0X0B,0X0C,0X6C,0XD6,0X01,0X11,0X38,0XD4,0X07,0X11,0X6C,0XD8,0X1B,0X1C,0X24,0X95,0X03,0X10,0X3E,0XD0,0X4E,0X0B,0X29,0XCD,0X1A,0X5F,0X2D,0XDB,0X0A,0X5F,0X29,0XC3,0X0B,0X11,0X6C,0XD2,0X01,0X1A,0X3F,0X95,0X0C,0X1A,0X35,0XDA,0X00,0X1B,0X6C,0XC1,0X06,0X1A,0X6C,0X84,0X5C,0X49,0X6C,0XD7,0X17,0X0B,0X29,0X95,0X02,0X1A,0X22,0X95,0X08,0X16,0X29,0XD9,0X0A,0X51},
+ .expectedDecodeBuf={0X46,0X72,0X61,0X6D,0X65,0X32,0X20,0X64,0X6F,0X65,0X73,0X20,0X63,0X6F,0X6E,0X74,0X61,0X69,0X6E,0X20,0X6D,0X75,0X63,0X68,0X20,0X6D,0X6F,0X72,0X65,0X20,0X74,0X65,0X78,0X74,0X20,0X61,0X6E,0X64,0X20,0X65,0X76,0X65,0X6E,0X20,0X67,0X6F,0X65,0X73,0X20,0X62,0X65,0X79,0X6F,0X6E,0X64,0X20,0X74,0X68,0X65,0X20,0X31,0X32,0X36,0X20,0X62,0X79,0X74,0X65,0X20,0X6C,0X65,0X6E,0X20,0X66,0X69,0X65,0X6C,0X64,0X2E,0X20,0X46,0X72,0X61,0X6D,0X65,0X32,0X20,0X64,0X6F,0X65,0X73,0X20,0X63,0X6F,0X6E,0X74,0X61,0X69,0X6E,0X20,0X6D,0X75,0X63,0X68,0X20,0X6D,0X6F,0X72,0X65,0X20,0X74,0X65,0X78,0X74,0X20,0X61,0X6E,0X64,0X20,0X65,0X76,0X65,0X6E,0X20,0X67,0X6F,0X65,0X73,0X20,0X62,0X65,0X79,0X6F,0X6E,0X64,0X20,0X74,0X68,0X65,0X20,0X31,0X32,0X36,0X20,0X62,0X79,0X74,0X65,0X20,0X6C,0X65,0X6E,0X20,0X66,0X69,0X65,0X6C,0X64,0X2E},
+ .frame_len=167,
+ .raw_payload_len=159,
+ .expected_errno=0,
+ .descr="Mid-long valid binary frame",
+ .i=0,
+ .simulate_sock_malfunction_at=0,
+ .errno_val=0,
+ .close_sock_at=0
+ },
+ {
+ .frame={0X88,0X82,0X6B,0X33,0X77,0X94,0X68,0XD8},
+ .expectedDecodeBuf={0X03,0XEB},
+ .frame_len=8,
+ .raw_payload_len=2,
+ .expected_errno=ECONNRESET,
+ .descr="Close frame (Reason 1003)",
+ .i=0,
+ .simulate_sock_malfunction_at=0,
+ .errno_val=0,
+ .close_sock_at=0
+ },
+ {
+ .frame={0X88,0XAD,0X4B,0XA1,0XCE,0XE8,0X48,0X4A,0X87,0XCF,0X26,0X81,0XAF,0XC8,0X28,0XCD,0XA1,0X9B,0X2E,0X81,0XBC,0X8D,0X2A,0XD2,0XA1,0X86,0X6B,0XC0,0XA0,0X8C,0X6B,0XCC,0XBB,0X8B,0X23,0X81,0XA3,0X87,0X39,0XC4,0XEE,0X9C,0X23,0XC0,0XA0,0XC8,0X3F,0XC9,0XAF,0X9C,0X6A},
+ .expectedDecodeBuf={0X03,0XEB,0X49,0X27,0X6D,0X20,0X61,0X20,0X63,0X6C,0X6F,0X73,0X65,0X20,0X72,0X65,0X61,0X73,0X6F,0X6E,0X20,0X61,0X6E,0X64,0X20,0X6D,0X75,0X63,0X68,0X20,0X6D,0X6F,0X72,0X65,0X20,0X74,0X68,0X61,0X6E,0X20,0X74,0X68,0X61,0X74,0X21},
+ .frame_len=51,
+ .raw_payload_len=45,
+ .expected_errno=ECONNRESET,
+ .descr="Close frame (Reason 1003) and msg",
+ .i=0,
+ .simulate_sock_malfunction_at=0,
+ .errno_val=0,
+ .close_sock_at=0
+ },
+ {
+ .frame={0X81,0X08,0X56,0X47,0X56,0X7A,0X64,0X47,0X6C,0X30},
+ .expectedDecodeBuf={0X54,0X65,0X73,0X74,0X69,0X74},
+ .frame_len=10,
+ .raw_payload_len=6,
+ .expected_errno=EPROTO,
+ .descr="Invalid frame: Wrong masking",
+ .i=0,
+ .simulate_sock_malfunction_at=0,
+ .errno_val=0,
+ .close_sock_at=0
+ },
+ {
+ .frame={0X81,0XFE,0X00,0X0F,0X71,0XE9,0X29,0X79,0X44,0XA4,0X07,0X23,0X3B,0X85,0X2C,0X55,0X1D,0X9E,0X06,0X23,0X27,0X9D},
+ .expectedDecodeBuf={0X2E,0XFE,0X00,0X0F,0X72,0X65,0X20,0X49,0X70,0X73,0X75,0X6D},
+ .frame_len=22,
+ .raw_payload_len=12,
+ .expected_errno=EPROTO,
+ .descr="Invalid frame: Length of < 126 with add. 16 bit len field",
+ .i=0,
+ .simulate_sock_malfunction_at=0,
+ .errno_val=0,
+ .close_sock_at=0
+ },
+ {
+ .frame={0X81,0XFF,0X00,0X00,0X00,0X00,0X00,0X00,0X80,0X40,0X2F,0X40,0XF3,0X5B,0X2F,0X40,0XF2,0X63,0X01,0X1A,0X8D,0X42,0X2A,0X6C,0XAB,0X59,0X00,0X1A,0X91,0X5A},
+ .expectedDecodeBuf={0X2E,0XFF,0X00,0X00,0X00,0X00,0X00,0X00,0X80,0X40,0X72,0X65,0X20,0X49,0X70,0X73,0X75,0X6D},
+ .frame_len=30,
+ .raw_payload_len=18,
+ .expected_errno=EPROTO,
+ .descr="Invalid frame: Length of < 126 with add. 64 bit len field",
+ .i=0,
+ .simulate_sock_malfunction_at=0,
+ .errno_val=0,
+ .close_sock_at=0
+ },
+ {
+ .frame={0X01,0XAC,0XC9,0X6E,0XC7,0X6E,0X9F,0X29,0XAF,0X1E,0XAA,0X17,0X85,0X1E,0XAA,0X17,0X85,0X06,0X80,0X29,0X9D,0X17,0X90,0X39,0XA3,0X1A,0X93,0X39,0XF2,0X5E,0X93,0X39,0X96,0X09,0XAD,0X5C,0X91,0X07,0XAA,0X5C,0XFE,0X04,0XA8,0X5C,0X91,0X5E,0X85,0X07,0XF3,0X1B},
+ .expectedDecodeBuf={0X54,0X68,0X69,0X73,0X20,0X69,0X73,0X20,0X61,0X20,0X66,0X72,0X61,0X67,0X6D,0X65,0X6E,0X74,0X65,0X64,0X20,0X77,0X65,0X62,0X73,0X6F,0X63,0X6B,0X65,0X74,0X2E,0X2E,0X2E},
+ .frame_len=50,
+ .raw_payload_len=33,
+ .expected_errno=0,
+ .descr="Continuation test frag1",
+ .i=0,
+ .simulate_sock_malfunction_at=0,
+ .errno_val=0,
+ .close_sock_at=0
+ },
+ {
+ .frame={0X00,0X9C,0X52,0XBC,0XD5,0X99,0X1E,0XD5,0XE1,0XEC,0X1B,0XFB,0X93,0XEC,0X08,0XFF,0X97,0XE9,0X36,0XFF,0X97,0XF7,0X30,0X8E,0X83,0XE3,0X1B,0XFB,0XEC,0XEC,0X1E,0XD5,0XE1,0XEC},
+ .expectedDecodeBuf={0X2E,0X2E,0X2E,0X20,0X61,0X6E,0X64,0X20,0X69,0X74,0X20,0X67,0X6F,0X65,0X73,0X20,0X6F,0X6E,0X2E,0X2E,0X2E},
+ .frame_len=34,
+ .raw_payload_len=21,
+ .expected_errno=0,
+ .descr="Continuation test frag2",
+ .i=0,
+ .simulate_sock_malfunction_at=0,
+ .errno_val=0,
+ .close_sock_at=0
+ },
+ {
+ .frame={0X80,0X94,0X3B,0X88,0XA1,0XE9,0X62,0XDF,0X94,0X82,0X72,0XCF,0X98,0X9C,0X72,0XCF,0XE7,0X9C,0X61,0XCB,0XE3,0X93,0X5F,0XCF,0X98,0X9E},
+ .expectedDecodeBuf={0X61,0X6E,0X64,0X20,0X6F,0X6E,0X20,0X61,0X6E,0X64,0X20,0X73,0X74,0X6F,0X70},
+ .frame_len=26,
+ .raw_payload_len=15,
+ .expected_errno=0,
+ .descr="Continuation test frag3",
+ .i=0,
+ .simulate_sock_malfunction_at=0,
+ .errno_val=0,
+ .close_sock_at=0
+ }
+};
diff --git a/webclients/Makefile.am b/webclients/Makefile.am
deleted file mode 100644
index 6c2db84..0000000
--- a/webclients/Makefile.am
+++ /dev/null
@@ -1,4 +0,0 @@
-SUBDIRS = java-applet
-DIST_SUBDIRS = java-applet
-EXTRA_DIST=index.vnc novnc
-
diff --git a/webclients/index.vnc b/webclients/index.vnc
index 3229d79..728eab1 100644
--- a/webclients/index.vnc
+++ b/webclients/index.vnc
@@ -18,7 +18,7 @@ $USER's $DESKTOP desktop ($DISPLAY)
<br/>
<br/>
-If the above Java applet does not work, you can also try the new JavaScript-only <a href="http://kanaka.github.com/noVNC/">noVNC</a> viewer. You will need a HTML5-capable browser though.
+If the above Java applet does not work, you can also try the new JavaScript-only <a href="https://novnc.com/">noVNC</a> viewer. You will need a HTML5-capable browser though.
<script language="JavaScript">
<!--
function start_novnc(){
@@ -30,7 +30,7 @@ If the above Java applet does not work, you can also try the new JavaScript-only
if(host.charAt(host.length-1) != "]")
host = host + "]";
}
- open("novnc/vnc_auto.html?host=" + host + "&port=$PORT&true_color=1");
+ open("novnc/vnc.html?autoconnect=true&host=" + host + "&port=$PORT");
}
-->
</script>
diff --git a/webclients/java-applet/Makefile.am b/webclients/java-applet/Makefile.am
deleted file mode 100644
index d6d10e4..0000000
--- a/webclients/java-applet/Makefile.am
+++ /dev/null
@@ -1,5 +0,0 @@
-EXTRA_DIST=VncViewer.jar javaviewer.pseudo_proxy.patch
-
-SUBDIRS = ssl
-DIST_SUBDIRS = ssl
-
diff --git a/webclients/java-applet/ssl/Makefile.am b/webclients/java-applet/ssl/Makefile.am
deleted file mode 100644
index fd1c201..0000000
--- a/webclients/java-applet/ssl/Makefile.am
+++ /dev/null
@@ -1,2 +0,0 @@
-EXTRA_DIST=VncViewer.jar index.vnc SignedVncViewer.jar proxy.vnc README ss_vncviewer onetimekey UltraViewerSSL.jar SignedUltraViewerSSL.jar ultra.vnc ultrasigned.vnc ultraproxy.vnc
-
diff --git a/webclients/novnc/LICENSE.txt b/webclients/novnc/LICENSE.txt
deleted file mode 100644
index 2d09408..0000000
--- a/webclients/novnc/LICENSE.txt
+++ /dev/null
@@ -1,82 +0,0 @@
-noVNC is Copyright (C) 2011 Joel Martin <github@martintribe.org>
-
-The noVNC core library files are licensed under the MPL 2.0 (Mozilla
-Public License 2.0). The noVNC core library is composed of the
-Javascript code necessary for full noVNC operation. This includes (but
-is not limited to):
-
- include/base64.js
- include/des.js
- include/display.js
- include/input.js
- include/jsunzip.js
- include/keysym.js
- include/logo.js
- include/rfb.js
- include/ui.js
- include/util.js
- include/vnc.js
- include/websock.js
- include/webutil.js
-
-The HTML, CSS, font and images files that included with the noVNC
-source distibution (or repository) are not considered part of the
-noVNC core library and are licensed under more permissive licenses.
-The intent is to allow easy integration of noVNC into existing web
-sites and web applications.
-
-The HTML, CSS, font and image files are licensed as follows:
-
- *.html : 2-Clause BSD license
-
- include/*.css : 2-Clause BSD license
-
- include/Orbitron* : SIL Open Font License 1.1
- (Copyright 2009 Matt McInerney)
-
- images/ : Creative Commons Attribution-ShareAlike
- http://creativecommons.org/licenses/by-sa/3.0/
-
-Some portions of noVNC are copyright to their individual authors.
-Please refer to the individual source files and/or to the noVNC commit
-history: https://github.com/kanaka/noVNC/commits/master
-
-The are several files and projects that have been incorporated into
-the noVNC core library. Here is a list of those files and the original
-licenses (all MPL 2.0 compatible):
-
- include/base64.js : MPL 2.0
-
- include/des.js : Various BSD style licenses
-
- include/jsunzip.js : zlib/libpng license
-
- include/web-socket-js/ : New BSD license (3-clause). Source code at
- http://github.com/gimite/web-socket-js
-
- include/chrome-app/tcp-stream.js
- : Apache 2.0 license
-
- utils/websockify
- utils/websocket.py : LGPL 3
-
-The following license texts are included:
-
- docs/LICENSE.MPL-2.0
- docs/LICENSE.LGPL-3 and
- docs/LICENSE.GPL-3
- docs/LICENSE.OFL-1.1
- docs/LICENSE.BSD-3-Clause (New BSD)
- docs/LICENSE.BSD-2-Clause (Simplified BSD / FreeBSD)
- docs/LICENSE.zlib
- docs/LICENSE.Apache-2.0
-
-Or alternatively the license texts may be found here:
-
- http://www.mozilla.org/MPL/2.0/
- http://www.gnu.org/licenses/lgpl.html and
- http://www.gnu.org/licenses/gpl.html
- http://scripts.sil.org/OFL
- http://en.wikipedia.org/wiki/BSD_licenses
- http://www.gzip.org/zlib/zlib_license.html
- http://www.apache.org/licenses/LICENSE-2.0.html
diff --git a/webclients/novnc/README.md b/webclients/novnc/README.md
deleted file mode 100644
index b5679cd..0000000
--- a/webclients/novnc/README.md
+++ /dev/null
@@ -1,138 +0,0 @@
-## noVNC: HTML5 VNC Client
-
-[![Build Status](https://travis-ci.org/kanaka/noVNC.svg?branch=master)](https://travis-ci.org/kanaka/noVNC)
-
-### Description
-
-noVNC is a HTML5 VNC client that runs well in any modern browser
-including mobile browsers (iPhone/iPad and Android).
-
-Many companies/projects have integrated noVNC including [Ganeti Web
-Manager](http://code.osuosl.org/projects/ganeti-webmgr),
-[OpenStack](http://www.openstack.org),
-[OpenNebula](http://opennebula.org/), and
-[LibVNCServer](http://libvncserver.sourceforge.net). See [the Projects
-and Companies wiki
-page](https://github.com/kanaka/noVNC/wiki/ProjectsCompanies-using-noVNC)
-for a more complete list with additional info and links.
-
-### News/help/contact
-
-Notable commits, announcements and news are posted to
-<a href="http://www.twitter.com/noVNC">@noVNC</a>
-
-If you are a noVNC developer/integrator/user (or want to be) please
-join the <a
-href="https://groups.google.com/forum/?fromgroups#!forum/novnc">noVNC
-discussion group</a>
-
-Bugs and feature requests can be submitted via [github
-issues](https://github.com/kanaka/noVNC/issues). If you are looking
-for a place to start contributing to noVNC, a good place to start
-would be the issues that are marked as
-["patchwelcome"](https://github.com/kanaka/noVNC/issues?labels=patchwelcome).
-
-If you want to show appreciation for noVNC you could donate to a great
-non-profits such as: [Compassion
-International](http://www.compassion.com/), [SIL](http://www.sil.org),
-[Habitat for Humanity](http://www.habitat.org), [Electronic Frontier
-Foundation](https://www.eff.org/), [Against Malaria
-Foundation](http://www.againstmalaria.com/), [Nothing But
-Nets](http://www.nothingbutnets.net/), etc. Please tweet <a
-href="http://www.twitter.com/noVNC">@noVNC</a> if you do.
-
-
-### Features
-
-* Supports all modern browsers including mobile (iOS, Android)
-* Supported VNC encodings: raw, copyrect, rre, hextile, tight, tightPNG
-* WebSocket SSL/TLS encryption (i.e. "wss://") support
-* 24-bit true color and 8 bit colour mapped
-* Supports desktop resize notification/pseudo-encoding
-* Local or remote cursor
-* Clipboard copy/paste
-* Clipping or scolling modes for large remote screens
-* Easy site integration and theming (3 example themes included)
-* Licensed under the [MPL 2.0](http://www.mozilla.org/MPL/2.0/)
-
-### Screenshots
-
-Running in Chrome before and after connecting:
-
-<img src="http://kanaka.github.com/noVNC/img/noVNC-5.png" width=400>&nbsp;<img src="http://kanaka.github.com/noVNC/img/noVNC-7.jpg" width=400>
-
-See more screenshots <a href="http://kanaka.github.com/noVNC/screenshots.html">here</a>.
-
-
-### Browser Requirements
-
-* HTML5 Canvas (with createImageData): Chrome, Firefox 3.6+, iOS
- Safari, Opera 11+, Internet Explorer 9+, etc.
-
-* HTML5 WebSockets: For browsers that do not have builtin
- WebSockets support, the project includes
- <a href="http://github.com/gimite/web-socket-js">web-socket-js</a>,
- a WebSockets emulator using Adobe Flash. iOS 4.2+ has built-in
- WebSocket support.
-
-* Fast Javascript Engine: this is not strictly a requirement, but
- without a fast Javascript engine, noVNC might be painfully slow.
-
-* See the more detailed [browser compatibility wiki page](https://github.com/kanaka/noVNC/wiki/Browser-support).
-
-
-### Server Requirements
-
-Unless you are using a VNC server with support for WebSockets
-connections (such as
-[x11vnc/libvncserver](http://libvncserver.sourceforge.net/),
-[QEMU](http://www.qemu.org/), or
-[PocketVNC](http://www.pocketvnc.com/blog/?page_id=866)), you need to
-use a WebSockets to TCP socket proxy. There is a python proxy included
-('websockify').
-
-
-### Quick Start
-
-* Use the launch script to start a mini-webserver and the WebSockets
- proxy (websockify). The `--vnc` option is used to specify the location of
- a running VNC server:
-
- `./utils/launch.sh --vnc localhost:5901`
-
-* Point your browser to the cut-and-paste URL that is output by the
- launch script. Enter a password if the VNC server has one
- configured. Hit the Connect button and enjoy!
-
-
-### Other Pages
-
-* [Encrypted Connections](https://github.com/kanaka/websockify/wiki/Encrypted-Connections). How to setup websockify so that you can use encrypted connections from noVNC.
-
-* [Advanced Usage](https://github.com/kanaka/noVNC/wiki/Advanced-usage). Starting a VNC server, advanced websockify usage, etc.
-
-* [Integrating noVNC](https://github.com/kanaka/noVNC/wiki/Integration) into existing projects.
-
-* [Troubleshooting noVNC](https://github.com/kanaka/noVNC/wiki/Troubleshooting) problems.
-
-
-### Authors/Contributors
-
-* Core team:
- * [Joel Martin](https://github.com/kanaka)
- * [Samuel Mannehed](https://github.com/samhed) (Cendio)
- * [Peter Åstrand](https://github.com/astrand) (Cendio)
- * [Solly Ross](https://github.com/DirectXMan12) (Red Hat / OpenStack)
-
-* Notable contributions:
- * UI and Icons : Chris Gordon
- * Original Logo : Michael Sersen
- * tight encoding : Michael Tinglof (Mercuri.ca)
-
-* Included libraries:
- * web-socket-js : Hiroshi Ichikawa (github.com/gimite/web-socket-js)
- * as3crypto : Henri Torgemane (code.google.com/p/as3crypto)
- * base64 : Martijn Pieters (Digital Creations 2), Samuel Sieb (sieb.net)
- * jsunzip : Erik Moller (github.com/operasoftware/jsunzip),
- * tinflate : Joergen Ibsen (ibsensoftware.com)
- * DES : Dave Zimmerman (Widget Workshop), Jef Poskanzer (ACME Labs)
diff --git a/webclients/novnc/app/error-handler.js b/webclients/novnc/app/error-handler.js
new file mode 100644
index 0000000..e5a6adb
--- /dev/null
+++ b/webclients/novnc/app/error-handler.js
@@ -0,0 +1,56 @@
+// NB: this should *not* be included as a module until we have
+// native support in the browsers, so that our error handler
+// can catch script-loading errors.
+
+
+(function(){
+ "use strict";
+
+ // Fallback for all uncought errors
+ function handleError (event, err) {
+ try {
+ var msg = document.getElementById('noVNC_fallback_errormsg');
+
+ // Only show the initial error
+ if (msg.hasChildNodes()) {
+ return false;
+ }
+
+ var div = document.createElement("div");
+ div.classList.add('noVNC_message');
+ div.appendChild(document.createTextNode(event.message));
+ msg.appendChild(div);
+
+ if (event.filename) {
+ div = document.createElement("div");
+ div.className = 'noVNC_location';
+ var text = event.filename;
+ if (event.lineno !== undefined) {
+ text += ":" + event.lineno;
+ if (event.colno !== undefined) {
+ text += ":" + event.colno;
+ }
+ }
+ div.appendChild(document.createTextNode(text));
+ msg.appendChild(div);
+ }
+
+ if (err && (err.stack !== undefined)) {
+ div = document.createElement("div");
+ div.className = 'noVNC_stack';
+ div.appendChild(document.createTextNode(err.stack));
+ msg.appendChild(div);
+ }
+
+ document.getElementById('noVNC_fallback_error')
+ .classList.add("noVNC_open");
+ } catch (exc) {
+ document.write("noVNC encountered an error.");
+ }
+ // Don't return true since this would prevent the error
+ // from being printed to the browser console.
+ return false;
+ }
+ window.addEventListener('error', function (evt) { handleError(evt, evt.error); });
+ window.addEventListener('unhandledrejection', function (evt) { handleError(evt.reason, evt.reason); });
+})();
diff --git a/webclients/novnc/app/images/alt.svg b/webclients/novnc/app/images/alt.svg
new file mode 100644
index 0000000..e5bb461
--- /dev/null
+++ b/webclients/novnc/app/images/alt.svg
@@ -0,0 +1,92 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="25"
+ height="25"
+ viewBox="0 0 25 25"
+ id="svg2"
+ version="1.1"
+ inkscape:version="0.91 r13725"
+ sodipodi:docname="alt.svg"
+ inkscape:export-filename="/home/ossman/devel/noVNC/images/drag.png"
+ inkscape:export-xdpi="90"
+ inkscape:export-ydpi="90">
+ <defs
+ id="defs4" />
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#959595"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ inkscape:pageopacity="0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="16"
+ inkscape:cx="18.205425"
+ inkscape:cy="17.531398"
+ inkscape:document-units="px"
+ inkscape:current-layer="layer1"
+ showgrid="false"
+ units="px"
+ inkscape:snap-bbox="true"
+ inkscape:bbox-paths="true"
+ inkscape:bbox-nodes="true"
+ inkscape:snap-bbox-edge-midpoints="true"
+ inkscape:object-paths="true"
+ showguides="true"
+ inkscape:window-width="1920"
+ inkscape:window-height="1136"
+ inkscape:window-x="1920"
+ inkscape:window-y="27"
+ inkscape:window-maximized="1"
+ inkscape:snap-smooth-nodes="true"
+ inkscape:object-nodes="true"
+ inkscape:snap-intersection-paths="true"
+ inkscape:snap-nodes="true"
+ inkscape:snap-global="true">
+ <inkscape:grid
+ type="xygrid"
+ id="grid4136" />
+ </sodipodi:namedview>
+ <metadata
+ id="metadata7">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:title></dc:title>
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ inkscape:label="Layer 1"
+ inkscape:groupmode="layer"
+ id="layer1"
+ transform="translate(0,-1027.3622)">
+ <g
+ style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:48px;line-height:125%;font-family:'DejaVu Sans';-inkscape-font-specification:'Sans Bold';text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ id="text5290">
+ <path
+ d="m 9.9560547,1042.3329 -2.9394531,0 -0.4638672,1.3281 -1.8896485,0 2.7001953,-7.29 2.241211,0 2.7001958,7.29 -1.889649,0 -0.4589843,-1.3281 z m -2.4707031,-1.3526 1.9970703,0 -0.9960938,-2.9003 -1.0009765,2.9003 z"
+ style="font-size:10px;fill:#ffffff;fill-opacity:1"
+ id="path5340" />
+ <path
+ d="m 13.188477,1036.0634 1.748046,0 0,7.5976 -1.748046,0 0,-7.5976 z"
+ style="font-size:10px;fill:#ffffff;fill-opacity:1"
+ id="path5342" />
+ <path
+ d="m 18.535156,1036.6395 0,1.5528 1.801758,0 0,1.25 -1.801758,0 0,2.3193 q 0,0.3809 0.151367,0.5176 0.151368,0.1318 0.600586,0.1318 l 0.898438,0 0,1.25 -1.499024,0 q -1.035156,0 -1.469726,-0.4297 -0.429688,-0.4345 -0.429688,-1.4697 l 0,-2.3193 -0.86914,0 0,-1.25 0.86914,0 0,-1.5528 1.748047,0 z"
+ style="font-size:10px;fill:#ffffff;fill-opacity:1"
+ id="path5344" />
+ </g>
+ </g>
+</svg>
diff --git a/webclients/novnc/app/images/clipboard.svg b/webclients/novnc/app/images/clipboard.svg
new file mode 100644
index 0000000..79af275
--- /dev/null
+++ b/webclients/novnc/app/images/clipboard.svg
@@ -0,0 +1,106 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="25"
+ height="25"
+ viewBox="0 0 25 25"
+ id="svg2"
+ version="1.1"
+ inkscape:version="0.91 r13725"
+ sodipodi:docname="clipboard.svg"
+ inkscape:export-filename="/home/ossman/devel/noVNC/images/drag.png"
+ inkscape:export-xdpi="90"
+ inkscape:export-ydpi="90">
+ <defs
+ id="defs4" />
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#959595"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ inkscape:pageopacity="0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="1"
+ inkscape:cx="15.366606"
+ inkscape:cy="16.42981"
+ inkscape:document-units="px"
+ inkscape:current-layer="layer1"
+ showgrid="false"
+ units="px"
+ inkscape:snap-bbox="true"
+ inkscape:bbox-paths="true"
+ inkscape:bbox-nodes="true"
+ inkscape:snap-bbox-edge-midpoints="true"
+ inkscape:object-paths="true"
+ showguides="true"
+ inkscape:window-width="1920"
+ inkscape:window-height="1136"
+ inkscape:window-x="1920"
+ inkscape:window-y="27"
+ inkscape:window-maximized="1"
+ inkscape:snap-smooth-nodes="true"
+ inkscape:object-nodes="true"
+ inkscape:snap-intersection-paths="true"
+ inkscape:snap-nodes="true"
+ inkscape:snap-global="true">
+ <inkscape:grid
+ type="xygrid"
+ id="grid4136" />
+ </sodipodi:namedview>
+ <metadata
+ id="metadata7">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:title></dc:title>
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ inkscape:label="Layer 1"
+ inkscape:groupmode="layer"
+ id="layer1"
+ transform="translate(0,-1027.3622)">
+ <path
+ style="opacity:1;fill:none;fill-opacity:1;stroke:#ffffff;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+ d="M 9,6 6,6 C 5.4459889,6 5,6.4459889 5,7 l 0,13 c 0,0.554011 0.4459889,1 1,1 l 13,0 c 0.554011,0 1,-0.445989 1,-1 L 20,7 C 20,6.4459889 19.554011,6 19,6 l -3,0"
+ transform="translate(0,1027.3622)"
+ id="rect6083"
+ inkscape:connector-curvature="0"
+ sodipodi:nodetypes="cssssssssc" />
+ <rect
+ style="opacity:1;fill:none;fill-opacity:1;stroke:#ffffff;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+ id="rect6085"
+ width="7"
+ height="4"
+ x="9"
+ y="1031.3622"
+ ry="1.00002" />
+ <path
+ style="fill:none;fill-rule:evenodd;stroke:#ffffff;stroke-width:1;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:0.50196081"
+ d="m 8.5071212,1038.8622 7.9999998,0"
+ id="path6087"
+ inkscape:connector-curvature="0" />
+ <path
+ style="fill:none;fill-rule:evenodd;stroke:#ffffff;stroke-width:1;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:0.50196081"
+ d="m 8.5071212,1041.8622 3.9999998,0"
+ id="path6089"
+ inkscape:connector-curvature="0" />
+ <path
+ style="fill:none;fill-rule:evenodd;stroke:#ffffff;stroke-width:1;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:0.50196081"
+ d="m 8.5071212,1044.8622 5.9999998,0"
+ id="path6091"
+ inkscape:connector-curvature="0" />
+ </g>
+</svg>
diff --git a/webclients/novnc/app/images/connect.svg b/webclients/novnc/app/images/connect.svg
new file mode 100644
index 0000000..56cde41
--- /dev/null
+++ b/webclients/novnc/app/images/connect.svg
@@ -0,0 +1,96 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="25"
+ height="25"
+ viewBox="0 0 25 25"
+ id="svg2"
+ version="1.1"
+ inkscape:version="0.91 r13725"
+ sodipodi:docname="connect.svg"
+ inkscape:export-filename="/home/ossman/devel/noVNC/images/drag.png"
+ inkscape:export-xdpi="90"
+ inkscape:export-ydpi="90">
+ <defs
+ id="defs4" />
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#959595"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ inkscape:pageopacity="0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="1"
+ inkscape:cx="37.14834"
+ inkscape:cy="1.9525926"
+ inkscape:document-units="px"
+ inkscape:current-layer="layer1"
+ showgrid="false"
+ units="px"
+ inkscape:snap-bbox="true"
+ inkscape:bbox-paths="true"
+ inkscape:bbox-nodes="true"
+ inkscape:snap-bbox-edge-midpoints="true"
+ inkscape:object-paths="true"
+ showguides="true"
+ inkscape:window-width="1920"
+ inkscape:window-height="1136"
+ inkscape:window-x="1920"
+ inkscape:window-y="27"
+ inkscape:window-maximized="1"
+ inkscape:snap-smooth-nodes="true"
+ inkscape:object-nodes="true"
+ inkscape:snap-intersection-paths="true"
+ inkscape:snap-nodes="true">
+ <inkscape:grid
+ type="xygrid"
+ id="grid4136" />
+ </sodipodi:namedview>
+ <metadata
+ id="metadata7">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:title></dc:title>
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ inkscape:label="Layer 1"
+ inkscape:groupmode="layer"
+ id="layer1"
+ transform="translate(0,-1027.3622)">
+ <g
+ id="g5103"
+ transform="matrix(0.70710678,-0.70710678,0.70710678,0.70710678,-729.15757,315.8823)">
+ <path
+ sodipodi:nodetypes="cssssc"
+ inkscape:connector-curvature="0"
+ id="rect5096"
+ d="m 11,1040.3622 -5,0 c -1.108,0 -2,-0.892 -2,-2 l 0,-4 c 0,-1.108 0.892,-2 2,-2 l 5,0"
+ style="opacity:1;fill:none;fill-opacity:1;stroke:#ffffff;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
+ <path
+ style="opacity:1;fill:none;fill-opacity:1;stroke:#ffffff;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+ d="m 14,1032.3622 5,0 c 1.108,0 2,0.892 2,2 l 0,4 c 0,1.108 -0.892,2 -2,2 l -5,0"
+ id="path5099"
+ inkscape:connector-curvature="0"
+ sodipodi:nodetypes="cssssc" />
+ <path
+ inkscape:connector-curvature="0"
+ id="path5101"
+ d="m 9,1036.3622 7,0"
+ style="fill:none;fill-rule:evenodd;stroke:#ffffff;stroke-width:2;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
+ </g>
+ </g>
+</svg>
diff --git a/webclients/novnc/app/images/ctrl.svg b/webclients/novnc/app/images/ctrl.svg
new file mode 100644
index 0000000..856e939
--- /dev/null
+++ b/webclients/novnc/app/images/ctrl.svg
@@ -0,0 +1,96 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="25"
+ height="25"
+ viewBox="0 0 25 25"
+ id="svg2"
+ version="1.1"
+ inkscape:version="0.91 r13725"
+ sodipodi:docname="ctrl.svg"
+ inkscape:export-filename="/home/ossman/devel/noVNC/images/drag.png"
+ inkscape:export-xdpi="90"
+ inkscape:export-ydpi="90">
+ <defs
+ id="defs4" />
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#959595"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ inkscape:pageopacity="0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="16"
+ inkscape:cx="18.205425"
+ inkscape:cy="17.531398"
+ inkscape:document-units="px"
+ inkscape:current-layer="layer1"
+ showgrid="false"
+ units="px"
+ inkscape:snap-bbox="true"
+ inkscape:bbox-paths="true"
+ inkscape:bbox-nodes="true"
+ inkscape:snap-bbox-edge-midpoints="true"
+ inkscape:object-paths="true"
+ showguides="true"
+ inkscape:window-width="1920"
+ inkscape:window-height="1136"
+ inkscape:window-x="1920"
+ inkscape:window-y="27"
+ inkscape:window-maximized="1"
+ inkscape:snap-smooth-nodes="true"
+ inkscape:object-nodes="true"
+ inkscape:snap-intersection-paths="true"
+ inkscape:snap-nodes="true"
+ inkscape:snap-global="true">
+ <inkscape:grid
+ type="xygrid"
+ id="grid4136" />
+ </sodipodi:namedview>
+ <metadata
+ id="metadata7">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:title></dc:title>
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ inkscape:label="Layer 1"
+ inkscape:groupmode="layer"
+ id="layer1"
+ transform="translate(0,-1027.3622)">
+ <g
+ style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:48px;line-height:125%;font-family:'DejaVu Sans';-inkscape-font-specification:'Sans Bold';text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ id="text5290">
+ <path
+ d="m 9.1210938,1043.1898 q -0.5175782,0.2686 -1.0791016,0.4053 -0.5615235,0.1367 -1.171875,0.1367 -1.8212891,0 -2.8857422,-1.0156 -1.0644531,-1.0205 -1.0644531,-2.7637 0,-1.748 1.0644531,-2.7637 1.0644531,-1.0205 2.8857422,-1.0205 0.6103515,0 1.171875,0.1368 0.5615234,0.1367 1.0791016,0.4052 l 0,1.5088 q -0.522461,-0.3564 -1.0302735,-0.5224 -0.5078125,-0.1661 -1.0693359,-0.1661 -1.0058594,0 -1.5820313,0.6446 -0.5761719,0.6445 -0.5761719,1.7773 0,1.1279 0.5761719,1.7725 0.5761719,0.6445 1.5820313,0.6445 0.5615234,0 1.0693359,-0.166 0.5078125,-0.166 1.0302735,-0.5225 l 0,1.5088 z"
+ style="font-size:10px;fill:#ffffff;fill-opacity:1"
+ id="path5370" />
+ <path
+ d="m 12.514648,1036.5687 0,1.5528 1.801758,0 0,1.25 -1.801758,0 0,2.3193 q 0,0.3809 0.151368,0.5176 0.151367,0.1318 0.600586,0.1318 l 0.898437,0 0,1.25 -1.499023,0 q -1.035157,0 -1.469727,-0.4297 -0.429687,-0.4345 -0.429687,-1.4697 l 0,-2.3193 -0.8691411,0 0,-1.25 0.8691411,0 0,-1.5528 1.748046,0 z"
+ style="font-size:10px;fill:#ffffff;fill-opacity:1"
+ id="path5372" />
+ <path
+ d="m 19.453125,1039.6107 q -0.229492,-0.1074 -0.458984,-0.1562 -0.22461,-0.054 -0.454102,-0.054 -0.673828,0 -1.040039,0.4345 -0.361328,0.4297 -0.361328,1.2354 l 0,2.5195 -1.748047,0 0,-5.4687 1.748047,0 0,0.8984 q 0.336914,-0.5371 0.771484,-0.7813 0.439453,-0.249 1.049805,-0.249 0.08789,0 0.19043,0.01 0.102539,0 0.297851,0.029 l 0.0049,1.582 z"
+ style="font-size:10px;fill:#ffffff;fill-opacity:1"
+ id="path5374" />
+ <path
+ d="m 20.332031,1035.9926 1.748047,0 0,7.5976 -1.748047,0 0,-7.5976 z"
+ style="font-size:10px;fill:#ffffff;fill-opacity:1"
+ id="path5376" />
+ </g>
+ </g>
+</svg>
diff --git a/webclients/novnc/app/images/ctrlaltdel.svg b/webclients/novnc/app/images/ctrlaltdel.svg
new file mode 100644
index 0000000..d7744ea
--- /dev/null
+++ b/webclients/novnc/app/images/ctrlaltdel.svg
@@ -0,0 +1,100 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="25"
+ height="25"
+ viewBox="0 0 25 25"
+ id="svg2"
+ version="1.1"
+ inkscape:version="0.91 r13725"
+ sodipodi:docname="ctrlaltdel.svg"
+ inkscape:export-filename="/home/ossman/devel/noVNC/images/drag.png"
+ inkscape:export-xdpi="90"
+ inkscape:export-ydpi="90">
+ <defs
+ id="defs4" />
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#959595"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ inkscape:pageopacity="0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="8"
+ inkscape:cx="11.135667"
+ inkscape:cy="16.407428"
+ inkscape:document-units="px"
+ inkscape:current-layer="layer1"
+ showgrid="false"
+ units="px"
+ inkscape:snap-bbox="true"
+ inkscape:bbox-paths="true"
+ inkscape:bbox-nodes="true"
+ inkscape:snap-bbox-edge-midpoints="true"
+ inkscape:object-paths="true"
+ showguides="true"
+ inkscape:window-width="1920"
+ inkscape:window-height="1136"
+ inkscape:window-x="1920"
+ inkscape:window-y="27"
+ inkscape:window-maximized="1"
+ inkscape:snap-smooth-nodes="true"
+ inkscape:object-nodes="true"
+ inkscape:snap-intersection-paths="true"
+ inkscape:snap-nodes="true"
+ inkscape:snap-global="true">
+ <inkscape:grid
+ type="xygrid"
+ id="grid4136" />
+ </sodipodi:namedview>
+ <metadata
+ id="metadata7">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:title></dc:title>
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ inkscape:label="Layer 1"
+ inkscape:groupmode="layer"
+ id="layer1"
+ transform="translate(0,-1027.3622)">
+ <rect
+ style="opacity:1;fill:#ffffff;fill-opacity:1;stroke:#ffffff;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+ id="rect5253"
+ width="5"
+ height="5.0000172"
+ x="16"
+ y="1031.3622"
+ ry="1.0000174" />
+ <rect
+ y="1043.3622"
+ x="4"
+ height="5.0000172"
+ width="5"
+ id="rect5255"
+ style="opacity:1;fill:#ffffff;fill-opacity:1;stroke:#ffffff;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+ ry="1.0000174" />
+ <rect
+ style="opacity:1;fill:#ffffff;fill-opacity:1;stroke:#ffffff;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+ id="rect5257"
+ width="5"
+ height="5.0000172"
+ x="13"
+ y="1043.3622"
+ ry="1.0000174" />
+ </g>
+</svg>
diff --git a/webclients/novnc/app/images/disconnect.svg b/webclients/novnc/app/images/disconnect.svg
new file mode 100644
index 0000000..6be7d18
--- /dev/null
+++ b/webclients/novnc/app/images/disconnect.svg
@@ -0,0 +1,94 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="25"
+ height="25"
+ viewBox="0 0 25 25"
+ id="svg2"
+ version="1.1"
+ inkscape:version="0.91 r13725"
+ sodipodi:docname="disconnect.svg"
+ inkscape:export-filename="/home/ossman/devel/noVNC/images/drag.png"
+ inkscape:export-xdpi="90"
+ inkscape:export-ydpi="90">
+ <defs
+ id="defs4" />
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#959595"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ inkscape:pageopacity="0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="16"
+ inkscape:cx="25.05707"
+ inkscape:cy="11.594858"
+ inkscape:document-units="px"
+ inkscape:current-layer="layer1"
+ showgrid="false"
+ units="px"
+ inkscape:snap-bbox="true"
+ inkscape:bbox-paths="true"
+ inkscape:bbox-nodes="true"
+ inkscape:snap-bbox-edge-midpoints="true"
+ inkscape:object-paths="true"
+ showguides="true"
+ inkscape:window-width="1920"
+ inkscape:window-height="1136"
+ inkscape:window-x="1920"
+ inkscape:window-y="27"
+ inkscape:window-maximized="1"
+ inkscape:snap-smooth-nodes="true"
+ inkscape:object-nodes="true"
+ inkscape:snap-intersection-paths="true"
+ inkscape:snap-nodes="true"
+ inkscape:snap-global="false">
+ <inkscape:grid
+ type="xygrid"
+ id="grid4136" />
+ </sodipodi:namedview>
+ <metadata
+ id="metadata7">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:title></dc:title>
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ inkscape:label="Layer 1"
+ inkscape:groupmode="layer"
+ id="layer1"
+ transform="translate(0,-1027.3622)">
+ <g
+ id="g5171"
+ transform="translate(-24.062499,-6.15775e-4)">
+ <path
+ id="path5110"
+ transform="translate(0,1027.3622)"
+ d="m 39.744141,3.4960938 c -0.769923,0 -1.539607,0.2915468 -2.121094,0.8730468 l -2.566406,2.5664063 1.414062,1.4140625 2.566406,-2.5664063 c 0.403974,-0.404 1.010089,-0.404 1.414063,0 l 2.828125,2.828125 c 0.40398,0.4039 0.403907,1.0101621 0,1.4140629 l -2.566406,2.566406 1.414062,1.414062 2.566406,-2.566406 c 1.163041,-1.1629 1.162968,-3.0791874 0,-4.2421874 L 41.865234,4.3691406 C 41.283747,3.7876406 40.514063,3.4960937 39.744141,3.4960938 Z M 39.017578,9.015625 a 1.0001,1.0001 0 0 0 -0.6875,0.3027344 l -0.445312,0.4453125 1.414062,1.4140621 0.445313,-0.445312 A 1.0001,1.0001 0 0 0 39.017578,9.015625 Z m -6.363281,0.7070312 a 1.0001,1.0001 0 0 0 -0.6875,0.3027348 L 28.431641,13.5625 c -1.163042,1.163 -1.16297,3.079187 0,4.242188 l 2.828125,2.828124 c 1.162974,1.163101 3.079213,1.163101 4.242187,0 l 3.535156,-3.535156 a 1.0001,1.0001 0 1 0 -1.414062,-1.414062 l -3.535156,3.535156 c -0.403974,0.404 -1.010089,0.404 -1.414063,0 l -2.828125,-2.828125 c -0.403981,-0.404 -0.403908,-1.010162 0,-1.414063 l 3.535156,-3.537109 A 1.0001,1.0001 0 0 0 32.654297,9.7226562 Z m 3.109375,2.1621098 -2.382813,2.384765 a 1.0001,1.0001 0 1 0 1.414063,1.414063 l 2.382812,-2.384766 -1.414062,-1.414062 z"
+ style="color:#000000;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:medium;line-height:normal;font-family:sans-serif;text-indent:0;text-align:start;text-decoration:none;text-decoration-line:none;text-decoration-style:solid;text-decoration-color:#000000;letter-spacing:normal;word-spacing:normal;text-transform:none;direction:ltr;block-progression:tb;writing-mode:lr-tb;baseline-shift:baseline;text-anchor:start;white-space:normal;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate"
+ inkscape:connector-curvature="0" />
+ <rect
+ transform="matrix(0.70710678,-0.70710678,0.70710678,0.70710678,0,0)"
+ y="752.29541"
+ x="-712.31262"
+ height="18.000017"
+ width="3"
+ id="rect5116"
+ style="opacity:1;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
+ </g>
+ </g>
+</svg>
diff --git a/webclients/novnc/app/images/drag.svg b/webclients/novnc/app/images/drag.svg
new file mode 100644
index 0000000..139caf9
--- /dev/null
+++ b/webclients/novnc/app/images/drag.svg
@@ -0,0 +1,76 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="25"
+ height="25"
+ viewBox="0 0 25 25"
+ id="svg2"
+ version="1.1"
+ inkscape:version="0.91 r13725"
+ sodipodi:docname="drag.svg"
+ inkscape:export-filename="/home/ossman/devel/noVNC/images/drag.png"
+ inkscape:export-xdpi="90"
+ inkscape:export-ydpi="90">
+ <defs
+ id="defs4" />
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#959595"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ inkscape:pageopacity="0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="22.627417"
+ inkscape:cx="9.8789407"
+ inkscape:cy="9.5008608"
+ inkscape:document-units="px"
+ inkscape:current-layer="layer1"
+ showgrid="true"
+ units="px"
+ inkscape:snap-bbox="true"
+ inkscape:bbox-paths="true"
+ inkscape:bbox-nodes="true"
+ inkscape:snap-bbox-edge-midpoints="true"
+ inkscape:object-paths="true"
+ showguides="false"
+ inkscape:window-width="1920"
+ inkscape:window-height="1136"
+ inkscape:window-x="1920"
+ inkscape:window-y="27"
+ inkscape:window-maximized="1">
+ <inkscape:grid
+ type="xygrid"
+ id="grid4136" />
+ </sodipodi:namedview>
+ <metadata
+ id="metadata7">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:title></dc:title>
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ inkscape:label="Layer 1"
+ inkscape:groupmode="layer"
+ id="layer1"
+ transform="translate(0,-1027.3622)">
+ <path
+ style="opacity:1;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:1;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+ d="m 7.039733,1049.3037 c -0.4309106,-0.1233 -0.7932634,-0.4631 -0.9705434,-0.9103 -0.04922,-0.1241 -0.057118,-0.2988 -0.071321,-1.5771 l -0.015972,-1.4375 -0.328125,-0.082 c -0.7668138,-0.1927 -1.1897046,-0.4275 -1.7031253,-0.9457 -0.4586773,-0.4629 -0.6804297,-0.8433 -0.867034,-1.4875 -0.067215,-0.232 -0.068001,-0.2642 -0.078682,-3.2188 -0.012078,-3.341 -0.020337,-3.2012 0.2099452,-3.5555 0.2246623,-0.3458 0.5798271,-0.5892 0.9667343,-0.6626 0.092506,-0.017 0.531898,-0.032 0.9764271,-0.032 l 0.8082347,0 1.157e-4,1.336 c 1.125e-4,1.2779 0.00281,1.3403 0.062214,1.4378 0.091785,0.1505 0.2357707,0.226 0.4314082,0.2261 0.285389,2e-4 0.454884,-0.1352 0.5058962,-0.4042 0.019355,-0.102 0.031616,-0.982 0.031616,-2.269 0,-1.9756 0.00357,-2.1138 0.059205,-2.2926 0.1645475,-0.5287 0.6307616,-0.9246 1.19078,-1.0113 0.8000572,-0.1238 1.5711277,0.4446 1.6860387,1.2429 0.01732,0.1203 0.03177,0.8248 0.03211,1.5657 6.19e-4,1.3449 7.22e-4,1.347 0.07093,1.4499 0.108355,0.1587 0.255268,0.2248 0.46917,0.2108 0.204069,-0.013 0.316116,-0.08 0.413642,-0.2453 0.06028,-0.1024 0.06307,-0.1778 0.07862,-2.1218 0.01462,-1.8283 0.02124,-2.0285 0.07121,-2.1549 0.260673,-0.659 0.934894,-1.0527 1.621129,-0.9465 0.640523,0.099 1.152269,0.6104 1.243187,1.2421 0.01827,0.1269 0.03175,0.9943 0.03211,2.0657 l 6.19e-4,1.8469 0.07031,0.103 c 0.108355,0.1587 0.255267,0.2248 0.46917,0.2108 0.204069,-0.013 0.316115,-0.08 0.413642,-0.2453 0.05951,-0.1011 0.06329,-0.1786 0.07907,-1.6218 0.01469,-1.3438 0.02277,-1.5314 0.07121,-1.6549 0.257975,-0.6576 0.934425,-1.0527 1.620676,-0.9465 0.640522,0.099 1.152269,0.6104 1.243186,1.2421 0.0186,0.1292 0.03179,1.0759 0.03222,2.3125 7.15e-4,2.0335 0.0025,2.0966 0.06283,2.1956 0.09178,0.1505 0.235771,0.226 0.431409,0.2261 0.285388,2e-4 0.454884,-0.1352 0.505897,-0.4042 0.01874,-0.099 0.03161,-0.8192 0.03161,-1.769 0,-1.4848 0.0043,-1.6163 0.0592,-1.7926 0.164548,-0.5287 0.630762,-0.9246 1.19078,-1.0113 0.800057,-0.1238 1.571128,0.4446 1.686039,1.2429 0.04318,0.2999 0.04372,9.1764 5.78e-4,9.4531 -0.04431,0.2841 -0.217814,0.6241 -0.420069,0.8232 -0.320102,0.315 -0.63307,0.4268 -1.194973,0.4268 l -0.35281,0 -2.51e-4,1.2734 c -1.25e-4,0.7046 -0.01439,1.3642 -0.03191,1.4766 -0.06665,0.4274 -0.372966,0.8704 -0.740031,1.0702 -0.349999,0.1905 0.01748,0.18 -6.242199,0.1776 -5.3622439,0 -5.7320152,-0.01 -5.9121592,-0.057 l 1.4e-5,0 z"
+ id="path4379"
+ inkscape:connector-curvature="0" />
+ </g>
+</svg>
diff --git a/webclients/novnc/app/images/error.svg b/webclients/novnc/app/images/error.svg
new file mode 100644
index 0000000..8356d3f
--- /dev/null
+++ b/webclients/novnc/app/images/error.svg
@@ -0,0 +1,81 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="25"
+ height="25"
+ viewBox="0 0 25 25"
+ id="svg2"
+ version="1.1"
+ inkscape:version="0.91 r13725"
+ sodipodi:docname="error.svg"
+ inkscape:export-filename="/home/ossman/devel/noVNC/images/drag.png"
+ inkscape:export-xdpi="90"
+ inkscape:export-ydpi="90">
+ <defs
+ id="defs4" />
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#959595"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ inkscape:pageopacity="0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="1"
+ inkscape:cx="14.00357"
+ inkscape:cy="12.443398"
+ inkscape:document-units="px"
+ inkscape:current-layer="layer1"
+ showgrid="false"
+ units="px"
+ inkscape:snap-bbox="true"
+ inkscape:bbox-paths="true"
+ inkscape:bbox-nodes="true"
+ inkscape:snap-bbox-edge-midpoints="true"
+ inkscape:object-paths="true"
+ showguides="true"
+ inkscape:window-width="1920"
+ inkscape:window-height="1136"
+ inkscape:window-x="1920"
+ inkscape:window-y="27"
+ inkscape:window-maximized="1"
+ inkscape:snap-smooth-nodes="true"
+ inkscape:object-nodes="true"
+ inkscape:snap-intersection-paths="true"
+ inkscape:snap-nodes="true"
+ inkscape:snap-global="true">
+ <inkscape:grid
+ type="xygrid"
+ id="grid4136" />
+ </sodipodi:namedview>
+ <metadata
+ id="metadata7">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:title />
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ inkscape:label="Layer 1"
+ inkscape:groupmode="layer"
+ id="layer1"
+ transform="translate(0,-1027.3622)">
+ <path
+ style="opacity:1;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+ d="M 7 3 C 4.7839905 3 3 4.7839905 3 7 L 3 18 C 3 20.21601 4.7839905 22 7 22 L 18 22 C 20.21601 22 22 20.21601 22 18 L 22 7 C 22 4.7839905 20.21601 3 18 3 L 7 3 z M 7.6992188 6 A 1.6916875 1.6924297 0 0 1 8.9121094 6.5117188 L 12.5 10.101562 L 16.087891 6.5117188 A 1.6916875 1.6924297 0 0 1 17.251953 6 A 1.6916875 1.6924297 0 0 1 18.480469 8.90625 L 14.892578 12.496094 L 18.480469 16.085938 A 1.6916875 1.6924297 0 1 1 16.087891 18.478516 L 12.5 14.888672 L 8.9121094 18.478516 A 1.6916875 1.6924297 0 1 1 6.5214844 16.085938 L 10.109375 12.496094 L 6.5214844 8.90625 A 1.6916875 1.6924297 0 0 1 7.6992188 6 z "
+ transform="translate(0,1027.3622)"
+ id="rect4135" />
+ </g>
+</svg>
diff --git a/webclients/novnc/app/images/esc.svg b/webclients/novnc/app/images/esc.svg
new file mode 100644
index 0000000..830152b
--- /dev/null
+++ b/webclients/novnc/app/images/esc.svg
@@ -0,0 +1,92 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="25"
+ height="25"
+ viewBox="0 0 25 25"
+ id="svg2"
+ version="1.1"
+ inkscape:version="0.91 r13725"
+ sodipodi:docname="esc.svg"
+ inkscape:export-filename="/home/ossman/devel/noVNC/images/drag.png"
+ inkscape:export-xdpi="90"
+ inkscape:export-ydpi="90">
+ <defs
+ id="defs4" />
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#959595"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ inkscape:pageopacity="0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="16"
+ inkscape:cx="18.205425"
+ inkscape:cy="17.531398"
+ inkscape:document-units="px"
+ inkscape:current-layer="text5290"
+ showgrid="false"
+ units="px"
+ inkscape:snap-bbox="true"
+ inkscape:bbox-paths="true"
+ inkscape:bbox-nodes="true"
+ inkscape:snap-bbox-edge-midpoints="true"
+ inkscape:object-paths="true"
+ showguides="true"
+ inkscape:window-width="1920"
+ inkscape:window-height="1136"
+ inkscape:window-x="1920"
+ inkscape:window-y="27"
+ inkscape:window-maximized="1"
+ inkscape:snap-smooth-nodes="true"
+ inkscape:object-nodes="true"
+ inkscape:snap-intersection-paths="true"
+ inkscape:snap-nodes="true"
+ inkscape:snap-global="true">
+ <inkscape:grid
+ type="xygrid"
+ id="grid4136" />
+ </sodipodi:namedview>
+ <metadata
+ id="metadata7">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:title></dc:title>
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ inkscape:label="Layer 1"
+ inkscape:groupmode="layer"
+ id="layer1"
+ transform="translate(0,-1027.3622)">
+ <g
+ style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:48px;li