Conflicts:
	CMakeLists.txt
	libvncserver/main.c
pull/1/head
Slávek Banko 7 years ago
commit 68cb29a12f

1
.gitignore vendored

@ -61,7 +61,6 @@ examples/vncev
libtool
libvncclient/libvncclient.la
libvncserver/libvncserver.la
rfb/rfbint.h
test/blooptest
test/cargstest
test/copyrecttest

@ -0,0 +1,15 @@
language: c
os:
- linux
- osx
compiler:
- gcc
- 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'
# before build script, run autoreconf
before_script: autoreconf -fiv

@ -1,4 +1,5 @@
cmake_minimum_required(VERSION 2.6)
cmake_policy(SET CMP0037 NEW)
project(LibVNCServer)
include(CheckFunctionExists)
@ -11,10 +12,11 @@ include(CheckCSourceRuns)
set(PACKAGE_NAME "LibVNCServer")
set(FULL_PACKAGE_NAME "LibVNCServer")
set(PACKAGE_VERSION "0.9.10")
set(VERSION_MAJOR "0")
set(VERSION_MINOR "9")
set(VERSION_PATCHLEVEL "10")
set(VERSION_PATCHLEVEL "11")
set(VERSION_SO "0")
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(LIBVNCSERVER_DIR ${CMAKE_CURRENT_SOURCE_DIR}/libvncserver)
@ -34,6 +36,7 @@ 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
@ -100,15 +103,28 @@ if(PNG_FOUND)
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(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})
@ -134,12 +150,21 @@ check_include_file("sys/wait.h" LIBVNCSERVER_HAVE_SYS_WAIT_H)
check_include_file("unistd.h" LIBVNCSERVER_HAVE_UNISTD_H)
# headers needed for check_type_size()
check_include_file("vfork.h" LIBVNCSERVER_HAVE_VFORK_H)
check_include_file("ws2tcpip.h" LIBVNCSERVER_HAVE_WS2TCPIP_H)
check_include_file("arpa/inet.h" HAVE_ARPA_INET_H)
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)
check_function_exists(gettimeofday LIBVNCSERVER_HAVE_GETTIMEOFDAY)
check_function_exists(vfork LIBVNCSERVER_HAVE_VFORK)
check_function_exists(vprintf LIBVNCSERVER_HAVE_VPRINTF)
if(LIBVNCSERVER_HAVE_WS2TCPIP_H AND LIBVNCSERVER_HAVE_VPRINTF)
option(LIBVNCSERVER_IPv6 "Enable IPv6 Support" ON)
endif()
if(CMAKE_USE_PTHREADS_INIT)
set(LIBVNCSERVER_HAVE_LIBPTHREAD 1)
@ -168,7 +193,6 @@ TEST_BIG_ENDIAN(LIBVNCSERVER_WORDS_BIGENDIAN)
# 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/rfbint.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/rfb/rfbint.h)
set(LIBVNCSERVER_SOURCES
${LIBVNCSERVER_DIR}/main.cc

@ -1,3 +1,448 @@
2016-12-29 Christian Beier <dontmind@freeshell.org>
* README: Fix README markdown.
2016-12-28 Christian Beier <dontmind@freeshell.org>
* CMakeLists.txt: CMake: version up as well.
2016-12-28 Christian Beier <dontmind@freeshell.org>
* NEWS: Update NEWS.
2016-12-28 Christian Beier <dontmind@freeshell.org>
* configure.ac: Version up.
2016-12-28 Christian Beier <dontmind@freeshell.org>
* libvncserver/main.c: LibVNCServer: fix starting of an
onHold-client in threaded mode. Discovered by madscientist159 on 11 Jan 2015: "noted in testing with the threaded server build, whereby if
newClientHook() returned RFB_CLIENT_ON_HOLD there was no way to
release the hold when the server became ready"
2016-12-09 Christian Beier <dontmind@freeshell.org>
* : Merge pull request #145 from bkylerussell/websockets Sec-WebSocket-Protocol header fix
2016-12-02 Christian Beier <dontmind@freeshell.org>
* : Merge pull request #142 from samhed/master Write the correct length for end of header
2016-11-29 Christian Beier <dontmind@freeshell.org>
* : Merge pull request #140 from vapier/master test/Makefile: use check_PROGRAMS
2015-01-10 Timothy Pearson <kb9vqf@pearsoncomputing.net>
* README: Update README to reflect change from defaultPtrAddEvent to
rfbDefaultPtrAddEvent
2016-11-25 Christian Beier <dontmind@freeshell.org>
* libvncserver/httpd.c: httpd: rework mime type handling to
recognise more types
2016-11-24 Christian Beier <dontmind@freeshell.org>
* .travis.yml: TravisCI: Another stab at fixing OSX build. See https://github.com/Tarsnap/spiped/pull/92
2016-11-24 Christian Beier <dontmind@freeshell.org>
* configure.ac: Revert "Hopefully fix building on OSX." This reverts commit 584b23fdbe12edd81119d57ddd378d10e52cc9e1.
2016-11-24 Christian Beier <dontmind@freeshell.org>
* configure.ac: Hopefully fix building on OSX.
2016-11-24 Christian Beier <dontmind@freeshell.org>
* .travis.yml: TravisCI: check on OSX as well, test both gcc and
clang.
2016-11-24 Christian Beier <dontmind@freeshell.org>
* libvncclient/rfbproto.c: Fix building on OSX.
2016-11-24 Christian Beier <dontmind@freeshell.org>
* : Merge pull request #137 from atalax/master Fix two heap buffer overflows
2016-11-18 Christian Beier <dontmind@freeshell.org>
* : Merge pull request #138 from stweil/master Fix some typos
2016-11-18 Stefan Weil <sw@weilnetz.de>
* README, common/zywrletemplate.c, examples/example.c,
examples/zippy.c: Fix some typos (it's / its) Signed-off-by: Stefan Weil <sw@weilnetz.de>
2016-11-14 Josef Gajdusek <atx@atx.name>
* libvncclient/ultra.c: Fix heap overflow in the ultra.c decoder The Ultra type tile decoder does not use the _safe variant of the
LZO decompress function, which allows a maliciuous server to
overwrite parts of the heap by sending a larger-than-specified LZO
data stream.
2016-11-14 Josef Gajdusek <atx@atx.name>
* libvncclient/rfbproto.c: Fix heap overflows in the various
rectangle fill functions Altough rfbproto.c does check whether the overall FramebufferUpdate
rectangle is too large, some of the individual encoding decoders do
not, which allows a malicious server to overwrite parts of the heap.
2016-09-24 Christian Beier <dontmind@freeshell.org>
* : Merge pull request #129 from bkylerussell/systemd Support systemd socket activation
2016-08-14 Zac Medico <zmedico@gmail.com>
* libvncserver/sockets.c: Support autoPort with ipv4 or ipv6
disabled Make it possible to get autoPort behavior with either ipv4 or ipv6
disabled, by setting rfbScreen->ipv6port or rfbScreen->port to a
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-05 Christian Beier <dontmind@freeshell.org>
* NEWS: Update NEWS.
2016-06-05 Christian Beier <dontmind@freeshell.org>
* rfb/rfbclient.h: Fix rfbClientSwap64IfLE broken in
fe7df89fb1777b4fd303d5a601541f6062caf8ea
2016-06-05 Christian Beier <dontmind@freeshell.org>
* : Merge pull request #84 from plettix/master fix for issue 81
2016-05-30 Christian Beier <cb@shoutrlabs.com>
* CMakeLists.txt: CMake: Add maybe-found OpenSSL libs to
libvncclient.
2016-05-30 Christian Beier <cb@shoutrlabs.com>
* CMakeLists.txt: CMake: Not all platforms have endian.h, so use the
build system's endianess check.
2016-05-30 Christian Beier <cb@shoutrlabs.com>
* rfb/rfbproto.h: Only include endian.h if present on system.
2016-05-30 Christian Beier <dontmind@freeshell.org>
* : Merge pull request #105 from cgeorges82/master fix for issue #97. Also, this fixes cmake builds for other
platforms.
2016-05-13 George Fleury <gfleury@gmail.com>
* libvncserver/sockets.c: Avoid calling SSL_pending when connection
is already closed Avoid calling SSL_pending when connection is already closed, calling
SSL_pending with connection already closed is crashing. To
reproduce, open a secure websocket binay protocol connection with
libvncserver compiled with OpenSSL, and when libvncserver is waiting
for rfbProcessClientProtocolVersion send any invalid char, it will
fail and call rfbCloseClient whith destroy all SSL context, calling
SSL_pending after that will generate a invalid access.
2016-04-24 Christian Beier <dontmind@freeshell.org>
* : Merge pull request #103 from rdieter/master use namespaced vnc_max macro (issue #102)
2016-04-23 gbdj <gbdj@users.noreply.github.com>
* libvncclient/tls_gnutls.c, libvncclient/vncviewer.c,
rfb/rfbclient.h: libvncclient/tls_gnutls.c: Add hooks to
WriteToTLS() for optional protection by mutex. Fix upstream issue
#100 Squashed commit of the pull request #101 : commit
1c7e01e81862bc46508e675e83c74cc6d63224b0 commit
1e749b094d6696380d3f0540a00138d7e3427874
2016-02-18 Rex Dieter <rdieter@math.unl.edu>
* libvncclient/listen.c, libvncserver/httpd.c,
libvncserver/rfbserver.c, libvncserver/sockets.c, rfb/rfbproto.h:
use namespaced rfbMax macro (issue #102) Not using generic 'max', avoids conflicts with stl_algobase.h
2016-04-15 Christian Beier <dontmind@freeshell.org>
* : Merge pull request #115 from solofox/master Enable AF_UNIX socket: ignore setsockopt TCP_NODELAY failure.
2016-04-13 Christian Beier <dontmind@freeshell.org>
* : Merge pull request #114 from zbierak/master Increase MAX_ENCODINGS value to accommodate more client encodings
2016-04-12 Christian Beier <dontmind@freeshell.org>
* : Merge pull request #110 from AlexejStukov/patch-1 break statement out of case
2016-04-12 zbierak <zbierak@users.noreply.github.com>
* libvncclient/rfbproto.c: Fix buffer overflow when applying client
encodings
2016-04-12 Christian Beier <cb@shoutrlabs.com>
* travis.yml: TravisCI: remove old config.
2016-04-12 Christian Beier <cb@shoutrlabs.com>
* .travis.yml: TravisCI: add autoreconf step.
2016-04-12 Christian Beier <cb@shoutrlabs.com>
* .travis.yml: TravisCI: the config starts with a dot!
2016-04-12 Christian Beier <cb@shoutrlabs.com>
* README, README.md: Add a README.md and and Travis CI status badge.
2016-04-12 Christian Beier <cb@shoutrlabs.com>
* travis.yml: Add a minimalistic config for Travis CI.
2016-04-08 Christian Beier <dontmind@freeshell.org>
* : Merge pull request #109 from zbierak/master Fix memory access error in camera.c example
2016-04-04 zbierak <zbierak@users.noreply.github.com>
* examples/camera.c: Fix memory access error in camera.c example
2016-03-05 Cédric 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>
* CMakeLists.txt: re-up comment
2016-03-05 Cédric Georges <cgeorges@edge-airport.com>
* CMakeLists.txt, rfb/rfbconfig.h.cmake: Append IPv6 option in CMake
Project
2016-01-27 Christian Beier <dontmind@freeshell.org>
* : Merge pull request #99 from spaceone/master Ignore null pointers in FillRectangle() and
CopyRectangleFromRectangle()
2016-01-27 SpaceOne <space@wechall.net>
* libvncclient/rfbproto.c: Ignore null pointers in FillRectangle()
and CopyRectangleFromRectangle()
2015-12-03 Christian Beier <cb@shoutrlabs.com>
* rfb/rfbclient.h: Be a bit clearer with the cursorshape
documentation for libvncclient.
2015-12-03 Christian Beier <cb@shoutrlabs.com>
* libvncclient/cursor.c, rfb/rfbclient.h: Properly document
HandleCursorShape and GotCursorShapeProc.
2015-10-10 Christian Beier <dontmind@freeshell.org>
* : Merge pull request #90 from stweil/fix Fix some recently introduced regressions
2015-10-10 Stefan Weil <sw@weilnetz.de>
* rfb/rfbproto.h: Fix definition of POSIX data types Commit 92f558482d94c5152174a1983a40863bd6b07911 added stdint.h to
get the type definitions, but included it after the first use of
int8_t in builds for Windows. Signed-off-by: Stefan Weil <sw@weilnetz.de>
2015-10-10 Stefan Weil <sw@weilnetz.de>
* rfb/rfbproto.h: Fix endianness detection Commit 97f442ef2aa65ade6bea11e90054c57b90abbaca tried to improve the
endianness detection, but introduced a typo and problems for Windows
builds (no endian.h, different definition of
LIBVNCSERVER_WORDS_BIGENDIAN). Fix both issues. Signed-off-by: Stefan Weil <sw@weilnetz.de>
2015-10-09 Stefan Weil <sw@weilnetz.de>
* ChangeLog, Doxyfile, NEWS, README, client_examples/vnc2mpg.c,
common/zywrletemplate.c, examples/camera.c, libvncclient/listen.c,
libvncclient/sockets.c, libvncserver/cargs.c, libvncserver/scale.c,
libvncserver/sockets.c, libvncserver/tight.c,
libvncserver/tightvnc-filetransfer/filetransfermsg.c,
libvncserver/tightvnc-filetransfer/handlefiletransferrequest.c,
libvncserver/tightvnc-filetransfer/rfbtightproto.h,
libvncserver/tightvnc-filetransfer/rfbtightserver.c,
libvncserver/ultra.c, libvncserver/zlib.c, rfb/keysym.h, rfb/rfb.h,
rfb/rfbproto.h, webclients/java-applet/ssl/README,
webclients/java-applet/ssl/proxy.vnc,
webclients/java-applet/ssl/ss_vncviewer,
webclients/java-applet/ssl/ultravnc-102-JavaViewer-ssl-etc.patch,
webclients/novnc/include/display.js,
webclients/novnc/include/rfb.js, webclients/novnc/include/ui.js: Fix
some typos (found by codespell) Signed-off-by: Stefan Weil <sw@weilnetz.de>
2015-07-22 plettix <plettix@gmail.com>
* common/md5.c: another shift fix
2015-07-22 plettix <plettix@gmail.com>
* rfb/rfb.h, rfb/rfbclient.h: shift fixes - if an integer is a
negative number then the return value of "Swap32IfLE" was -1
2015-07-07 plettix <plettix@gmail.com>
* libvncserver/websockets.c: fix for issue 81 use different buffers
for decode and encode
2015-05-28 Christian Beier <dontmind@freeshell.org>
* CMakeLists.txt, configure.ac, rfb/rfbproto.h: Instead of letting
the build system define endianess, rely on endian.h.
2015-05-28 Christian Beier <dontmind@freeshell.org>
* .gitignore, CMakeLists.txt, Doxyfile, Makefile.am, configure.ac,
libvncserver/Makefile.am, m4/ax_create_stdint_h.m4, rfb/rfbproto.h:
Do away with rfbint.h generation and use stdint.h directly instead.
2015-04-17 Christian Beier <dontmind@freeshell.org>
* libvncclient/rfbproto.c, libvncclient/vncviewer.c: Re-add the
useful bits of 9aa9ac59b4cb10bfca93456a3098e348de172d7f.
2015-04-17 Christian Beier <dontmind@freeshell.org>
* libvncclient/Makefile.am: Revert "Add libvncclient/h264.c to dist
tarball." This reverts commit 9aa9ac59b4cb10bfca93456a3098e348de172d7f.
2015-04-17 Christian Beier <dontmind@freeshell.org>
* 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
2015-04-17 Christian Beier <dontmind@freeshell.org>
* : Merge pull request #70 from maxnet/master httpd: disallow directory traversal
2015-04-17 Christian Beier <dontmind@freeshell.org>
* : Merge pull request #72 from lopago/fix-segfaults prevent segfaults due to uninitialized memory
2015-04-15 Thomas Anderson <tanderson@caltech.edu>
* configure.ac: configure.ac: Use AC_CHECK_TOOL for cross-compiling
support. When cross-compiling the ar program has the appropriate prefix
prepended. Respect that here and have autotools autodetect the
appropriate tool.
2015-04-13 Benjamin Dürholt <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>
* libvncserver/rfbssl_gnutls.c, libvncserver/tight.c: prevent
segfault
2015-03-29 Floris Bos <bos@je-eigen-domein.nl>
* libvncserver/httpd.c: httpd: disallow directory traversal Signed-off-by: Floris Bos <bos@je-eigen-domein.nl>
2015-03-27 Jay Carlson <nop@nop.com>
* libvncclient/rfbproto.c: Avoid divide-by-zero in raw encoding (OSX
RealVNC) OS X RealVNC server crashes out Remmina because the server can
provoke bytesPerLine to be zero. Assume this is coding for zero
lines. The condition could be checked before the calculation of
bytesPerLine. I dont understand the preconditions of this code
to say one way or the other.
2015-02-09 Peter Spiess-Knafl <psk@autistici.org>
* libvncclient/Makefile.am, libvncserver/Makefile.am: Set autotools
SOVERSION.
2015-02-05 Christian Beier <dontmind@freeshell.org>
* : Merge pull request #63 from LibVNC/sha1rework Replace SHA1 implementation with the one from RFC 6234.
2015-01-27 Christian Beier <dontmind@freeshell.org>
* : Merge pull request #60 from cinemast/master fixing SOVERSION and .so VERSION
2015-01-18 Christian Beier <dontmind@freeshell.org>
* webclients/index.vnc: Update link to project home page in
index.vnc.
2015-01-18 Christian Beier <dontmind@freeshell.org>
* : Merge pull request #57 from maxnet/master Fix handling of multiple VNC commands per websockets frame
2015-01-16 Christian Beier <dontmind@freeshell.org>
* : Merge pull request #56 from maxnet/master Only advertise xvp support when xvpHook is set
2015-01-06 Christian Beier <dontmind@freeshell.org>
* AUTHORS: Add Floris to AUTHORS.
2015-01-06 Christian Beier <dontmind@freeshell.org>
* NEWS: Update NEWS.
2015-01-02 Christian Beier <dontmind@freeshell.org>
* : Merge pull request #51 from maxnet/master Initialize libgcrypt before use
2015-01-02 Christian Beier <dontmind@freeshell.org>
* : Merge pull request #50 from maxnet/master tls_openssl.c: define _XOPEN_SOURCE for extra POSIX functionality
2014-12-30 Christian Beier <dontmind@freeshell.org>
* libvncclient/sockets.c: Fix another MinGW64 build issue.
WSAEWOULDBLOCK is not MinGW-specific.
2014-12-30 Christian Beier <dontmind@freeshell.org>
* libvncserver/rfbserver.c: Fix building with mingw-w64.
2014-12-30 Christian Beier <dontmind@freeshell.org>
* configure.ac: confgure.ac: Remove MinGW linker flag that's
incompatible with mingw-w64.
2014-12-30 Christian Beier <dontmind@freeshell.org>
* autogen.sh: autogen.sh: pass cmdline params to configure call.
2014-12-29 Christian Beier <dontmind@freeshell.org>
* : Merge pull request #49 from maxnet/master Fix libva related compile errors
2014-12-29 Floris Bos <bos@je-eigen-domein.nl>
* configure.ac, libvncclient/h264.c: Fix libva related compile
errors - Make h264.c compile with recent libva version by including
va_compat.h - Only enable libva if libva-x11 is installed - Modified configure help text Previous help text suggested libva was only build when
--with-libva was specified, while actual behavior is to build it
by default. Warning: THIS CODE IS UNTESTED. Lacking a h.264 capable VNC server
Also no attempt is made to support platforms not using X11 Signed-off-by: Floris Bos <bos@je-eigen-domein.nl>
2014-10-31 Christian Beier <dontmind@freeshell.org>
* README: Add VNCpp to projects using LibVNC.
2014-10-21 Christian Beier <dontmind@freeshell.org>
* ChangeLog: Update ChangeLog for 0.9.10.
2014-10-21 Christian Beier <dontmind@freeshell.org>
* NEWS: Update NEWS.

@ -292,7 +292,7 @@ TYPEDEF_HIDES_STRUCT = YES
# causing a significant performance penality.
# If the system has enough physical memory increasing the cache will improve the
# performance by keeping more symbols in memory. Note that the value works on
# a logarithmic scale so increasing the size by one will rougly double the
# a logarithmic scale so increasing the size by one will roughly double the
# memory usage. The cache size is given by this formula:
# 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0,
# corresponding to a cache size of 2^16 = 65536 symbols
@ -661,7 +661,6 @@ RECURSIVE = YES
# subdirectory from a directory tree whose root is specified with the INPUT tag.
EXCLUDE = rfb/rfbconfig.h \
rfb/rfbint.h \
rfb/default8x16.h
# The EXCLUDE_SYMLINKS tag can be used select whether or not files or

@ -2,7 +2,7 @@ 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/rfbint.h.cmake rfb/rfbconfig.h.cmake
EXTRA_DIST = CMakeLists.txt rfb/rfbconfig.h.cmake
bin_SCRIPTS = libvncserver-config
@ -10,9 +10,8 @@ pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = libvncserver.pc libvncclient.pc
includedir=$(prefix)/include/rfb
#include_HEADERS=rfb.h rfbconfig.h rfbint.h rfbproto.h keysym.h rfbregion.h
include_HEADERS=rfb/rfb.h rfb/rfbconfig.h rfb/rfbint.h rfb/rfbproto.h \
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

23
NEWS

@ -1,8 +1,27 @@
0.9.11
- Overall changes:
* LibVNCServer/LibVNCClient development now uses continous intregration,
provided by TravisCI.
- LibVNCClient:
* Now initializes libgcrypt before use if the application did not do it.
Fixes a crash when connection to Mac hosts
(https://github.com/LibVNC/libvncserver/issues/45).
* Various fixes that result in more stable handling of malicious or broken
servers.
* Removed broken and unmaintained H264 decoding.
* Some documentation fixes.
* Added hooks to WriteToTLS() for optional protection by mutex.
- LibVNCServer:
* Stability fixes for the WebSocket implementation.
* Replaced SHA1 implementation with the one from RFC 6234.
* The built-in HTTP server does not allow directory traversals anymore.
* The built-in HTTP now sends correct MIME types for CSS and SVG.
* Added support for systemd socket activation.
* Made it possible to get autoPort behavior with either ipv4 or ipv6
disabled.
* Fixed starting of an onHold-client in threaded mode.
0.9.10
- Overall changes:
@ -80,7 +99,7 @@
* Implemented xvp VNC extension.
* Updated minilzo library used for Ultra encoding to ver 2.04.
According to the minilzo README, this brings a significant
speedup on 64-bit architechtures.
speedup on 64-bit architectures.
- LibVNCServer:
* Thread safety for ZRLE, Zlib, Tight, RRE, CoRRE and Ultra encodings.
@ -131,7 +150,7 @@
- Print this string out to stdout: 'PORT=XXXX' (usually XXXX = 5900).
Combining with -bg, easy to write a ssh/rsh wrapper with something like:
port=`ssh $host "x11vnc -bg .."` then run vncviewer based on $port output.
(tunneling the vnc traffic thru ssh a bit more messy, but doable)
(tunneling the vnc traffic through ssh a bit more messy, but doable)
- Quite a bit of code to be more careful when doing 8bpp indexed color, e.g.
not assuming NCOLORS is 256, handling 8bit TrueColor and Direct Color, etc

@ -1,3 +1,5 @@
[![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
@ -24,7 +26,7 @@ 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 everytime you click, there is some bigger blot,
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
@ -32,7 +34,7 @@ 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 everytime the mouse moves, the cursor is
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
@ -112,11 +114,11 @@ Before you draw something, be sure to call
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 everytime an update is sent. LibVNCServer handles
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
defaultPtrAddEvent(buttonMask,x,y,cl);
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.
@ -182,7 +184,7 @@ kbdReleaseAllKeys(rfbClientPtr cl)
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
defaultPtrAddEvent(buttonMask,x,y,cl)
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.
@ -246,7 +248,7 @@ 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
it's clock rate was higher than that of my C64. This was my first experience
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
@ -257,7 +259,7 @@ 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 it's own problems (security as well as 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!
@ -323,8 +325,8 @@ 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 everytime annoying again, is that they don't do it right. Every
concept has it's new name (remember what enumerators used to be until
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.)
@ -332,11 +334,13 @@ 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,
@ -391,7 +395,7 @@ 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 it's parents very proud. As well they can be! To protect
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.

@ -0,0 +1 @@
README

@ -23,10 +23,6 @@
#include <gdk/gdkkeysyms.h>
#include <rfb/rfbclient.h>
#ifdef LIBVNCSERVER_CONFIG_LIBVA
#include <gdk/gdkx.h>
#endif
static rfbClient *cl;
static gchar *server_cut_text = NULL;
static gboolean framebuffer_allocated = FALSE;
@ -61,14 +57,6 @@ static gboolean expose_event (GtkWidget *widget,
cl->format.greenMax = (1 << image->visual->green_prec) - 1;
cl->format.blueMax = (1 << image->visual->blue_prec) - 1;
#ifdef LIBVNCSERVER_CONFIG_LIBVA
/* Allow libvncclient to use a more efficient way
* of putting the framebuffer on the screen when
* using the H.264 format.
*/
cl->outputWindow = GDK_WINDOW_XID(widget->window);
#endif
SetFormatAndEncodings (cl);
framebuffer_allocated = TRUE;
@ -79,14 +67,12 @@ static gboolean expose_event (GtkWidget *widget,
gdk_cursor_unref( cur );
}
#ifndef LIBVNCSERVER_CONFIG_LIBVA
gdk_draw_image (GDK_DRAWABLE (widget->window),
widget->style->fg_gc[gtk_widget_get_state(widget)],
image,
event->area.x, event->area.y,
event->area.x, event->area.y,
event->area.width, event->area.height);
#endif
return FALSE;
}
@ -476,12 +462,10 @@ static void update (rfbClient *cl, int x, int y, int w, int h) {
dialog_connecting = NULL;
}
#ifndef LIBVNCSERVER_CONFIG_LIBVA
GtkWidget *drawing_area = rfbClientGetClientData (cl, gtk_init);
if (drawing_area != NULL)
gtk_widget_queue_draw_area (drawing_area, x, y, w, h);
#endif
}
static void kbd_leds (rfbClient *cl, int value, int pad) {

@ -85,11 +85,11 @@ AVStream *add_video_stream(AVFormatContext *oc, int codec_id, int w, int h)
}
if (c->codec_id == CODEC_ID_MPEG1VIDEO){
/* needed to avoid using macroblocks in which some coeffs overflow
this doesnt happen with normal video, it just happens here as the
motion of the chroma plane doesnt match the luma plane */
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;
}
/* some formats want stream headers to be seperate */
/* 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;

@ -46,7 +46,7 @@
#ifdef WORDS_BIGENDIAN
# define SWAP(n) \
(((n) << 24) | (((n) & 0xff00) << 8) | (((n) >> 8) & 0xff00) | ((n) >> 24))
((((n) & 0x00ff) << 24) | (((n) & 0xff00) << 8) | (((n) >> 8) & 0xff00) | (((n) >> 24) & 0x00ff))
#else
# define SWAP(n) (n)
#endif

@ -0,0 +1,29 @@
/************************ sha-private.h ************************/
/***************** See RFC 6234 for details. *******************/
#ifndef _SHA_PRIVATE__H
#define _SHA_PRIVATE__H
/*
* These definitions are defined in FIPS 180-3, section 4.1.
* Ch() and Maj() are defined identically in sections 4.1.1,
* 4.1.2, and 4.1.3.
*
* The definitions used in FIPS 180-3 are as follows:
*/
#ifndef USE_MODIFIED_MACROS
#define SHA_Ch(x,y,z) (((x) & (y)) ^ ((~(x)) & (z)))
#define SHA_Maj(x,y,z) (((x) & (y)) ^ ((x) & (z)) ^ ((y) & (z)))
#else /* USE_MODIFIED_MACROS */
/*
* The following definitions are equivalent and potentially faster.
*/
#define SHA_Ch(x, y, z) (((x) & ((y) ^ (z))) ^ (z))
#define SHA_Maj(x, y, z) (((x) & ((y) | (z))) | ((y) & (z)))
#endif /* USE_MODIFIED_MACROS */
#define SHA_Parity(x, y, z) ((x) ^ (y) ^ (z))
#endif /* _SHA_PRIVATE__H */

@ -0,0 +1,358 @@
/**************************** sha.h ****************************/
/***************** See RFC 6234 for details. *******************/
/*
Copyright (c) 2011 IETF Trust and the persons identified as
authors of the code. 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.
- Neither the name of Internet Society, IETF or IETF Trust, nor
the names of specific contributors, may be used to endorse or
promote products derived from this software without specific
prior written permission.
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 OWNER 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 _SHA_H_
#define _SHA_H_
/*
* Description:
* This file implements the Secure Hash Algorithms
* as defined in the U.S. National Institute of Standards
* and Technology Federal Information Processing Standards
* Publication (FIPS PUB) 180-3 published in October 2008
* and formerly defined in its predecessors, FIPS PUB 180-1
* and FIP PUB 180-2.
*
* A combined document showing all algorithms is available at
* http://csrc.nist.gov/publications/fips/
* fips180-3/fips180-3_final.pdf
*
* The five hashes are defined in these sizes:
* SHA-1 20 byte / 160 bit
* SHA-224 28 byte / 224 bit
* SHA-256 32 byte / 256 bit
* SHA-384 48 byte / 384 bit
* SHA-512 64 byte / 512 bit
*
* Compilation Note:
* These files may be compiled with two options:
* USE_32BIT_ONLY - use 32-bit arithmetic only, for systems
* without 64-bit integers
*
* USE_MODIFIED_MACROS - use alternate form of the SHA_Ch()
* and SHA_Maj() macros that are equivalent
* and potentially faster on many systems
*
*/
#include <stdint.h>
/*
* If you do not have the ISO standard stdint.h header file, then you
* must typedef the following:
* name meaning
* uint64_t unsigned 64-bit integer
* uint32_t unsigned 32-bit integer
* uint8_t unsigned 8-bit integer (i.e., unsigned char)
* int_least16_t integer of >= 16 bits
*
* See stdint-example.h
*/
#ifndef _SHA_enum_
#define _SHA_enum_
/*
* All SHA functions return one of these values.
*/
enum {
shaSuccess = 0,
shaNull, /* Null pointer parameter */
shaInputTooLong, /* input data too long */
shaStateError, /* called Input after FinalBits or Result */
shaBadParam /* passed a bad parameter */
};
#endif /* _SHA_enum_ */
/*
* These constants hold size information for each of the SHA
* hashing operations
*/
enum {
SHA1_Message_Block_Size = 64, SHA224_Message_Block_Size = 64,
SHA256_Message_Block_Size = 64, SHA384_Message_Block_Size = 128,
SHA512_Message_Block_Size = 128,
USHA_Max_Message_Block_Size = SHA512_Message_Block_Size,
SHA1HashSize = 20, SHA224HashSize = 28, SHA256HashSize = 32,
SHA384HashSize = 48, SHA512HashSize = 64,
USHAMaxHashSize = SHA512HashSize,
SHA1HashSizeBits = 160, SHA224HashSizeBits = 224,
SHA256HashSizeBits = 256, SHA384HashSizeBits = 384,
SHA512HashSizeBits = 512, USHAMaxHashSizeBits = SHA512HashSizeBits
};
/*
* These constants are used in the USHA (Unified SHA) functions.
*/
typedef enum SHAversion {
SHA1, SHA224, SHA256, SHA384, SHA512
} SHAversion;
/*
* This structure will hold context information for the SHA-1
* hashing operation.
*/
typedef struct SHA1Context {
uint32_t Intermediate_Hash[SHA1HashSize/4]; /* Message Digest */
uint32_t Length_High; /* Message length in bits */
uint32_t Length_Low; /* Message length in bits */
int_least16_t Message_Block_Index; /* Message_Block array index */
/* 512-bit message blocks */
uint8_t Message_Block[SHA1_Message_Block_Size];
int Computed; /* Is the hash computed? */
int Corrupted; /* Cumulative corruption code */
} SHA1Context;
/*
* This structure will hold context information for the SHA-256
* hashing operation.
*/
typedef struct SHA256Context {
uint32_t Intermediate_Hash[SHA256HashSize/4]; /* Message Digest */
uint32_t Length_High; /* Message length in bits */
uint32_t Length_Low; /* Message length in bits */
int_least16_t Message_Block_Index; /* Message_Block array index */
/* 512-bit message blocks */
uint8_t Message_Block[SHA256_Message_Block_Size];
int Computed; /* Is the hash computed? */
int Corrupted; /* Cumulative corruption code */
} SHA256Context;
/*
* This structure will hold context information for the SHA-512
* hashing operation.
*/
typedef struct SHA512Context {
#ifdef USE_32BIT_ONLY
uint32_t Intermediate_Hash[SHA512HashSize/4]; /* Message Digest */
uint32_t Length[4]; /* Message length in bits */
#else /* !USE_32BIT_ONLY */
uint64_t Intermediate_Hash[SHA512HashSize/8]; /* Message Digest */
uint64_t Length_High, Length_Low; /* Message length in bits */
#endif /* USE_32BIT_ONLY */
int_least16_t Message_Block_Index; /* Message_Block array index */
/* 1024-bit message blocks */
uint8_t Message_Block[SHA512_Message_Block_Size];
int Computed; /* Is the hash computed?*/
int Corrupted; /* Cumulative corruption code */
} SHA512Context;
/*
* This structure will hold context information for the SHA-224
* hashing operation. It uses the SHA-256 structure for computation.
*/
typedef struct SHA256Context SHA224Context;
/*
* This structure will hold context information for the SHA-384
* hashing operation. It uses the SHA-512 structure for computation.
*/
typedef struct SHA512Context SHA384Context;
/*
* This structure holds context information for all SHA
* hashing operations.
*/
typedef struct USHAContext {
int whichSha; /* which SHA is being used */
union {
SHA1Context sha1Context;
SHA224Context sha224Context; SHA256Context sha256Context;
SHA384Context sha384Context; SHA512Context sha512Context;
} ctx;
} USHAContext;
/*
* This structure will hold context information for the HMAC
* keyed-hashing operation.
*/
typedef struct HMACContext {
int whichSha; /* which SHA is being used */
int hashSize; /* hash size of SHA being used */
int blockSize; /* block size of SHA being used */
USHAContext shaContext; /* SHA context */
unsigned char k_opad[USHA_Max_Message_Block_Size];
/* outer padding - key XORd with opad */
int Computed; /* Is the MAC computed? */
int Corrupted; /* Cumulative corruption code */
} HMACContext;
/*
* This structure will hold context information for the HKDF
* extract-and-expand Key Derivation Functions.
*/
typedef struct HKDFContext {
int whichSha; /* which SHA is being used */
HMACContext hmacContext;
int hashSize; /* hash size of SHA being used */
unsigned char prk[USHAMaxHashSize];
/* pseudo-random key - output of hkdfInput */
int Computed; /* Is the key material computed? */
int Corrupted; /* Cumulative corruption code */
} HKDFContext;
/*
* Function Prototypes
*/
/* SHA-1 */
extern int SHA1Reset(SHA1Context *);
extern int SHA1Input(SHA1Context *, const uint8_t *bytes,
unsigned int bytecount);
extern int SHA1FinalBits(SHA1Context *, uint8_t bits,
unsigned int bit_count);
extern int SHA1Result(SHA1Context *,
uint8_t Message_Digest[SHA1HashSize]);
/* SHA-224 */
extern int SHA224Reset(SHA224Context *);
extern int SHA224Input(SHA224Context *, const uint8_t *bytes,
unsigned int bytecount);
extern int SHA224FinalBits(SHA224Context *, uint8_t bits,
unsigned int bit_count);
extern int SHA224Result(SHA224Context *,
uint8_t Message_Digest[SHA224HashSize]);
/* SHA-256 */
extern int SHA256Reset(SHA256Context *);
extern int SHA256Input(SHA256Context *, const uint8_t *bytes,
unsigned int bytecount);
extern int SHA256FinalBits(SHA256Context *, uint8_t bits,
unsigned int bit_count);
extern int SHA256Result(SHA256Context *,
uint8_t Message_Digest[SHA256HashSize]);
/* SHA-384 */
extern int SHA384Reset(SHA384Context *);
extern int SHA384Input(SHA384Context *, const uint8_t *bytes,
unsigned int bytecount);
extern int SHA384FinalBits(SHA384Context *, uint8_t bits,
unsigned int bit_count);
extern int SHA384Result(SHA384Context *,
uint8_t Message_Digest[SHA384HashSize]);
/* SHA-512 */
extern int SHA512Reset(SHA512Context *);
extern int SHA512Input(SHA512Context *, const uint8_t *bytes,
unsigned int bytecount);
extern int SHA512FinalBits(SHA512Context *, uint8_t bits,
unsigned int bit_count);
extern int SHA512Result(SHA512Context *,
uint8_t Message_Digest[SHA512HashSize]);
/* Unified SHA functions, chosen by whichSha */
extern int USHAReset(USHAContext *context, SHAversion whichSha);
extern int USHAInput(USHAContext *context,
const uint8_t *bytes, unsigned int bytecount);
extern int USHAFinalBits(USHAContext *context,
uint8_t bits, unsigned int bit_count);
extern int USHAResult(USHAContext *context,
uint8_t Message_Digest[USHAMaxHashSize]);
extern int USHABlockSize(enum SHAversion whichSha);
extern int USHAHashSize(enum SHAversion whichSha);
extern int USHAHashSizeBits(enum SHAversion whichSha);
extern const char *USHAHashName(enum SHAversion whichSha);
/*
* HMAC Keyed-Hashing for Message Authentication, RFC 2104,
* for all SHAs.
* This interface allows a fixed-length text input to be used.
*/
extern int hmac(SHAversion whichSha, /* which SHA algorithm to use */
const unsigned char *text, /* pointer to data stream */
int text_len, /* length of data stream */
const unsigned char *key, /* pointer to authentication key */
int key_len, /* length of authentication key */
uint8_t digest[USHAMaxHashSize]); /* caller digest to fill in */
/*
* HMAC Keyed-Hashing for Message Authentication, RFC 2104,
* for all SHAs.
* This interface allows any length of text input to be used.
*/
extern int hmacReset(HMACContext *context, enum SHAversion whichSha,
const unsigned char *key, int key_len);
extern int hmacInput(HMACContext *context, const unsigned char *text,
int text_len);
extern int hmacFinalBits(HMACContext *context, uint8_t bits,
unsigned int bit_count);
extern int hmacResult(HMACContext *context,
uint8_t digest[USHAMaxHashSize]);
/*
* HKDF HMAC-based Extract-and-Expand Key Derivation Function,
* RFC 5869, for all SHAs.
*/
extern int hkdf(SHAversion whichSha, const unsigned char *salt,
int salt_len, const unsigned char *ikm, int ikm_len,
const unsigned char *info, int info_len,
uint8_t okm[ ], int okm_len);
extern int hkdfExtract(SHAversion whichSha, const unsigned char *salt,
int salt_len, const unsigned char *ikm,
int ikm_len, uint8_t prk[USHAMaxHashSize]);
extern int hkdfExpand(SHAversion whichSha, const uint8_t prk[ ],
int prk_len, const unsigned char *info,
int info_len, uint8_t okm[ ], int okm_len);
/*
* HKDF HMAC-based Extract-and-Expand Key Derivation Function,
* RFC 5869, for all SHAs.
* This interface allows any length of text input to be used.
*/
extern int hkdfReset(HKDFContext *context, enum SHAversion whichSha,
const unsigned char *salt, int salt_len);
extern int hkdfInput(HKDFContext *context, const unsigned char *ikm,
int ikm_len);
extern int hkdfFinalBits(HKDFContext *context, uint8_t ikm_bits,
unsigned int ikm_bit_count);
extern int hkdfResult(HKDFContext *context,
uint8_t prk[USHAMaxHashSize],
const unsigned char *info, int info_len,
uint8_t okm[USHAMaxHashSize], int okm_len);
#endif /* _SHA_H_ */

@ -1,73 +1,66 @@
/*
* Copyright (C) The Internet Society (2001). All Rights Reserved.
*
* This document and translations of it may be copied and furnished to
* others, and derivative works that comment on or otherwise explain it
* or assist in its implementation may be prepared, copied, published
* and distributed, in whole or in part, without restriction of any
* kind, provided that the above copyright notice and this paragraph are
* included on all such copies and derivative works. However, this
* document itself may not be modified in any way, such as by removing
* the copyright notice or references to the Internet Society or other
* Internet organizations, except as needed for the purpose of
* developing Internet standards in which case the procedures for
* copyrights defined in the Internet Standards process must be
* followed, or as required to translate it into languages other than
* English.
*
* The limited permissions granted above are perpetual and will not be
* revoked by the Internet Society or its successors or assigns.
*
* This document and the information contained herein is provided on an
* "AS IS" basis and THE INTERNET SOCIETY AND THE INTERNET ENGINEERING
* TASK FORCE DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
* BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
* HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
* MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
*/
/**************************** sha1.c ***************************/
/***************** See RFC 6234 for details. *******************/
/* Copyright (c) 2011 IETF Trust and the persons identified as */
/* authors of the code. All rights reserved. */
/* See sha.h for terms of use and redistribution. */
/*
* sha1.c
*
* Description:
* This file implements the Secure Hashing Algorithm 1 as
* defined in FIPS PUB 180-1 published April 17, 1995.
* This file implements the Secure Hash Algorithm SHA-1
* as defined in the U.S. National Institute of Standards
* and Technology Federal Information Processing Standards
* Publication (FIPS PUB) 180-3 published in October 2008
* and formerly defined in its predecessors, FIPS PUB 180-1
* and FIP PUB 180-2.
*
* The SHA-1, produces a 160-bit message digest for a given
* data stream. It should take about 2**n steps to find a
* message with the same digest as a given message and
* 2**(n/2) to find any two messages with the same digest,
* when n is the digest size in bits. Therefore, this
* algorithm can serve as a means of providing a
* A combined document showing all algorithms is available at
* http://csrc.nist.gov/publications/fips/
* fips180-3/fips180-3_final.pdf
*
* The SHA-1 algorithm produces a 160-bit message digest for a
* given data stream that can serve as a means of providing a
* "fingerprint" for a message.
*
* Portability Issues:
* SHA-1 is defined in terms of 32-bit "words". This code
* uses <stdint.h> (included via "sha1.h" to define 32 and 8
* bit unsigned integer types. If your C compiler does not
* support 32 bit unsigned integers, this code is not
* uses <stdint.h> (included via "sha.h") to define 32- and
* 8-bit unsigned integer types. If your C compiler does
* not support 32-bit unsigned integers, this code is not
* appropriate.
*
* Caveats:
* SHA-1 is designed to work with messages less than 2^64 bits
* long. Although SHA-1 allows a message digest to be generated
* for messages of any number of bits less than 2^64, this
* implementation only works with messages with a length that is
* a multiple of the size of an 8-bit character.
*
* long. This implementation uses SHA1Input() to hash the bits
* that are a multiple of the size of an 8-bit octet, and then
* optionally uses SHA1FinalBits() to hash the final few bits of
* the input.
*/
#include "sha1.h"
#include "sha.h"
#include "sha-private.h"
/*
* Define the SHA1 circular left shift macro
*/
#define SHA1CircularShift(bits,word) \
#define SHA1_ROTL(bits,word) \
(((word) << (bits)) | ((word) >> (32-(bits))))
/* Local Function Prototyptes */
void SHA1PadMessage(SHA1Context *);
void SHA1ProcessMessageBlock(SHA1Context *);
/*
* Add "length" to the length.
* Set Corrupted when overflow has occurred.
*/
static uint32_t addTemp;
#define SHA1AddLength(context, length) \
(addTemp = (context)->Length_Low, \
(context)->Corrupted = \
(((context)->Length_Low += (length)) < addTemp) && \
(++(context)->Length_High == 0) ? shaInputTooLong \
: (context)->Corrupted )
/* Local Function Prototypes */
static void SHA1ProcessMessageBlock(SHA1Context *context);
static void SHA1Finalize(SHA1Context *context, uint8_t Pad_Byte);
static void SHA1PadMessage(SHA1Context *context, uint8_t Pad_Byte);
/*
* SHA1Reset
@ -86,15 +79,12 @@ void SHA1ProcessMessageBlock(SHA1Context *);
*/
int SHA1Reset(SHA1Context *context)
{
if (!context)
{
return shaNull;
}
if (!context) return shaNull;
context->Length_Low = 0;
context->Length_High = 0;
context->Length_High = context->Length_Low = 0;
context->Message_Block_Index = 0;
/* Initial Hash Values: FIPS 180-3 section 5.3.1 */
context->Intermediate_Hash[0] = 0x67452301;
context->Intermediate_Hash[1] = 0xEFCDAB89;
context->Intermediate_Hash[2] = 0x98BADCFE;
@ -102,133 +92,138 @@ int SHA1Reset(SHA1Context *context)
context->Intermediate_Hash[4] = 0xC3D2E1F0;
context->Computed = 0;
context->Corrupted = 0;
context->Corrupted = shaSuccess;
return shaSuccess;
}
/*
* SHA1Result
* SHA1Input
*
* Description:
* This function will return the 160-bit message digest into the
* Message_Digest array provided by the caller.
* NOTE: The first octet of hash is stored in the 0th element,
* the last octet of hash in the 19th element.
* This function accepts an array of octets as the next portion
* of the message.
*
* Parameters:
* context: [in/out]
* The context to use to calculate the SHA-1 hash.
* Message_Digest: [out]
* Where the digest is returned.
* The SHA context to update.
* message_array[ ]: [in]
* An array of octets representing the next portion of
* the message.
* length: [in]
* The length of the message in message_array.
*
* Returns:
* sha Error Code.
*
*/
int SHA1Result( SHA1Context *context,
uint8_t Message_Digest[SHA1HashSize])
int SHA1Input(SHA1Context *context,
const uint8_t *message_array, unsigned length)
{
int i;
if (!context || !Message_Digest)
{
return shaNull;
}
if (!context) return shaNull;
if (!length) return shaSuccess;
if (!message_array) return shaNull;
if (context->Computed) return context->Corrupted = shaStateError;
if (context->Corrupted) return context->Corrupted;
if (context->Corrupted)
{
return context->Corrupted;
}
while (length--) {
context->Message_Block[context->Message_Block_Index++] =
*message_array;
if (!context->Computed)
{
SHA1PadMessage(context);
for(i=0; i<64; ++i)
{
/* message may be sensitive, clear it out */
context->Message_Block[i] = 0;
}
context->Length_Low = 0; /* and clear length */
context->Length_High = 0;
context->Computed = 1;
}
if ((SHA1AddLength(context, 8) == shaSuccess) &&
(context->Message_Block_Index == SHA1_Message_Block_Size))
SHA1ProcessMessageBlock(context);
for(i = 0; i < SHA1HashSize; ++i)
{
Message_Digest[i] = context->Intermediate_Hash[i>>2]
>> 8 * ( 3 - ( i & 0x03 ) );
message_array++;
}
return shaSuccess;
return context->Corrupted;
}
/*
* SHA1Input
* SHA1FinalBits
*
* Description:
* This function accepts an array of octets as the next portion
* of the message.
* This function will add in any final bits of the message.
*
* Parameters:
* context: [in/out]
* The SHA context to update
* message_array: [in]
* An array of characters representing the next portion of
* the message.
* The SHA context to update.
* message_bits: [in]
* The final bits of the message, in the upper portion of the
* byte. (Use 0b###00000 instead of 0b00000### to input the
* three bits ###.)
* length: [in]
* The length of the message in message_array
* The number of bits in message_bits, between 1 and 7.
*
* Returns:
* sha Error Code.
*
*/
int SHA1Input( SHA1Context *context,
const uint8_t *message_array,
unsigned length)
int SHA1FinalBits(SHA1Context *context, uint8_t message_bits,
unsigned int length)
{
if (!length)
{
return shaSuccess;
}
static uint8_t masks[8] = {
/* 0 0b00000000 */ 0x00, /* 1 0b10000000 */ 0x80,
/* 2 0b11000000 */ 0xC0, /* 3 0b11100000 */ 0xE0,
/* 4 0b11110000 */ 0xF0, /* 5 0b11111000 */ 0xF8,
/* 6 0b11111100 */ 0xFC, /* 7 0b11111110 */ 0xFE
};
if (!context || !message_array)
{
return shaNull;
}
static uint8_t markbit[8] = {
/* 0 0b10000000 */ 0x80, /* 1 0b01000000 */ 0x40,
/* 2 0b00100000 */ 0x20, /* 3 0b00010000 */ 0x10,
/* 4 0b00001000 */ 0x08, /* 5 0b00000100 */ 0x04,
/* 6 0b00000010 */ 0x02, /* 7 0b00000001 */ 0x01
};
if (context->Computed)
{
context->Corrupted = shaStateError;
return shaStateError;
}
if (!context) return shaNull;
if (!length) return shaSuccess;
if (context->Corrupted) return context->Corrupted;
if (context->Computed) return context->Corrupted = shaStateError;
if (length >= 8) return context->Corrupted = shaBadParam;
SHA1AddLength(context, length);
SHA1Finalize(context,
(uint8_t) ((message_bits & masks[length]) | markbit[length]));
if (context->Corrupted)
{
return context->Corrupted;
}
while(length-- && !context->Corrupted)
{
context->Message_Block[context->Message_Block_Index++] =
(*message_array & 0xFF);
context->Length_Low += 8;
if (context->Length_Low == 0)
{
context->Length_High++;
if (context->Length_High == 0)
{
/* Message is too long */
context->Corrupted = 1;
}
}
}
if (context->Message_Block_Index == 64)
{
SHA1ProcessMessageBlock(context);
}
/*
* SHA1Result
*
* Description:
* This function will return the 160-bit message digest
* into the Message_Digest array provided by the caller.
* NOTE:
* The first octet of hash is stored in the element with index 0,
* the last octet of hash in the element with index 19.
*
* Parameters:
* context: [in/out]
* The context to use to calculate the SHA-1 hash.
* Message_Digest[ ]: [out]
* Where the digest is returned.
*
* Returns:
* sha Error Code.
*
*/
int SHA1Result(SHA1Context *context,
uint8_t Message_Digest[SHA1HashSize])
{
int i;
message_array++;
}
if (!context) return shaNull;
if (!Message_Digest) return shaNull;
if (context->Corrupted) return context->Corrupted;
if (!context->Computed)
SHA1Finalize(context, 0x80);
for (i = 0; i < SHA1HashSize; ++i)
Message_Digest[i] = (uint8_t) (context->Intermediate_Hash[i>>2]
>> (8 * ( 3 - ( i & 0x03 ) )));
return shaSuccess;
}
@ -237,11 +232,12 @@ int SHA1Input( SHA1Context *context,
* SHA1ProcessMessageBlock
*
* Description:
* This function will process the next 512 bits of the message
* stored in the Message_Block array.
* This helper function will process the next 512 bits of the
* message stored in the Message_Block array.
*
* Parameters:
* None.
* context: [in/out]
* The SHA context to update.
*
* Returns:
* Nothing.
@ -249,18 +245,15 @@ int SHA1Input( SHA1Context *context,
* Comments:
* Many of the variable names in this code, especially the
* single character names, were used because those were the
* names used in the publication.
*
*
* names used in the Secure Hash Standard.
*/
void SHA1ProcessMessageBlock(SHA1Context *context)
static void SHA1ProcessMessageBlock(SHA1Context *context)
{
const uint32_t K[] = { /* Constants defined in SHA-1 */
0x5A827999,
0x6ED9EBA1,
0x8F1BBCDC,
0xCA62C1D6
/* Constants defined in FIPS 180-3, section 4.2.1 */
const uint32_t K[4] = {
0x5A827999, 0x6ED9EBA1, 0x8F1BBCDC, 0xCA62C1D6
};
int t; /* Loop counter */
uint32_t temp; /* Temporary word value */
uint32_t W[80]; /* Word sequence */
@ -269,18 +262,15 @@ void SHA1ProcessMessageBlock(SHA1Context *context)
/*
* Initialize the first 16 words in the array W
*/
for(t = 0; t < 16; t++)
{
W[t] = context->Message_Block[t * 4] << 24;
W[t] |= context->Message_Block[t * 4 + 1] << 16;
W[t] |= context->Message_Block[t * 4 + 2] << 8;
W[t] |= context->Message_Block[t * 4 + 3];
for (t = 0; t < 16; t++) {
W[t] = ((uint32_t)context->Message_Block[t * 4]) << 24;
W[t] |= ((uint32_t)context->Message_Block[t * 4 + 1]) << 16;
W[t] |= ((uint32_t)context->Message_Block[t * 4 + 2]) << 8;
W[t] |= ((uint32_t)context->Message_Block[t * 4 + 3]);
}
for(t = 16; t < 80; t++)
{
W[t] = SHA1CircularShift(1,W[t-3] ^ W[t-8] ^ W[t-14] ^ W[t-16]);
}
for (t = 16; t < 80; t++)
W[t] = SHA1_ROTL(1, W[t-3] ^ W[t-8] ^ W[t-14] ^ W[t-16]);
A = context->Intermediate_Hash[0];
B = context->Intermediate_Hash[1];
@ -288,44 +278,38 @@ void SHA1ProcessMessageBlock(SHA1Context *context)
D = context->Intermediate_Hash[3];
E = context->Intermediate_Hash[4];
for(t = 0; t < 20; t++)
{
temp = SHA1CircularShift(5,A) +
((B & C) | ((~B) & D)) + E + W[t] + K[0];
for (t = 0; t < 20; t++) {
temp = SHA1_ROTL(5,A) + SHA_Ch(B, C, D) + E + W[t] + K[0];
E = D;
D = C;
C = SHA1CircularShift(30,B);
C = SHA1_ROTL(30,B);
B = A;
A = temp;
}
for(t = 20; t < 40; t++)
{
temp = SHA1CircularShift(5,A) + (B ^ C ^ D) + E + W[t] + K[1];
for (t = 20; t < 40; t++) {
temp = SHA1_ROTL(5,A) + SHA_Parity(B, C, D) + E + W[t] + K[1];
E = D;
D = C;
C = SHA1CircularShift(30,B);
C = SHA1_ROTL(30,B);
B = A;
A = temp;
}
for(t = 40; t < 60; t++)
{
temp = SHA1CircularShift(5,A) +
((B & C) | (B & D) | (C & D)) + E + W[t] + K[2];
for (t = 40; t < 60; t++) {
temp = SHA1_ROTL(5,A) + SHA_Maj(B, C, D) + E + W[t] + K[2];
E = D;
D = C;
C = SHA1CircularShift(30,B);
C = SHA1_ROTL(30,B);
B = A;
A = temp;
}
for(t = 60; t < 80; t++)
{
temp = SHA1CircularShift(5,A) + (B ^ C ^ D) + E + W[t] + K[3];
for (t = 60; t < 80; t++) {
temp = SHA1_ROTL(5,A) + SHA_Parity(B, C, D) + E + W[t] + K[3];
E = D;
D = C;
C = SHA1CircularShift(30,B);
C = SHA1_ROTL(30,B);
B = A;
A = temp;
}
@ -335,35 +319,65 @@ void SHA1ProcessMessageBlock(SHA1Context *context)
context->Intermediate_Hash[2] += C;
context->Intermediate_Hash[3] += D;
context->Intermediate_Hash[4] += E;
context->Message_Block_Index = 0;
}
/*
* SHA1Finalize
*
* Description:
* This helper function finishes off the digest calculations.
*
* Parameters:
* context: [in/out]
* The SHA context to update.
* Pad_Byte: [in]
* The last byte to add to the message block before the 0-padding
* and length. This will contain the last bits of the message
* followed by another single bit. If the message was an
* exact multiple of 8-bits long, Pad_Byte will be 0x80.
*
* Returns:
* sha Error Code.
*
*/
static void SHA1Finalize(SHA1Context *context, uint8_t Pad_Byte)
{
int i;
SHA1PadMessage(context, Pad_Byte);
/* message may be sensitive, clear it out */
for (i = 0; i < SHA1_Message_Block_Size; ++i)
context->Message_Block[i] = 0;
context->Length_High = 0; /* and clear length */
context->Length_Low = 0;
context->Computed = 1;
}
/*
* SHA1PadMessage
*
* Description:
* According to the standard, the message must be padded to an even
* 512 bits. The first padding bit must be a '1'. The last 64
* bits represent the length of the original message. All bits in
* between should be 0. This function will pad the message
* according to those rules by filling the Message_Block array
* accordingly. It will also call the ProcessMessageBlock function
* provided appropriately. When it returns, it can be assumed that
* the message digest has been computed.
* According to the standard, the message must be padded to the next
* even multiple of 512 bits. The first padding bit must be a '1'.
* The last 64 bits represent the length of the original message.
* All bits in between should be 0. This helper function will pad
* the message according to those rules by filling the Message_Block
* array accordingly. When it returns, it can be assumed that the
* message digest has been computed.
*
* Parameters:
* context: [in/out]
* The context to pad
* ProcessMessageBlock: [in]
* The appropriate SHA*ProcessMessageBlock function
* The context to pad.
* Pad_Byte: [in]
* The last byte to add to the message block before the 0-padding
* and length. This will contain the last bits of the message
* followed by another single bit. If the message was an
* exact multiple of 8-bits long, Pad_Byte will be 0x80.
*
* Returns:
* Nothing.
*
*/
void SHA1PadMessage(SHA1Context *context)
static void SHA1PadMessage(SHA1Context *context, uint8_t Pad_Byte)
{
/*
* Check to see if the current message block is too small to hold
@ -371,41 +385,30 @@ void SHA1PadMessage(SHA1Context *context)
* block, process it, and then continue padding into a second
* block.
*/
if (context->Message_Block_Index > 55)
{
context->Message_Block[context->Message_Block_Index++] = 0x80;
while(context->Message_Block_Index < 64)
{
if (context->Message_Block_Index >= (SHA1_Message_Block_Size - 8)) {
context->Message_Block[context->Message_Block_Index++] = Pad_Byte;
while (context->Message_Block_Index < SHA1_Message_Block_Size)
context->Message_Block[context->Message_Block_Index++] = 0;
}
SHA1ProcessMessageBlock(context);
} else
context->Message_Block[context->Message_Block_Index++] = Pad_Byte;
while(context->Message_Block_Index < 56)
{
context->Message_Block[context->Message_Block_Index++] = 0;
}
}
else
{
context->Message_Block[context->Message_Block_Index++] = 0x80;
while(context->Message_Block_Index < 56)
{
while (context->Message_Block_Index < (SHA1_Message_Block_Size - 8))
context->Message_Block[context->Message_Block_Index++] = 0;
}
}
/*
* Store the message length as the last 8 octets
*/
context->Message_Block[56] = context->Length_High >> 24;
context->Message_Block[57] = context->Length_High >> 16;
context->Message_Block[58] = context->Length_High >> 8;
context->Message_Block[59] = context->Length_High;
context->Message_Block[60] = context->Length_Low >> 24;
context->Message_Block[61] = context->Length_Low >> 16;
context->Message_Block[62] = context->Length_Low >> 8;
context->Message_Block[63] = context->Length_Low;
context->Message_Block[56] = (uint8_t) (context->Length_High >> 24);
context->Message_Block[57] = (uint8_t) (context->Length_High >> 16);
context->Message_Block[58] = (uint8_t) (context->Length_High >> 8);
context->Message_Block[59] = (uint8_t) (context->Length_High);
context->Message_Block[60] = (uint8_t) (context->Length_Low >> 24);
context->Message_Block[61] = (uint8_t) (context->Length_Low >> 16);
context->Message_Block[62] = (uint8_t) (context->Length_Low >> 8);
context->Message_Block[63] = (uint8_t) (context->Length_Low);
SHA1ProcessMessageBlock(context);
}

@ -1,101 +0,0 @@
/*
* Copyright (C) The Internet Society (2001). All Rights Reserved.
*
* This document and translations of it may be copied and furnished to
* others, and derivative works that comment on or otherwise explain it
* or assist in its implementation may be prepared, copied, published
* and distributed, in whole or in part, without restriction of any
* kind, provided that the above copyright notice and this paragraph are
* included on all such copies and derivative works. However, this
* document itself may not be modified in any way, such as by removing
* the copyright notice or references to the Internet Society or other
* Internet organizations, except as needed for the purpose of
* developing Internet standards in which case the procedures for
* copyrights defined in the Internet Standards process must be
* followed, or as required to translate it into languages other than
* English.
*
* The limited permissions granted above are perpetual and will not be
* revoked by the Internet Society or its successors or assigns.
*
* This document and the information contained herein is provided on an
* "AS IS" basis and THE INTERNET SOCIETY AND THE INTERNET ENGINEERING
* TASK FORCE DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
* BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
* HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
* MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
*/
/*
* sha1.h
*
* Description:
* This is the header file for code which implements the Secure
* Hashing Algorithm 1 as defined in FIPS PUB 180-1 published
* April 17, 1995.
*
* Many of the variable names in this code, especially the
* single character names, were used because those were the names
* used in the publication.
*
* Please read the file sha1.c for more information.
*
*/
#ifndef _SHA1_H_
#define _SHA1_H_
#include <stdint.h>
/*
* If you do not have the ISO standard stdint.h header file, then you
* must typdef the following:
* name meaning
* uint32_t unsigned 32 bit integer
* uint8_t unsigned 8 bit integer (i.e., unsigned char)
* int_least16_t integer of >= 16 bits
*
*/
#ifndef _SHA_enum_
#define _SHA_enum_
enum
{
shaSuccess = 0,
shaNull, /* Null pointer parameter */
shaInputTooLong, /* input data too long */
shaStateError /* called Input after Result */
};
#endif
#define SHA1HashSize 20
/*
* This structure will hold context information for the SHA-1
* hashing operation
*/
typedef struct SHA1Context
{
uint32_t Intermediate_Hash[SHA1HashSize/4]; /* Message Digest */
uint32_t Length_Low; /* Message length in bits */
uint32_t Length_High; /* Message length in bits */
/* Index into message block array */
int_least16_t Message_Block_Index;
uint8_t Message_Block[64]; /* 512-bit message blocks */
int Computed; /* Is the digest computed? */
int Corrupted; /* Is the message digest corrupted? */
} SHA1Context;
/*
* Function Prototypes
*/
int SHA1Reset( SHA1Context *);
int SHA1Input( SHA1Context *,
const uint8_t *,
unsigned int);
int SHA1Result( SHA1Context *,
uint8_t Message_Digest[SHA1HashSize]);
#endif

@ -9,7 +9,7 @@
* *
* THE 'ZYWRLE' VNC CODEC SOURCE CODE IS (C) COPYRIGHT 2006 *
* BY Hitachi Systems & Services, Ltd. *
* (Noriaki Yamazaki, Research & Developement Center) * *
* (Noriaki Yamazaki, Research & Development Center) * *
* *
********************************************************************
Redistribution and use in source and binary forms, with or without
@ -352,7 +352,7 @@ static InlineX void Harr(signed char* pX0, signed char* pX1)
In this method, H/L and X0/X1 is always same position.
This lead us to more speed and less memory.
Of cause, the result of both method is quite same
because it's only difference that coefficient position.
because its only difference is that coefficient position.
*/
static InlineX void WaveletLevel(int* data, int size, int l, int SkipPixel)
{

@ -1,5 +1,5 @@
# Process this file with autoconf to produce a configure script.
AC_INIT(LibVNCServer, 0.9.10, https://github.com/LibVNC/libvncserver)
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)
@ -10,7 +10,7 @@ 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, 10, LibVNCServer patchlevel)
AC_DEFINE(VERSION_PATCHLEVEL, 11, LibVNCServer patchlevel)
# Checks for programs.
AC_PROG_CC
@ -24,13 +24,13 @@ test "x$GCC" = "xyes" && CFLAGS="$CFLAGS -Wall"
AC_PROG_MAKE_SET
AC_LIBTOOL_WIN32_DLL
AC_PROG_LIBTOOL
AC_PATH_PROG([AR], [ar], [/usr/bin/ar],
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-filetransfer disable TightVNC file transfer protocol],
[ --without-tightvnc-filetransfer disable TightVNC file transfer protocol],
, [ with_tightvnc_filetransfer=yes ])
# AC_DEFINE moved to after libpthread check.
@ -68,6 +68,9 @@ if test ! -z "$with_ffmpeg"; then
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")
@ -149,18 +152,6 @@ AC_SUBST(SSL_LIBS)
AM_CONDITIONAL(HAVE_LIBSSL, test ! -z "$SSL_LIBS")
# See if we want libva support
AH_TEMPLATE(CONFIG_LIBVA, [Build libva support])
AC_ARG_WITH(libva,
[ --without-libva disable support for libva],,)
if test "x$with_libva" != "xno"; then
AC_CHECK_LIB(va-x11, vaGetDisplay,
VA_LIBS="-lva -lva-x11"
[AC_DEFINE(CONFIG_LIBVA) CONFIG_LIBVA="true"], ,)
fi
AC_SUBST(VA_LIBS)
AM_CONDITIONAL(CONFIG_LIBVA, test ! -z "$VA_LIBS")
AC_ARG_WITH(jpeg,
@ -510,21 +501,15 @@ 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 string.h sys/endian.h sys/socket.h sys/time.h sys/timeb.h syslog.h unistd.h ws2tcpip.h])
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_C_BIGENDIAN
AC_TYPE_SIZE_T
AC_HEADER_TIME
AC_HEADER_SYS_WAIT
AX_TYPE_SOCKLEN_T
if test ! -d ./rfb; then
echo "creating subdir ./rfb for rfbint.h"
mkdir ./rfb
fi
AX_CREATE_STDINT_H(rfb/rfbint.h)
AC_CACHE_CHECK([for in_addr_t],
vnc_cv_inaddrt, [
AC_TRY_COMPILE([#include <sys/types.h>

@ -16,7 +16,7 @@
* Christian Daschill
*
*
* Answer: Originally, I thought about using seperate threads and using a
* Answer: Originally, I thought about using separate threads and using a
* mutex to determine when the frame buffer was being accessed by any client
* so we could determine a safe time to take a picture. The probem is, we
* are lock-stepping everything with framebuffer access. Why not be a
@ -31,7 +31,7 @@
* as the libvncserver should not stall on transmitting to any single
* client.
*
* Another solution would be to provide a seperate framebuffer for each
* Another solution would be to provide a separate framebuffer for each
* client and use mutexes to determine if any particular client is ready for
* a snapshot. This way, your not updating a framebuffer for a slow client
* while it is being transferred.
@ -104,7 +104,7 @@ int TakePicture(unsigned char *buffer)
*/
gettimeofday(&now,NULL);
line = now.tv_usec / (1000000/HEIGHT);
if (line>HEIGHT) line=HEIGHT-1;
if (line>=HEIGHT) line=HEIGHT-1;
memset(&buffer[(WIDTH * BPP) * line], 0, (WIDTH * BPP));
/* frames per second (informational only) */

@ -56,7 +56,7 @@ static void initBuffer(unsigned char* buffer)
}
}
/* Here we create a structure so that every client has it's own pointer */
/* Here we create a structure so that every client has its own pointer */
typedef struct ClientData {
rfbBool oldButton;

@ -7,7 +7,7 @@
static int maxx=400, maxy=400, bpp=4;
/* odd maxx doesn't work (vncviewer bug) */
/* Here we create a structure so that every client has it's own pointer */
/* Here we create a structure so that every client has its own pointer */
/* turns the framebuffer black */
void blank_framebuffer(char* frame_buffer, int x1, int y1, int x2, int y2);

@ -14,16 +14,16 @@ endif
libvncclient_la_SOURCES=cursor.c listen.c rfbproto.c sockets.c vncviewer.c ../common/minilzo.c $(TLSSRCS)
libvncclient_la_LIBADD=$(TLSLIBS) $(VA_LIBS)
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 h264.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

@ -37,12 +37,6 @@
<< client->format.blueShift)
/*********************************************************************
* HandleCursorShape(). Support for XCursor and RichCursor shape
* updates. We emulate cursor operating on the frame buffer (that is
* why we call it "software cursor").
********************************************************************/
rfbBool HandleCursorShape(rfbClient* client,int xhot, int yhot, int width, int height, uint32_t enc)
{
int bytesPerPixel;

@ -1,648 +0,0 @@
/*
* Copyright (C) 2012 Intel Corporation. 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_CONFIG_LIBVA
#include <X11/Xlib.h>
#include <va/va_version.h>
#if VA_CHECK_VERSION(0,34,0)
#include <va/va_compat.h>
#endif
#include <va/va_x11.h>
enum _slice_types {
SLICE_TYPE_P = 0, /* Predicted */
SLICE_TYPE_B = 1, /* Bi-predicted */
SLICE_TYPE_I = 2, /* Intra coded */
};
#define SURFACE_NUM 7
VADisplay va_dpy = NULL;
VAConfigID va_config_id;
VASurfaceID va_surface_id[SURFACE_NUM];
VAContextID va_context_id = 0;
VABufferID va_pic_param_buf_id[SURFACE_NUM];
VABufferID va_mat_param_buf_id[SURFACE_NUM];
VABufferID va_sp_param_buf_id[SURFACE_NUM];
VABufferID va_d_param_buf_id[SURFACE_NUM];
static int cur_height = 0;
static int cur_width = 0;
static unsigned int num_frames = 0;
static int sid = 0;
static unsigned int frame_id = 0;
static int field_order_count = 0;
static VASurfaceID curr_surface = VA_INVALID_ID;
VAStatus gva_status;
VASurfaceStatus gsurface_status;
#define CHECK_SURF(X) \
gva_status = vaQuerySurfaceStatus(va_dpy, X, &gsurface_status); \
if (gsurface_status != 4) printf("ss: %d\n", gsurface_status);
#ifdef _DEBUG
#define DebugLog(A) rfbClientLog A
#else
#define DebugLog(A)
#endif
#define CHECK_VASTATUS(va_status,func) \
if (va_status != VA_STATUS_SUCCESS) { \
/*fprintf(stderr,"%s:%s (%d) failed,exit\n", __func__, func, __LINE__);*/ \
rfbClientErr("%s:%s:%d failed (0x%x),exit\n", __func__, func, __LINE__, va_status); \
exit(1); \
} else { \
/*fprintf(stderr,">> SUCCESS for: %s:%s (%d)\n", __func__, func, __LINE__);*/ \
DebugLog(("%s:%s:%d success\n", __func__, func, __LINE__)); \
}
/*
* Forward declarations
*/
static void h264_decode_frame(int f_width, int f_height, char *framedata, int framesize, int slice_type);
static void SetVAPictureParameterBufferH264(VAPictureParameterBufferH264 *p, int width, int height);
static void SetVASliceParameterBufferH264(VASliceParameterBufferH264 *p);
static void SetVASliceParameterBufferH264_Intra(VASliceParameterBufferH264 *p, int first);
static void put_updated_rectangle(rfbClient *client, int x, int y, int width, int height, int f_width, int f_height, int first_for_frame);
static void nv12_to_rgba(const VAImage vaImage, rfbClient *client, int ch_x, int ch_y, int ch_w, int ch_h);
/* FIXME: get this value from the server instead of hardcoding 32bit pixels */
#define BPP (4 * 8)
static const char *string_of_FOURCC(uint32_t fourcc)
{
static int buf;
static char str[2][5];
buf ^= 1;
str[buf][0] = fourcc;
str[buf][1] = fourcc >> 8;
str[buf][2] = fourcc >> 16;
str[buf][3] = fourcc >> 24;
str[buf][4] = '\0';
return str[buf];
}
static inline const char *string_of_VAImageFormat(VAImageFormat *imgfmt)
{
return string_of_FOURCC(imgfmt->fourcc);
}
static rfbBool
HandleH264 (rfbClient* client, int rx, int ry, int rw, int rh)
{
rfbH264Header hdr;
char *framedata;
DebugLog(("Framebuffer update with H264 (x: %d, y: %d, w: %d, h: %d)\n", rx, ry, rw, rh));
/* First, read the frame size and allocate buffer to store the data */
if (!ReadFromRFBServer(client, (char *)&hdr, sz_rfbH264Header))
return FALSE;
hdr.slice_type = rfbClientSwap32IfLE(hdr.slice_type);
hdr.nBytes = rfbClientSwap32IfLE(hdr.nBytes);
hdr.width = rfbClientSwap32IfLE(hdr.width);
hdr.height = rfbClientSwap32IfLE(hdr.height);
framedata = (char*) malloc(hdr.nBytes);
/* Obtain frame data from the server */
DebugLog(("Reading %d bytes of frame data (type: %d)\n", hdr.nBytes, hdr.slice_type));
if (!ReadFromRFBServer(client, framedata, hdr.nBytes))
return FALSE;
/* First make sure we have a large enough raw buffer to hold the
* decompressed data. In practice, with a fixed BPP, 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 < (( rw * rh ) * ( BPP / 8 ))) {
if ( client->raw_buffer != NULL ) {
free( client->raw_buffer );
}
client->raw_buffer_size = (( rw * rh ) * ( BPP / 8 ));
client->raw_buffer = (char*) malloc( client->raw_buffer_size );
rfbClientLog("Allocated raw buffer of %d bytes (%dx%dx%d BPP)\n", client->raw_buffer_size, rw, rh, BPP);
}
/* Decode frame if frame data was sent. Server only sends frame data for the first
* framebuffer update message for a particular frame buffer contents.
* If more than 1 rectangle is updated, the messages after the first one (with
* the H.264 frame) have nBytes == 0.
*/
if (hdr.nBytes > 0) {
DebugLog((" decoding %d bytes of H.264 data\n", hdr.nBytes));
h264_decode_frame(hdr.width, hdr.height, framedata, hdr.nBytes, hdr.slice_type);
}
DebugLog((" updating rectangle (%d, %d)-(%d, %d)\n", rx, ry, rw, rh));
put_updated_rectangle(client, rx, ry, rw, rh, hdr.width, hdr.height, hdr.nBytes != 0);
free(framedata);
return TRUE;
}
static void h264_cleanup_decoder()
{
VAStatus va_status;
rfbClientLog("%s()\n", __FUNCTION__);
if (va_surface_id[0] != VA_INVALID_ID) {
va_status = vaDestroySurfaces(va_dpy, &va_surface_id[0], SURFACE_NUM);
CHECK_VASTATUS(va_status, "vaDestroySurfaces");
}
if (va_context_id) {
va_status = vaDestroyContext(va_dpy, va_context_id);
CHECK_VASTATUS(va_status, "vaDestroyContext");
va_context_id = 0;
}
num_frames = 0;
sid = 0;
frame_id = 0;
field_order_count = 0;
}
static void h264_init_decoder(int width, int height)
{
VAStatus va_status;
if (va_context_id) {
rfbClientLog("%s: va_dpy already initialized\n", __FUNCTION__);
}
if (va_dpy != NULL) {
rfbClientLog("%s: Re-initializing H.264 decoder\n", __FUNCTION__);
}
else {
rfbClientLog("%s: initializing H.264 decoder\n", __FUNCTION__);
/* Attach VA display to local X display */
Display *win_display = (Display *)XOpenDisplay(":0.0");
if (win_display == NULL) {
rfbClientErr("Can't connect to local display\n");
exit(-1);
}
int major_ver, minor_ver;
va_dpy = vaGetDisplay(win_display);
va_status = vaInitialize(va_dpy, &major_ver, &minor_ver);
CHECK_VASTATUS(va_status, "vaInitialize");
rfbClientLog("%s: libva version %d.%d found\n", __FUNCTION__, major_ver, minor_ver);
}
/* Check for VLD entrypoint */
int num_entrypoints;
VAEntrypoint entrypoints[5];
int vld_entrypoint_found = 0;
/* Change VAProfileH264High if needed */
VAProfile profile = VAProfileH264High;
va_status = vaQueryConfigEntrypoints(va_dpy, profile, entrypoints, &num_entrypoints);
CHECK_VASTATUS(va_status, "vaQueryConfigEntrypoints");
int i;
for (i = 0; i < num_entrypoints; ++i) {
if (entrypoints[i] == VAEntrypointVLD) {
vld_entrypoint_found = 1;
break;
}
}
if (vld_entrypoint_found == 0) {
rfbClientErr("VLD entrypoint not found\n");
exit(1);
}
/* Create configuration for the decode pipeline */
VAConfigAttrib attrib;
attrib.type = VAConfigAttribRTFormat;
va_status = vaCreateConfig(va_dpy, profile, VAEntrypointVLD, &attrib, 1, &va_config_id);
CHECK_VASTATUS(va_status, "vaCreateConfig");
/* Create VA surfaces */
for (i = 0; i < SURFACE_NUM; ++i) {
va_surface_id[i] = VA_INVALID_ID;
va_pic_param_buf_id[i] = VA_INVALID_ID;
va_mat_param_buf_id[i] = VA_INVALID_ID;
va_sp_param_buf_id[i] = VA_INVALID_ID;
va_d_param_buf_id[i] = VA_INVALID_ID;
}
va_status = vaCreateSurfaces(va_dpy, width, height, VA_RT_FORMAT_YUV420, SURFACE_NUM, &va_surface_id[0]);
CHECK_VASTATUS(va_status, "vaCreateSurfaces");
for (i = 0; i < SURFACE_NUM; ++i) {
DebugLog(("%s: va_surface_id[%d] = %p\n", __FUNCTION__, i, va_surface_id[i]));
}
/* Create VA context */
va_status = vaCreateContext(va_dpy, va_config_id, width, height, 0/*VA_PROGRESSIVE*/, &va_surface_id[0], SURFACE_NUM, &va_context_id);
CHECK_VASTATUS(va_status, "vaCreateContext");
DebugLog(("%s: VA context created (id: %d)\n", __FUNCTION__, va_context_id));
/* Instantiate decode pipeline */
va_status = vaBeginPicture(va_dpy, va_context_id, va_surface_id[0]);
CHECK_VASTATUS(va_status, "vaBeginPicture");
rfbClientLog("%s: H.264 decoder initialized\n", __FUNCTION__);
}
static void h264_decode_frame(int f_width, int f_height, char *framedata, int framesize, int slice_type)
{
VAStatus va_status;
DebugLog(("%s: called for frame of %d bytes (%dx%d) slice_type=%d\n", __FUNCTION__, framesize, width, height, slice_type));
/* Initialize decode pipeline if necessary */
if ( (f_width > cur_width) || (f_height > cur_height) ) {
if (va_dpy != NULL)
h264_cleanup_decoder();
cur_width = f_width;
cur_height = f_height;
h264_init_decoder(f_width, f_height);
rfbClientLog("%s: decoder initialized\n", __FUNCTION__);
}
/* Decode frame */
static VAPictureH264 va_picture_h264, va_old_picture_h264;
/* The server should always send an I-frame when a new client connects
* or when the resolution of the framebuffer changes, but we check
* just in case.
*/
if ( (slice_type != SLICE_TYPE_I) && (num_frames == 0) ) {
rfbClientLog("First frame is not an I frame !!! Skipping!!!\n");
return;
}
DebugLog(("%s: frame_id=%d va_surface_id[%d]=0x%x field_order_count=%d\n", __FUNCTION__, frame_id, sid, va_surface_id[sid], field_order_count));
va_picture_h264.picture_id = va_surface_id[sid];
va_picture_h264.frame_idx = frame_id;
va_picture_h264.flags = 0;
va_picture_h264.BottomFieldOrderCnt = field_order_count;
va_picture_h264.TopFieldOrderCnt = field_order_count;
/* Set up picture parameter buffer */
if (va_pic_param_buf_id[sid] == VA_INVALID_ID) {
va_status = vaCreateBuffer(va_dpy, va_context_id, VAPictureParameterBufferType, sizeof(VAPictureParameterBufferH264), 1, NULL, &va_pic_param_buf_id[sid]);
CHECK_VASTATUS(va_status, "vaCreateBuffer(PicParam)");
}
CHECK_SURF(va_surface_id[sid]);
VAPictureParameterBufferH264 *pic_param_buf = NULL;
va_status = vaMapBuffer(va_dpy, va_pic_param_buf_id[sid], (void **)&pic_param_buf);
CHECK_VASTATUS(va_status, "vaMapBuffer(PicParam)");
SetVAPictureParameterBufferH264(pic_param_buf, f_width, f_height);
memcpy(&pic_param_buf->CurrPic, &va_picture_h264, sizeof(VAPictureH264));
if (slice_type == SLICE_TYPE_P) {
memcpy(&pic_param_buf->ReferenceFrames[0], &va_old_picture_h264, sizeof(VAPictureH264));
pic_param_buf->ReferenceFrames[0].flags = 0;
}
else if (slice_type != SLICE_TYPE_I) {
rfbClientLog("Frame type %d not supported!!!\n");
return;
}
pic_param_buf->frame_num = frame_id;
va_status = vaUnmapBuffer(va_dpy, va_pic_param_buf_id[sid]);
CHECK_VASTATUS(va_status, "vaUnmapBuffer(PicParam)");
/* Set up IQ matrix buffer */
if (va_mat_param_buf_id[sid] == VA_INVALID_ID) {
va_status = vaCreateBuffer(va_dpy, va_context_id, VAIQMatrixBufferType, sizeof(VAIQMatrixBufferH264), 1, NULL, &va_mat_param_buf_id[sid]);
CHECK_VASTATUS(va_status, "vaCreateBuffer(IQMatrix)");
}
CHECK_SURF(va_surface_id[sid]);
VAIQMatrixBufferH264 *iq_matrix_buf = NULL;
va_status = vaMapBuffer(va_dpy, va_mat_param_buf_id[sid], (void **)&iq_matrix_buf);
CHECK_VASTATUS(va_status, "vaMapBuffer(IQMatrix)");
static const unsigned char m_MatrixBufferH264[]= {
/* ScalingList4x4[6][16] */
0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,
0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,
0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,
0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,
0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,
0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,
/* ScalingList8x8[2][64] */
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
};
memcpy(iq_matrix_buf, m_MatrixBufferH264, 224);
va_status = vaUnmapBuffer(va_dpy, va_mat_param_buf_id[sid]);
CHECK_VASTATUS(va_status, "vaUnmapBuffer(IQMatrix)");
VABufferID buffer_ids[2];
buffer_ids[0] = va_pic_param_buf_id[sid];
buffer_ids[1] = va_mat_param_buf_id[sid];
CHECK_SURF(va_surface_id[sid]);
va_status = vaRenderPicture(va_dpy, va_context_id, buffer_ids, 2);
CHECK_VASTATUS(va_status, "vaRenderPicture");
/* Set up slice parameter buffer */
if (va_sp_param_buf_id[sid] == VA_INVALID_ID) {
va_status = vaCreateBuffer(va_dpy, va_context_id, VASliceParameterBufferType, sizeof(VASliceParameterBufferH264), 1, NULL, &va_sp_param_buf_id[sid]);
CHECK_VASTATUS(va_status, "vaCreateBuffer(SliceParam)");
}
CHECK_SURF(va_surface_id[sid]);
VASliceParameterBufferH264 *slice_param_buf = NULL;
va_status = vaMapBuffer(va_dpy, va_sp_param_buf_id[sid], (void **)&slice_param_buf);
CHECK_VASTATUS(va_status, "vaMapBuffer(SliceParam)");
static int t2_first = 1;
if (slice_type == SLICE_TYPE_I) {
SetVASliceParameterBufferH264_Intra(slice_param_buf, t2_first);
t2_first = 0;
} else {
SetVASliceParameterBufferH264(slice_param_buf);
memcpy(&slice_param_buf->RefPicList0[0], &va_old_picture_h264, sizeof(VAPictureH264));
slice_param_buf->RefPicList0[0].flags = 0;
}
slice_param_buf->slice_data_bit_offset = 0;
slice_param_buf->slice_data_size = framesize;
va_status = vaUnmapBuffer(va_dpy, va_sp_param_buf_id[sid]);
CHECK_VASTATUS(va_status, "vaUnmapBuffer(SliceParam)");
CHECK_SURF(va_surface_id[sid]);
/* Set up slice data buffer and copy H.264 encoded data */
if (va_d_param_buf_id[sid] == VA_INVALID_ID) {
/* TODO use estimation matching framebuffer dimensions instead of this large value */
va_status = vaCreateBuffer(va_dpy, va_context_id, VASliceDataBufferType, 4177920, 1, NULL, &va_d_param_buf_id[sid]); /* 1080p size */
CHECK_VASTATUS(va_status, "vaCreateBuffer(SliceData)");
}
char *slice_data_buf;
va_status = vaMapBuffer(va_dpy, va_d_param_buf_id[sid], (void **)&slice_data_buf);
CHECK_VASTATUS(va_status, "vaMapBuffer(SliceData)");
memcpy(slice_data_buf, framedata, framesize);
CHECK_SURF(va_surface_id[sid]);
va_status = vaUnmapBuffer(va_dpy, va_d_param_buf_id[sid]);
CHECK_VASTATUS(va_status, "vaUnmapBuffer(SliceData)");
buffer_ids[0] = va_sp_param_buf_id[sid];
buffer_ids[1] = va_d_param_buf_id[sid];
CHECK_SURF(va_surface_id[sid]);
va_status = vaRenderPicture(va_dpy, va_context_id, buffer_ids, 2);
CHECK_VASTATUS(va_status, "vaRenderPicture");
va_status = vaEndPicture(va_dpy, va_context_id);
CHECK_VASTATUS(va_status, "vaEndPicture");
/* Prepare next one... */
int sid_new = (sid + 1) % SURFACE_NUM;
DebugLog(("%s: new Surface ID = %d\n", __FUNCTION__, sid_new));
va_status = vaBeginPicture(va_dpy, va_context_id, va_surface_id[sid_new]);
CHECK_VASTATUS(va_status, "vaBeginPicture");
/* Get decoded data */
va_status = vaSyncSurface(va_dpy, va_surface_id[sid]);
CHECK_VASTATUS(va_status, "vaSyncSurface");
CHECK_SURF(va_surface_id[sid]);
curr_surface = va_surface_id[sid];
sid = sid_new;
field_order_count += 2;
++frame_id;
if (frame_id > 15) {
frame_id = 0;
}
++num_frames;
memcpy(&va_old_picture_h264, &va_picture_h264, sizeof(VAPictureH264));
}
static void put_updated_rectangle(rfbClient *client, int x, int y, int width, int height, int f_width, int f_height, int first_for_frame)
{
if (curr_surface == VA_INVALID_ID) {
rfbClientErr("%s: called, but current surface is invalid\n", __FUNCTION__);
return;
}
VAStatus va_status;
if (client->outputWindow) {
/* use efficient vaPutSurface() method of putting the framebuffer on the screen */
if (first_for_frame) {
/* vaPutSurface() clears window contents outside the given destination rectangle => always update full screen. */
va_status = vaPutSurface(va_dpy, curr_surface, client->outputWindow, 0, 0, f_width, f_height, 0, 0, f_width, f_height, NULL, 0, VA_FRAME_PICTURE);
CHECK_VASTATUS(va_status, "vaPutSurface");
}
}
else if (client->frameBuffer) {
/* ... or copy the changed framebuffer region manually as a fallback */
VAImage decoded_image;
decoded_image.image_id = VA_INVALID_ID;
decoded_image.buf = VA_INVALID_ID;
va_status = vaDeriveImage(va_dpy, curr_surface, &decoded_image);
CHECK_VASTATUS(va_status, "vaDeriveImage");
if ((decoded_image.image_id == VA_INVALID_ID) || (decoded_image.buf == VA_INVALID_ID)) {
rfbClientErr("%s: vaDeriveImage() returned success but VA image is invalid (id: %d, buf: %d)\n", __FUNCTION__, decoded_image.image_id, decoded_image.buf);
}
nv12_to_rgba(decoded_image, client, x, y, width, height);
va_status = vaDestroyImage(va_dpy, decoded_image.image_id);
CHECK_VASTATUS(va_status, "vaDestroyImage");
}
}
static void SetVAPictureParameterBufferH264(VAPictureParameterBufferH264 *p, int width, int height)
{
int i;
unsigned int width_in_mbs = (width + 15) / 16;
unsigned int height_in_mbs = (height + 15) / 16;
memset(p, 0, sizeof(VAPictureParameterBufferH264));
p->picture_width_in_mbs_minus1 = width_in_mbs - 1;
p->picture_height_in_mbs_minus1 = height_in_mbs - 1;
p->num_ref_frames = 1;
p->seq_fields.value = 145;
p->pic_fields.value = 0x501;
for (i = 0; i < 16; i++) {
p->ReferenceFrames[i].flags = VA_PICTURE_H264_INVALID;
p->ReferenceFrames[i].picture_id = 0xffffffff;
}
}
static void SetVASliceParameterBufferH264(VASliceParameterBufferH264 *p)
{
int i;
memset(p, 0, sizeof(VASliceParameterBufferH264));
p->slice_data_size = 0;
p->slice_data_bit_offset = 64;
p->slice_alpha_c0_offset_div2 = 2;
p->slice_beta_offset_div2 = 2;
p->chroma_weight_l0_flag = 1;
p->chroma_weight_l0[0][0]=1;
p->chroma_offset_l0[0][0]=0;
p->chroma_weight_l0[0][1]=1;
p->chroma_offset_l0[0][1]=0;
p->luma_weight_l1_flag = 1;
p->chroma_weight_l1_flag = 1;
p->luma_weight_l0[0]=0x01;
for (i = 0; i < 32; i++) {
p->RefPicList0[i].flags = VA_PICTURE_H264_INVALID;
p->RefPicList1[i].flags = VA_PICTURE_H264_INVALID;
}
p->RefPicList1[0].picture_id = 0xffffffff;
}
static void SetVASliceParameterBufferH264_Intra(VASliceParameterBufferH264 *p, int first)
{
int i;
memset(p, 0, sizeof(VASliceParameterBufferH264));
p->slice_data_size = 0;
p->slice_data_bit_offset = 64;
p->slice_alpha_c0_offset_div2 = 2;
p->slice_beta_offset_div2 = 2;
p->slice_type = 2;
if (first) {
p->luma_weight_l0_flag = 1;
p->chroma_weight_l0_flag = 1;
p->luma_weight_l1_flag = 1;
p->chroma_weight_l1_flag = 1;
} else {
p->chroma_weight_l0_flag = 1;
p->chroma_weight_l0[0][0]=1;
p->chroma_offset_l0[0][0]=0;
p->chroma_weight_l0[0][1]=1;
p->chroma_offset_l0[0][1]=0;
p->luma_weight_l1_flag = 1;
p->chroma_weight_l1_flag = 1;
p->luma_weight_l0[0]=0x01;
}
for (i = 0; i < 32; i++) {
p->RefPicList0[i].flags = VA_PICTURE_H264_INVALID;
p->RefPicList1[i].flags = VA_PICTURE_H264_INVALID;
}
p->RefPicList1[0].picture_id = 0xffffffff;
p->RefPicList0[0].picture_id = 0xffffffff;
}
static void nv12_to_rgba(const VAImage vaImage, rfbClient *client, int ch_x, int ch_y, int ch_w, int ch_h)
{
DebugLog(("%s: converting region (%d, %d)-(%d, %d) from NV12->RGBA\n", __FUNCTION__, ch_x, ch_y, ch_w, ch_h));
VAStatus va_status;
uint8_t *nv12_buf;
va_status = vaMapBuffer(va_dpy, vaImage.buf, (void **)&nv12_buf);
CHECK_VASTATUS(va_status, "vaMapBuffer(DecodedData)");
/* adjust x, y, width, height of the affected area so
* x, y, width and height are always even.
*/
if (ch_x % 2) { --ch_x; ++ch_w; }
if (ch_y % 2) { --ch_y; ++ch_h; }
if ((ch_x + ch_w) % 2) { ++ch_w; }
if ((ch_y + ch_h) % 2) { ++ch_h; }
/* point nv12_buf and dst to upper left corner of changed area */
uint8_t *nv12_y = &nv12_buf[vaImage.offsets[0] + vaImage.pitches[0] * ch_y + ch_x];
uint8_t *nv12_uv = &nv12_buf[vaImage.offsets[1] + vaImage.pitches[1] * (ch_y / 2) + ch_x];
uint32_t *dst = &((uint32_t*)client->frameBuffer)[client->width * ch_y + ch_x];
/* TODO: optimize R, G, B calculation. Possible ways to do this:
* - use lookup tables
* - convert from floating point to integer arithmetic
* - use MMX/SSE to vectorize calculations
* - use GPU (VA VPP, shader...)
*/
int src_x, src_y;
for (src_y = 0; src_y < ch_h; src_y += 2) {
for (src_x = 0; src_x < ch_w; src_x += 2) {
uint8_t nv_u = nv12_uv[src_x];
uint8_t nv_v = nv12_uv[src_x + 1];
uint8_t nv_y[4] = { nv12_y[ src_x], nv12_y[ src_x + 1],
nv12_y[vaImage.pitches[0] + src_x], nv12_y[vaImage.pitches[0] + src_x + 1] };
int i;
for (i = 0; i < 4; ++i) {
double R = 1.164 * (nv_y[i] - 16) + 1.596 * (nv_v - 128);
double G = 1.164 * (nv_y[i] - 16) - 0.391 * (nv_u - 128) - 0.813 * (nv_v - 128);
double B = 1.164 * (nv_y[i] - 16) + 2.018 * (nv_u - 128);
/* clamp R, G, B values. For some Y, U, V combinations,
* the results of the above calculations fall outside of
* the range 0-255.
*/
if (R < 0.0) R = 0.0;
if (G < 0.0) G = 0.0;
if (B < 0.0) B = 0.0;
if (R > 255.0) R = 255.0;
if (G > 255.0) G = 255.0;
if (B > 255.0) B = 255.0;
dst[client->width * (i / 2) + src_x + (i % 2)] = 0
| ((unsigned int)(R + 0.5) << client->format.redShift)
| ((unsigned int)(G + 0.5) << client->format.greenShift)
| ((unsigned int)(B + 0.5) << client->format.blueShift);
}
}
nv12_y += 2 * vaImage.pitches[0];
nv12_uv += vaImage.pitches[1];
dst += 2 * client->width;
}
CHECK_SURF(va_surface_id[sid]);
va_status = vaUnmapBuffer(va_dpy, vaImage.buf);
CHECK_VASTATUS(va_status, "vaUnmapBuffer(DecodedData)");
}
#endif /* LIBVNCSERVER_CONFIG_LIBVA */

@ -30,9 +30,6 @@
#ifdef WIN32
#define close closesocket
#include <winsock2.h>
#ifdef _MINGW32
#undef max
#endif // #ifdef _MINGW32
#else // #ifdef WIN32
#include <sys/wait.h>
#include <sys/utsname.h>
@ -99,7 +96,7 @@ listenForIncomingConnections(rfbClient* client)
if(listen6Socket >= 0)
FD_SET(listen6Socket, &fds);
r = select(max(listenSocket, listen6Socket)+1, &fds, NULL, NULL, NULL);
r = select(rfbMax(listenSocket, listen6Socket)+1, &fds, NULL, NULL, NULL);
if (r > 0) {
if (FD_ISSET(listenSocket, &fds))
@ -141,7 +138,7 @@ listenForIncomingConnections(rfbClient* client)
/*
* listenForIncomingConnectionsNoFork() - listen for incoming connections
* from servers, but DON'T fork, instead just wait timeout microseconds.
* If timeout is negative, block indefinitly.
* If timeout is negative, block indefinitely.
* Returns 1 on success (there was an incoming connection on the listen socket
* and we accepted it successfully), -1 on error, 0 on timeout.
*/
@ -195,9 +192,9 @@ listenForIncomingConnectionsNoFork(rfbClient* client, int timeout)
FD_SET(client->listen6Sock, &fds);
if (timeout < 0)
r = select(max(client->listenSock, client->listen6Sock) +1, &fds, NULL, NULL, NULL);
r = select(rfbMax(client->listenSock, client->listen6Sock) +1, &fds, NULL, NULL, NULL);
else
r = select(max(client->listenSock, client->listen6Sock) +1, &fds, NULL, NULL, &to);
r = select(rfbMax(client->listenSock, client->listen6Sock) +1, &fds, NULL, NULL, &to);
if (r > 0)
{

@ -147,9 +147,22 @@ void* rfbClientGetClientData(rfbClient* client, void* tag)
/* 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++) \
@ -171,6 +184,11 @@ static void CopyRectangle(rfbClient* client, uint8_t* buffer, int x, int y, int
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; \
@ -193,6 +211,20 @@ static void CopyRectangle(rfbClient* client, uint8_t* buffer, int x, int y, int
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; \
@ -273,9 +305,6 @@ static rfbBool HandleZRLE24Up(rfbClient* client, int rx, int ry, int rw, int rh)
static rfbBool HandleZRLE24Down(rfbClient* client, int rx, int ry, int rw, int rh);
static rfbBool HandleZRLE32(rfbClient* client, int rx, int ry, int rw, int rh);
#endif
#ifdef LIBVNCSERVER_CONFIG_LIBVA
static rfbBool HandleH264 (rfbClient* client, int rx, int ry, int rw, int rh);
#endif
/*
* Server Capability Functions
@ -1411,10 +1440,6 @@ SetFormatAndEncodings(rfbClient* client)
encs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingCoRRE);
} else if (strncasecmp(encStr,"rre",encStrLen) == 0) {
encs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingRRE);
#ifdef LIBVNCSERVER_CONFIG_LIBVA
} else if (strncasecmp(encStr,"h264",encStrLen) == 0) {
encs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingH264);
#endif
} else {
rfbClientLog("Unknown encoding '%.*s'\n",encStrLen,encStr);
}
@ -1483,10 +1508,6 @@ SetFormatAndEncodings(rfbClient* client)
encs[se->nEncodings++] = rfbClientSwap32IfLE(client->appData.qualityLevel +
rfbEncodingQualityLevel0);
}
#ifdef LIBVNCSERVER_CONFIG_LIBVA
encs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingH264);
rfbClientLog("h264 encoding added\n");
#endif
}
@ -1530,6 +1551,7 @@ SetFormatAndEncodings(rfbClient* client)
if(e->encodings) {
int* enc;
for(enc = e->encodings; *enc; enc++)
if(se->nEncodings < MAX_ENCODINGS)
encs[se->nEncodings++] = rfbClientSwap32IfLE(*enc);
}
@ -1981,7 +2003,10 @@ HandleRFBServerMessage(rfbClient* client)
int y=rect.r.y, h=rect.r.h;
bytesPerLine = rect.r.w * client->format.bitsPerPixel / 8;
linesToRead = RFB_BUFFER_SIZE / bytesPerLine;
/* RealVNC 4.x-5.x on OSX can induce bytesPerLine==0,
usually during GPU accel. */
/* Regardless of cause, do not divide by zero. */
linesToRead = bytesPerLine ? (RFB_BUFFER_SIZE / bytesPerLine) : 0;
while (h > 0) {
if (linesToRead > h)
@ -1997,7 +2022,8 @@ HandleRFBServerMessage(rfbClient* client)
y += linesToRead;
}
} break;
break;
}
case rfbEncodingCopyRect:
{
@ -2203,14 +2229,6 @@ HandleRFBServerMessage(rfbClient* client)
break;
}
#endif
#ifdef LIBVNCSERVER_CONFIG_LIBVA
case rfbEncodingH264:
{
if (!HandleH264(client, rect.r.x, rect.r.y, rect.r.w, rect.r.h))
return FALSE;
break;
}
#endif
default:
@ -2448,7 +2466,6 @@ HandleRFBServerMessage(rfbClient* client)
#define UNCOMP -8
#include "zrle.c"
#undef BPP
#include "h264.c"
/*

@ -567,7 +567,7 @@ ListenAtTcpPortAndAddress(int port, const char *address)
}
#ifdef IPV6_V6ONLY
/* we have seperate IPv4 and IPv6 sockets since some OS's do not support dual binding */
/* we have separate IPv4 and IPv6 sockets since some OS's do not support dual binding */
if (p->ai_family == AF_INET6 && setsockopt(sock, IPPROTO_IPV6, IPV6_V6ONLY, (char *)&one, sizeof(one)) < 0) {
rfbClientErr("ListenAtTcpPortAndAddress: error in setsockopt IPV6_V6ONLY: %s\n", strerror(errno));
close(sock);

@ -67,9 +67,20 @@ InitializeTLS(void)
* libvncclient are linked to different versions of msvcrt.dll.
*/
#ifdef WIN32
static void WSAtoTLSErrno()
static void WSAtoTLSErrno(gnutls_session_t* session)
{
switch(WSAGetLastError()) {
#if (GNUTLS_VERSION_NUMBER >= 0x029901)
case WSAEWOULDBLOCK:
gnutls_transport_set_errno(session, EAGAIN);
break;
case WSAEINTR:
gnutls_transport_set_errno(session, EINTR);
break;
default:
gnutls_transport_set_errno(session, EIO);
break;
#else
case WSAEWOULDBLOCK:
gnutls_transport_set_global_errno(EAGAIN);
break;
@ -79,11 +90,11 @@ static void WSAtoTLSErrno()
default:
gnutls_transport_set_global_errno(EIO);
break;
#endif
}
}
#endif
static ssize_t
PushTLS(gnutls_transport_ptr_t transport, const void *data, size_t len)
{
@ -96,7 +107,7 @@ PushTLS(gnutls_transport_ptr_t transport, const void *data, size_t len)
if (ret < 0)
{
#ifdef WIN32
WSAtoTLSErrno();
WSAtoTLSErrno((gnutls_session_t*)&client->tlsSession);
#endif
if (errno == EINTR) continue;
return -1;
@ -118,7 +129,7 @@ PullTLS(gnutls_transport_ptr_t transport, void *data, size_t len)
if (ret < 0)
{
#ifdef WIN32
WSAtoTLSErrno();
WSAtoTLSErrno((gnutls_session_t*)&client->tlsSession);
#endif
if (errno == EINTR) continue;
return -1;
@ -480,6 +491,14 @@ WriteToTLS(rfbClient* client, char *buf, unsigned int n)
unsigned int offset = 0;
ssize_t ret;
if (client->LockWriteToTLS)
{
if (!client->LockWriteToTLS(client))
{
rfbClientLog("Callback to get lock in WriteToTLS() failed\n");
return -1;
}
}
while (offset < n)
{
ret = gnutls_record_send((gnutls_session_t)client->tlsSession, buf+offset, (size_t)(n-offset));
@ -488,10 +507,23 @@ WriteToTLS(rfbClient* client, char *buf, unsigned int n)
{
if (ret == GNUTLS_E_AGAIN || ret == GNUTLS_E_INTERRUPTED) continue;
rfbClientLog("Error writing to TLS: %s.\n", gnutls_strerror(ret));
if (client->UnlockWriteToTLS)
{
if (!client->UnlockWriteToTLS(client))
rfbClientLog("Callback to unlock WriteToTLS() failed\n");
}
return -1;
}
offset += (unsigned int)ret;
}
if (client->UnlockWriteToTLS)
{
if (!client->UnlockWriteToTLS(client))
{
rfbClientLog("Callback to unlock WriteToTLS() failed\n");
return -1;
}
}
return offset;
}

@ -86,14 +86,14 @@ HandleUltraBPP (rfbClient* client, int rx, int ry, int rw, int rh)
/* uncompress the data */
uncompressedBytes = client->raw_buffer_size;
inflateResult = lzo1x_decompress(
inflateResult = lzo1x_decompress_safe(
(lzo_byte *)client->ultra_buffer, toRead,
(lzo_byte *)client->raw_buffer, (lzo_uintp) &uncompressedBytes,
NULL);
/* Note that uncompressedBytes will be 0 on output overrun */
if ((rw * rh * (BPP / 8)) != uncompressedBytes)
rfbClientLog("Ultra decompressed too little (%d < %d)", (rw * rh * (BPP / 8)), uncompressedBytes);
rfbClientLog("Ultra decompressed unexpected amount of data (%d != %d)\n", (rw * rh * (BPP / 8)), uncompressedBytes);
/* Put the uncompressed contents of the update on the screen. */
if ( inflateResult == LZO_E_OK )
@ -168,7 +168,7 @@ HandleUltraZipBPP (rfbClient* client, int rx, int ry, int rw, int rh)
/* uncompress the data */
uncompressedBytes = client->raw_buffer_size;
inflateResult = lzo1x_decompress(
inflateResult = lzo1x_decompress_safe(
(lzo_byte *)client->ultra_buffer, toRead,
(lzo_byte *)client->raw_buffer, &uncompressedBytes, NULL);
if ( inflateResult != LZO_E_OK )

@ -116,11 +116,7 @@ static rfbBool MallocFrameBuffer(rfbClient* client) {
static void initAppData(AppData* data) {
data->shareDesktop=TRUE;
data->viewOnly=FALSE;
#ifdef LIBVNCSERVER_CONFIG_LIBVA
data->encodingsString="h264 tight zrle ultra copyrect hextile zlib corre rre raw";
#else
data->encodingsString="tight zrle ultra copyrect hextile zlib corre rre raw";
#endif
data->useBGR233=FALSE;
data->nColours=0;
data->forceOwnCmap=FALSE;
@ -224,6 +220,8 @@ rfbClient* rfbGetClient(int bitsPerSample,int samplesPerPixel,
client->subAuthScheme = 0;
client->GetCredential = NULL;
client->tlsSession = NULL;
client->LockWriteToTLS = NULL;
client->UnlockWriteToTLS = NULL;
client->sock = -1;
client->listenSock = -1;
client->listenAddress = NULL;

@ -30,14 +30,13 @@ WEBSOCKETSSRCS = websockets.c $(WEBSOCKETSSSLSRCS)
endif
includedir=$(prefix)/include/rfb
#include_HEADERS=rfb.h rfbconfig.h rfbint.h rfbproto.h keysym.h rfbregion.h
include_HEADERS=../rfb/rfb.h ../rfb/rfbconfig.h ../rfb/rfbint.h \
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/sha1.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 \
@ -60,7 +59,14 @@ LIB_SRCS = main.c rfbserver.c rfbregion.c auth.c sockets.c $(WEBSOCKETSSRCS) \
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

@ -1,5 +1,5 @@
/*
* This parses the command line arguments. It was seperated from main.c by
* This parses the command line arguments. It was separated from main.c by
* Justin Dearing <jdeari01@longisland.poly.edu>.
*/

@ -81,9 +81,7 @@
"<HEAD><TITLE>Invalid Request</TITLE></HEAD>\n" \
"<BODY><H1>Invalid request</H1></BODY>\n"
#define OK_STR "HTTP/1.0 200 OK\r\nConnection: close\r\n\r\n"
#define OK_STR_HTML "HTTP/1.0 200 OK\r\nConnection: close\r\nContent-Type: text/html\r\n\r\n"
#define OK_STR "HTTP/1.0 200 OK\r\nConnection: close\r\n"
static void httpProcessInput(rfbScreenInfoPtr screen);
@ -192,7 +190,7 @@ rfbHttpCheckFds(rfbScreenInfoPtr rfbScreen)
}
tv.tv_sec = 0;
tv.tv_usec = 0;
nfds = select(max(rfbScreen->httpListen6Sock, max(rfbScreen->httpSock,rfbScreen->httpListenSock)) + 1, &fds, NULL, NULL, &tv);
nfds = select(rfbMax(rfbScreen->httpListen6Sock, rfbMax(rfbScreen->httpSock,rfbScreen->httpListenSock)) + 1, &fds, NULL, NULL, &tv);
if (nfds == 0) {
return;
}
@ -423,6 +421,14 @@ httpProcessInput(rfbScreenInfoPtr rfbScreen)
}
}
/* Basic protection against directory traversal outside webroot */
if (strstr(fname, "..")) {
rfbErr("httpd: URL should not contain '..'\n");
rfbWriteExact(&cl, NOT_FOUND_STR, strlen(NOT_FOUND_STR));
httpCloseSock(rfbScreen);
return;
}
/* If we were asked for '/', actually read the file index.vnc */
@ -446,10 +452,18 @@ httpProcessInput(rfbScreenInfoPtr rfbScreen)
return;
}
if(performSubstitutions) /* is the 'index.vnc' file */
rfbWriteExact(&cl, OK_STR_HTML, strlen(OK_STR_HTML));
else
rfbWriteExact(&cl, OK_STR, strlen(OK_STR));
char *ext = strrchr(fname, '.');
char *contentType = "";
if(ext && strcasecmp(ext, ".vnc") == 0)
contentType = "Content-Type: text/html\r\n";
else if(ext && strcasecmp(ext, ".css") == 0)
contentType = "Content-Type: text/css\r\n";
else if(ext && strcasecmp(ext, ".svg") == 0)
contentType = "Content-Type: image/svg+xml\r\n";
rfbWriteExact(&cl, contentType, strlen(contentType));
/* end the header */
rfbWriteExact(&cl, "\r\n", 2);
while (1) {
int n = fread(buf, 1, BUF_SIZE-1, fd);

@ -579,7 +579,15 @@ clientInput(void *data)
rfbSendFileTransferChunk(cl);
if (FD_ISSET(cl->sock, &rfds) || FD_ISSET(cl->sock, &efds))
{
#ifdef LIBVNCSERVER_WITH_WEBSOCKETS
do {
rfbProcessClientMessage(cl);
} while (webSocketsHasDataInBuffer(cl));
#else
rfbProcessClientMessage(cl);
#endif
}
}
/* Get rid of the output thread. */
@ -616,7 +624,7 @@ listenerRun(void *data)
return NULL;
}
/* TODO: this thread wont die by restarting the server */
/* TODO: this thread won't die by restarting the server */
/* TODO: HTTP is not handled */
while (1) {
client_fd = -1;
@ -663,6 +671,10 @@ void
rfbStartOnHoldClient(rfbClientPtr cl)
{
cl->onHold = FALSE;
#ifdef LIBVNCSERVER_HAVE_LIBPTHREAD
if(cl->screen->backgroundLoop)
pthread_create(&cl->client_thread, NULL, clientInput, (void *)cl);
#endif
}
#endif

@ -23,7 +23,7 @@
#include <string.h>
#include "md5.h"
#include "sha1.h"
#include "sha.h"
#include "rfbcrypto.h"
void digestmd5(const struct iovec *iov, int iovcnt, void *dest)

@ -365,13 +365,11 @@ rfbNewTCPOrUDPClient(rfbScreenInfoPtr rfbScreen,
if (setsockopt(sock, IPPROTO_TCP, TCP_NODELAY,
(char *)&one, sizeof(one)) < 0) {
rfbLogPerror("setsockopt failed");
close(sock);
return NULL;
rfbLogPerror("setsockopt failed: can't set TCP_NODELAY flag, non TCP socket?");
}
FD_SET(sock,&(rfbScreen->allFds));
rfbScreen->maxFd = max(sock,rfbScreen->maxFd);
rfbScreen->maxFd = rfbMax(sock,rfbScreen->maxFd);
INIT_MUTEX(cl->outputMutex);
INIT_MUTEX(cl->refCountMutex);
@ -958,7 +956,6 @@ rfbSendSupportedMessages(rfbClientPtr cl)
/*rfbSetBit(msgs.client2server, rfbSetSW); */
/*rfbSetBit(msgs.client2server, rfbTextChat); */
rfbSetBit(msgs.client2server, rfbPalmVNCSetScaleFactor);
rfbSetBit(msgs.client2server, rfbXvp);
rfbSetBit(msgs.server2client, rfbFramebufferUpdate);
rfbSetBit(msgs.server2client, rfbSetColourMapEntries);
@ -966,7 +963,11 @@ rfbSendSupportedMessages(rfbClientPtr cl)
rfbSetBit(msgs.server2client, rfbServerCutText);
rfbSetBit(msgs.server2client, rfbResizeFrameBuffer);
rfbSetBit(msgs.server2client, rfbPalmVNCReSizeFrameBuffer);
if (cl->screen->xvpHook) {
rfbSetBit(msgs.client2server, rfbXvp);
rfbSetBit(msgs.server2client, rfbXvp);
}
memcpy(&cl->updateBuf[cl->ublen], (char *)&msgs, sz_rfbSupportedMessages);
cl->ublen += sz_rfbSupportedMessages;
@ -2226,12 +2227,14 @@ rfbProcessClientNormalMessage(rfbClientPtr cl)
}
break;
case rfbEncodingXvp:
if (cl->screen->xvpHook) {
rfbLog("Enabling Xvp protocol extension for client "
"%s\n", cl->host);
if (!rfbSendXvp(cl, 1, rfbXvp_Init)) {
rfbCloseClient(cl);
return;
}
}
break;
default:
#if defined(LIBVNCSERVER_HAVE_LIBZ) || defined(LIBVNCSERVER_HAVE_LIBPNG)

@ -109,6 +109,8 @@ struct rfbssl_ctx *rfbssl_init_global(char *key, char *cert)
gnutls_global_set_log_function(rfbssl_log_func);
gnutls_global_set_log_level(1);
gnutls_certificate_set_dh_params(ctx->x509_cred, ctx->dh_params);
/* newly allocated memory should be initialized, at least where it is important */
ctx->peekstart = ctx->peeklen = 0;
return ctx;
}

@ -213,7 +213,7 @@ void rfbScaledScreenUpdateRect(rfbScreenInfoPtr screen, rfbScreenInfoPtr ptr, in
case 2: pixel_value = *((unsigned short *)srcptr2); break;
case 1: pixel_value = *((unsigned char *)srcptr2); break;
default:
/* fixme: endianess problem? */
/* fixme: endianness problem? */
for (z = 0; z < bytesPerPixel; z++)
pixel_value += (srcptr2[z] << (8 * z));
break;
@ -240,7 +240,7 @@ void rfbScaledScreenUpdateRect(rfbScreenInfoPtr screen, rfbScreenInfoPtr ptr, in
case 2: *((unsigned short *)dstptr) = (unsigned short) pixel_value; break;
case 1: *((unsigned char *)dstptr) = (unsigned char) pixel_value; break;
default:
/* fixme: endianess problem? */
/* fixme: endianness problem? */
for (z = 0; z < bytesPerPixel; z++)
dstptr[z]=(pixel_value >> (8 * z)) & 0xff;
break;

@ -77,6 +77,10 @@
#include "rfbssl.h"
#endif
#ifdef LIBVNCSERVER_WITH_SYSTEMD
#include <systemd/sd-daemon.h>
#endif
#if defined(__linux__) && defined(NEED_TIMEVAL)
struct timeval
{
@ -122,6 +126,54 @@ int deny_severity=LOG_WARNING;
int rfbMaxClientWait = 20000; /* time (ms) after which we decide client has
gone away - needed to stop us hanging */
static rfbBool
rfbNewConnectionFromSock(rfbScreenInfoPtr rfbScreen, int sock)
{
const int one = 1;
#ifdef LIBVNCSERVER_IPv6
struct sockaddr_storage addr;
#else
struct sockaddr_in addr;
#endif
socklen_t addrlen = sizeof(addr);
getpeername(sock, (struct sockaddr *)&addr, &addrlen);
if(!rfbSetNonBlocking(sock)) {
rfbLogPerror("rfbCheckFds: setnonblock");
closesocket(sock);
return FALSE;
}
if (setsockopt(sock, IPPROTO_TCP, TCP_NODELAY,
(char *)&one, sizeof(one)) < 0) {
rfbLogPerror("rfbCheckFds: setsockopt failed: can't set TCP_NODELAY flag, non TCP socket?");
}
#ifdef USE_LIBWRAP
if(!hosts_ctl("vnc",STRING_UNKNOWN,inet_ntoa(addr.sin_addr),
STRING_UNKNOWN)) {
rfbLog("Rejected connection from client %s\n",
inet_ntoa(addr.sin_addr));
closesocket(sock);
return FALSE;
}
#endif
#ifdef LIBVNCSERVER_IPv6
char host[1024];
if(getnameinfo((struct sockaddr*)&addr, addrlen, host, sizeof(host), NULL, 0, NI_NUMERICHOST) != 0) {
rfbLogPerror("rfbProcessNewConnection: error in getnameinfo");
}
rfbLog("Got connection from client %s\n", host);
#else
rfbLog("Got connection from client %s\n", inet_ntoa(addr.sin_addr));
#endif
rfbNewClient(rfbScreen,sock);
return TRUE;
}
/*
* rfbInitSockets sets up the TCP and UDP sockets to listen for RFB
* connections. It does nothing if called again.
@ -138,6 +190,20 @@ rfbInitSockets(rfbScreenInfoPtr rfbScreen)
rfbScreen->socketState = RFB_SOCKET_READY;
#ifdef LIBVNCSERVER_WITH_SYSTEMD
if (sd_listen_fds(0) == 1)
{
int sock = SD_LISTEN_FDS_START + 0;
if (sd_is_socket(sock, AF_UNSPEC, 0, 0))
rfbNewConnectionFromSock(rfbScreen, sock);
else if (sd_is_socket(sock, AF_UNSPEC, 0, 1))
rfbProcessNewConnection(rfbScreen);
return;
}
else
rfbLog("Unable to establish connection with systemd socket\n");
#endif
if (rfbScreen->inetdSock != -1) {
const int one = 1;
@ -146,8 +212,7 @@ rfbInitSockets(rfbScreenInfoPtr rfbScreen)
if (setsockopt(rfbScreen->inetdSock, IPPROTO_TCP, TCP_NODELAY,
(char *)&one, sizeof(one)) < 0) {
rfbLogPerror("setsockopt");
return;
rfbLogPerror("setsockopt failed: can't set TCP_NODELAY flag, non TCP socket?");
}
FD_ZERO(&(rfbScreen->allFds));
@ -156,10 +221,10 @@ rfbInitSockets(rfbScreenInfoPtr rfbScreen)
return;
}
if(rfbScreen->autoPort) {
int i;
FD_ZERO(&(rfbScreen->allFds));
if(rfbScreen->autoPort && rfbScreen->port>0) {
int i;
rfbLog("Autoprobing TCP port \n");
for (i = 5900; i < 6000; i++) {
if ((rfbScreen->listenSock = rfbListenOnTCPPort(i, iface)) >= 0) {
@ -176,8 +241,11 @@ rfbInitSockets(rfbScreenInfoPtr rfbScreen)
rfbLog("Autoprobing selected TCP port %d\n", rfbScreen->port);
FD_SET(rfbScreen->listenSock, &(rfbScreen->allFds));
rfbScreen->maxFd = rfbScreen->listenSock;
}
#ifdef LIBVNCSERVER_IPv6
if(rfbScreen->autoPort && rfbScreen->ipv6port>0) {
int i;
rfbLog("Autoprobing TCP6 port \n");
for (i = 5900; i < 6000; i++) {
if ((rfbScreen->listen6Sock = rfbListenOnTCP6Port(i, rfbScreen->listen6Interface)) >= 0) {
@ -193,13 +261,12 @@ rfbInitSockets(rfbScreenInfoPtr rfbScreen)
rfbLog("Autoprobing selected TCP6 port %d\n", rfbScreen->ipv6port);
FD_SET(rfbScreen->listen6Sock, &(rfbScreen->allFds));
rfbScreen->maxFd = max((int)rfbScreen->listen6Sock,rfbScreen->maxFd);
#endif
rfbScreen->maxFd = rfbMax((int)rfbScreen->listen6Sock,rfbScreen->maxFd);
}
else
{
#endif
if(!rfbScreen->autoPort) {
if(rfbScreen->port>0) {
FD_ZERO(&(rfbScreen->allFds));
if ((rfbScreen->listenSock = rfbListenOnTCPPort(rfbScreen->port, iface)) < 0) {
rfbLogPerror("ListenOnTCPPort");
@ -220,7 +287,7 @@ rfbInitSockets(rfbScreenInfoPtr rfbScreen)
rfbLog("Listening for VNC connections on TCP6 port %d\n", rfbScreen->ipv6port);
FD_SET(rfbScreen->listen6Sock, &(rfbScreen->allFds));
rfbScreen->maxFd = max((int)rfbScreen->listen6Sock,rfbScreen->maxFd);
rfbScreen->maxFd = rfbMax((int)rfbScreen->listen6Sock,rfbScreen->maxFd);
}
#endif
@ -236,7 +303,7 @@ rfbInitSockets(rfbScreenInfoPtr rfbScreen)
rfbLog("Listening for VNC connections on TCP port %d\n", rfbScreen->port);
FD_SET(rfbScreen->udpSock, &(rfbScreen->allFds));
rfbScreen->maxFd = max((int)rfbScreen->udpSock,rfbScreen->maxFd);
rfbScreen->maxFd = rfbMax((int)rfbScreen->udpSock,rfbScreen->maxFd);
}
}
@ -391,7 +458,15 @@ rfbCheckFds(rfbScreenInfoPtr rfbScreen,long usec)
if (FD_ISSET(cl->sock, &(rfbScreen->allFds)))
{
if (FD_ISSET(cl->sock, &fds))
{
#ifdef LIBVNCSERVER_WITH_WEBSOCKETS
do {
rfbProcessClientMessage(cl);
} while (cl->sock > 0 && webSocketsHasDataInBuffer(cl));
#else
rfbProcessClientMessage(cl);
#endif
}
else
rfbSendFileTransferChunk(cl);
}
@ -404,14 +479,7 @@ rfbCheckFds(rfbScreenInfoPtr rfbScreen,long usec)
rfbBool
rfbProcessNewConnection(rfbScreenInfoPtr rfbScreen)
{
const int one = 1;
int sock = -1;
#ifdef LIBVNCSERVER_IPv6
struct sockaddr_storage addr;
#else
struct sockaddr_in addr;
#endif
socklen_t addrlen = sizeof(addr);
fd_set listen_fds;
int chosen_listen_sock = -1;
@ -432,49 +500,12 @@ rfbProcessNewConnection(rfbScreenInfoPtr rfbScreen)
if (rfbScreen->listen6Sock >= 0 && FD_ISSET(rfbScreen->listen6Sock, &listen_fds))
chosen_listen_sock = rfbScreen->listen6Sock;
if ((sock = accept(chosen_listen_sock,
(struct sockaddr *)&addr, &addrlen)) < 0) {
if ((sock = accept(chosen_listen_sock, NULL, NULL)) < 0) {
rfbLogPerror("rfbCheckFds: accept");
return FALSE;
}
if(!rfbSetNonBlocking(sock)) {
closesocket(sock);
return FALSE;
}
if (setsockopt(sock, IPPROTO_TCP, TCP_NODELAY,
(char *)&one, sizeof(one)) < 0) {
rfbLogPerror("rfbCheckFds: setsockopt");
closesocket(sock);
return FALSE;
}
#ifdef USE_LIBWRAP
if(!hosts_ctl("vnc",STRING_UNKNOWN,inet_ntoa(addr.sin_addr),
STRING_UNKNOWN)) {
rfbLog("Rejected connection from client %s\n",
inet_ntoa(addr.sin_addr));
closesocket(sock);
return FALSE;
}
#endif
#ifdef LIBVNCSERVER_IPv6
{
char host[1024];
if(getnameinfo((struct sockaddr*)&addr, addrlen, host, sizeof(host), NULL, 0, NI_NUMERICHOST) != 0) {
rfbLogPerror("rfbProcessNewConnection: error in getnameinfo");
}
rfbLog("Got connection from client %s\n", host);
}
#else
rfbLog("Got connection from client %s\n", inet_ntoa(addr.sin_addr));
#endif
rfbNewClient(rfbScreen,sock);
return TRUE;
return rfbNewConnectionFromSock(rfbScreen, sock);
}
@ -548,14 +579,12 @@ rfbConnect(rfbScreenInfoPtr rfbScreen,
if (setsockopt(sock, IPPROTO_TCP, TCP_NODELAY,
(char *)&one, sizeof(one)) < 0) {
rfbLogPerror("setsockopt failed");
closesocket(sock);
return -1;
rfbLogPerror("setsockopt failed: can't set TCP_NODELAY flag, non TCP socket?");
}
/* AddEnabledDevice(sock); */
FD_SET(sock, &rfbScreen->allFds);
rfbScreen->maxFd = max(sock,rfbScreen->maxFd);
rfbScreen->maxFd = rfbMax(sock,rfbScreen->maxFd);
return sock;
}
@ -917,7 +946,7 @@ rfbListenOnTCP6Port(int port,
}
#ifdef IPV6_V6ONLY
/* we have seperate IPv4 and IPv6 sockets since some OS's do not support dual binding */
/* we have separate IPv4 and IPv6 sockets since some OS's do not support dual binding */
if (setsockopt(sock, IPPROTO_IPV6, IPV6_V6ONLY, (char *)&one, sizeof(one)) < 0) {
rfbLogPerror("rfbListenOnTCP6Port error in setsockopt IPV6_V6ONLY");
closesocket(sock);

@ -163,7 +163,11 @@ void rfbTightCleanup (rfbScreenInfoPtr screen)
tightAfterBufSize = 0;
tightAfterBuf = NULL;
}
if (j) tjDestroy(j);
if (j) {
tjDestroy(j);
/* Set freed resource handle to 0! */
j = 0;
}
}
@ -559,7 +563,7 @@ ExtendSolidArea(rfbClientPtr cl,
/*
* Check if a rectangle is all of the same color. If needSameColor is
* set to non-zero, then also check that its color equals to the
* *colorPtr value. The result is 1 if the test is successfull, and in
* *colorPtr value. The result is 1 if the test is successful, and in
* that case new color will be stored in *colorPtr.
*/

@ -108,8 +108,8 @@ GetFileListResponseMsg(char* path, char flags)
/* fileListInfo can have null data if the folder is Empty
or if some error condition has occured.
The return value is 'failure' only if some error condition has occured.
or if some error condition has occurred.
The return value is 'failure' only if some error condition has occurred.
*/
status = CreateFileListInfo(&fileListInfo, path, !(flags & 0x10));

@ -703,7 +703,7 @@ HandleFileUploadLengthError(rfbClientPtr cl, short fNameSize)
return;
}
rfbLog("File [%s]: Method [%s]: File Upload Length Error occured"
rfbLog("File [%s]: Method [%s]: File Upload Length Error occurred"
"file path requested is <%s>\n", __FILE__, __FUNCTION__, path);
if(path != NULL) {

@ -208,7 +208,7 @@ void rfbHandleSecTypeTight(rfbClientPtr cl);
* In the protocol version 3.7t, the server informs the client what message
* types it supports in addition to ones defined in the protocol version 3.7.
* Also, the server sends the list of all supported encodings (note that it's
* not necessary to advertise the "raw" encoding sinse it MUST be supported in
* not necessary to advertise the "raw" encoding since it MUST be supported in
* RFB 3.x protocols).
*
* This data immediately follows the server initialisation message.

@ -500,7 +500,7 @@ rfbHandleSecTypeTight(rfbClientPtr cl) {
if(rtcp == NULL) {
/* Error condition close socket */
rfbLog("Memory error has occured while handling "
rfbLog("Memory error has occurred while handling "
"Tight security type... closing connection.\n");
rfbCloseClient(cl);
return;

@ -201,7 +201,7 @@ rfbSendRectEncodingUltra(rfbClientPtr cl,
return FALSE;
}
/* Technically, flushing the buffer here is not extrememly
/* Technically, flushing the buffer here is not extremely
* efficient. However, this improves the overall throughput
* of the system over very slow networks. By flushing
* the buffer with every maximum size lzo rectangle, we

@ -79,7 +79,8 @@ typedef int (*wsEncodeFunc)(rfbClientPtr cl, const char *src, int len, char **ds
typedef int (*wsDecodeFunc)(rfbClientPtr cl, char *dst, int len);
typedef struct ws_ctx_s {
char codeBuf[B64LEN(UPDATE_BUF_SIZE) + WSHLENMAX]; /* base64 + maximum frame header length */
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;
@ -152,6 +153,11 @@ Sec-WebSocket-Accept: %s\r\n\
Sec-WebSocket-Protocol: %s\r\n\
\r\n"
#define SERVER_HANDSHAKE_HYBI_NO_PROTOCOL "HTTP/1.1 101 Switching Protocols\r\n\
Upgrade: websocket\r\n\
Connection: Upgrade\r\n\
Sec-WebSocket-Accept: %s\r\n\
\r\n"
#define WEBSOCKETS_CLIENT_CONNECT_WAIT_MS 100
#define WEBSOCKETS_CLIENT_SEND_WAIT_MS 100
@ -389,8 +395,12 @@ webSocketsHandshake(rfbClientPtr cl, char *scheme)
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);
} else {
/* older hixie handshake, this could be removed if
* a final standard is established */
@ -490,15 +500,15 @@ webSocketsEncodeHixie(rfbClientPtr cl, const char *src, int len, char **dst)
int sz = 0;
ws_ctx_t *wsctx = (ws_ctx_t *)cl->wsctx;
wsctx->codeBuf[sz++] = '\x00';
len = __b64_ntop((unsigned char *)src, len, wsctx->codeBuf+sz, sizeof(wsctx->codeBuf) - (sz + 1));
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->codeBuf[sz++] = '\xff';
*dst = wsctx->codeBuf;
wsctx->codeBufEncode[sz++] = '\xff';
*dst = wsctx->codeBufEncode;
return sz;
}
@ -536,7 +546,7 @@ webSocketsDecodeHixie(rfbClientPtr cl, char *dst, int len)
char *buf, *end = NULL;
ws_ctx_t *wsctx = (ws_ctx_t *)cl->wsctx;
buf = wsctx->codeBuf;
buf = wsctx->codeBufDecode;
n = ws_peek(cl, buf, len*2+2);
@ -657,8 +667,8 @@ webSocketsDecodeHybi(rfbClientPtr cl, char *dst, int len)
goto spor;
}
buf = wsctx->codeBuf;
header = (ws_header_t *)wsctx->codeBuf;
buf = wsctx->codeBufDecode;
header = (ws_header_t *)wsctx->codeBufDecode;
ret = ws_peek(cl, buf, B64LEN(len) + WSHLENMAX);
@ -742,11 +752,11 @@ webSocketsDecodeHybi(rfbClientPtr cl, char *dst, int len)
errno = ECONNRESET;
break;
case WS_OPCODE_TEXT_FRAME:
if (-1 == (flength = __b64_pton(payload, (unsigned char *)wsctx->codeBuf, sizeof(wsctx->codeBuf)))) {
if (-1 == (flength = __b64_pton(payload, (unsigned char *)wsctx->codeBufDecode, sizeof(wsctx->codeBufDecode)))) {
rfbErr("%s: Base64 decode error; %m\n", __func__);
break;
}
payload = wsctx->codeBuf;
payload = wsctx->codeBufDecode;
/* fall through */
case WS_OPCODE_BINARY_FRAME:
if (flength > len) {
@ -790,7 +800,7 @@ webSocketsEncodeHybi(rfbClientPtr cl, const char *src, int len, char **dst)
return 0;
}
header = (ws_header_t *)wsctx->codeBuf;
header = (ws_header_t *)wsctx->codeBufEncode;
if (wsctx->base64) {
opcode = WS_OPCODE_TEXT_FRAME;
@ -816,7 +826,7 @@ webSocketsEncodeHybi(rfbClientPtr cl, const char *src, int len, char **dst)
}
if (wsctx->base64) {
if (-1 == (ret = __b64_ntop((unsigned char *)src, len, wsctx->codeBuf + sz, sizeof(wsctx->codeBuf) - sz))) {
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)
@ -824,11 +834,12 @@ webSocketsEncodeHybi(rfbClientPtr cl, const char *src, int len, char **dst)
ret += sz;
}
} else {
memcpy(wsctx->codeBuf + sz, src, len);
memcpy(wsctx->codeBufEncode + sz, src, len);
ret = sz + len;
}
*dst = wsctx->codeBuf;
*dst = wsctx->codeBufEncode;
return ret;
}
@ -905,3 +916,16 @@ webSocketCheckDisconnect(rfbClientPtr cl)
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
*/
rfbBool
webSocketsHasDataInBuffer(rfbClientPtr cl)
{
ws_ctx_t *wsctx = (ws_ctx_t *)cl->wsctx;
if (wsctx && wsctx->readbuflen)
return TRUE;
return (cl->sslctx && rfbssl_pending(cl) > 0);
}

@ -300,7 +300,7 @@ rfbSendRectEncodingZlib(rfbClientPtr cl,
return FALSE;
}
/* Technically, flushing the buffer here is not extrememly
/* Technically, flushing the buffer here is not extremely
* efficient. However, this improves the overall throughput
* of the system over very slow networks. By flushing
* the buffer with every maximum size zlib rectangle, we

@ -1,727 +0,0 @@
# ===========================================================================
# http://www.gnu.org/software/autoconf-archive/ax_create_stdint_h.html
# ===========================================================================
#
# SYNOPSIS
#
# AX_CREATE_STDINT_H [( HEADER-TO-GENERATE [, HEDERS-TO-CHECK])]
#
# DESCRIPTION
#
# the "ISO C9X: 7.18 Integer types <stdint.h>" section requires the
# existence of an include file <stdint.h> that defines a set of typedefs,
# especially uint8_t,int32_t,uintptr_t. Many older installations will not
# provide this file, but some will have the very same definitions in
# <inttypes.h>. In other enviroments we can use the inet-types in
# <sys/types.h> which would define the typedefs int8_t and u_int8_t
# respectivly.
#
# This macros will create a local "_stdint.h" or the headerfile given as
# an argument. In many cases that file will just "#include <stdint.h>" or
# "#include <inttypes.h>", while in other environments it will provide the
# set of basic 'stdint's definitions/typedefs:
#
# int8_t,uint8_t,int16_t,uint16_t,int32_t,uint32_t,intptr_t,uintptr_t
# int_least32_t.. int_fast32_t.. intmax_t
#
# which may or may not rely on the definitions of other files, or using
# the AC_CHECK_SIZEOF macro to determine the actual sizeof each type.
#
# if your header files require the stdint-types you will want to create an
# installable file mylib-int.h that all your other installable header may
# include. So if you have a library package named "mylib", just use
#
# AX_CREATE_STDINT_H(mylib-int.h)
#
# in configure.ac and go to install that very header file in Makefile.am
# along with the other headers (mylib.h) - and the mylib-specific headers
# can simply use "#include <mylib-int.h>" to obtain the stdint-types.
#
# Remember, if the system already had a valid <stdint.h>, the generated
# file will include it directly. No need for fuzzy HAVE_STDINT_H things...
# (oops, GCC 4.2.x has deliberatly disabled its stdint.h for non-c99
# compilation and the c99-mode is not the default. Therefore this macro
# will not use the compiler's stdint.h - please complain to the GCC
# developers).
#
# LICENSE
#
# Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de>
#
# 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 10
AC_DEFUN([AX_CHECK_DATA_MODEL],[
AC_CHECK_SIZEOF(char)
AC_CHECK_SIZEOF(short)
AC_CHECK_SIZEOF(int)
AC_CHECK_SIZEOF(long)
AC_CHECK_SIZEOF(void*)
ac_cv_char_data_model=""
ac_cv_char_data_model="$ac_cv_char_data_model$ac_cv_sizeof_char"
ac_cv_char_data_model="$ac_cv_char_data_model$ac_cv_sizeof_short"
ac_cv_char_data_model="$ac_cv_char_data_model$ac_cv_sizeof_int"
ac_cv_long_data_model=""
ac_cv_long_data_model="$ac_cv_long_data_model$ac_cv_sizeof_int"
ac_cv_long_data_model="$ac_cv_long_data_model$ac_cv_sizeof_long"
ac_cv_long_data_model="$ac_cv_long_data_model$ac_cv_sizeof_voidp"
AC_MSG_CHECKING([data model])
case "$ac_cv_char_data_model/$ac_cv_long_data_model" in
122/242) ac_cv_data_model="IP16" ; n="standard 16bit machine" ;;
122/244) ac_cv_data_model="LP32" ; n="standard 32bit machine" ;;
122/*) ac_cv_data_model="i16" ; n="unusual int16 model" ;;
124/444) ac_cv_data_model="ILP32" ; n="standard 32bit unixish" ;;
124/488) ac_cv_data_model="LP64" ; n="standard 64bit unixish" ;;
124/448) ac_cv_data_model="LLP64" ; n="unusual 64bit unixish" ;;
124/*) ac_cv_data_model="i32" ; n="unusual int32 model" ;;
128/888) ac_cv_data_model="ILP64" ; n="unusual 64bit numeric" ;;
128/*) ac_cv_data_model="i64" ; n="unusual int64 model" ;;
222/*2) ac_cv_data_model="DSP16" ; n="strict 16bit dsptype" ;;
333/*3) ac_cv_data_model="DSP24" ; n="strict 24bit dsptype" ;;
444/*4) ac_cv_data_model="DSP32" ; n="strict 32bit dsptype" ;;
666/*6) ac_cv_data_model="DSP48" ; n="strict 48bit dsptype" ;;
888/*8) ac_cv_data_model="DSP64" ; n="strict 64bit dsptype" ;;
222/*|333/*|444/*|666/*|888/*) :
ac_cv_data_model="iDSP" ; n="unusual dsptype" ;;
*) ac_cv_data_model="none" ; n="very unusual model" ;;
esac
AC_MSG_RESULT([$ac_cv_data_model ($ac_cv_long_data_model, $n)])
])
dnl AX_CHECK_HEADER_STDINT_X([HEADERLIST][,ACTION-IF])
AC_DEFUN([AX_CHECK_HEADER_STDINT_X],[
AC_CACHE_CHECK([for stdint uintptr_t], [ac_cv_header_stdint_x],[
ac_cv_header_stdint_x="" # the 1997 typedefs (inttypes.h)
AC_MSG_RESULT([(..)])
for i in m4_ifval([$1],[$1],[stdint.h inttypes.h sys/inttypes.h sys/types.h])
do
unset ac_cv_type_uintptr_t
unset ac_cv_type_uint64_t
AC_CHECK_TYPE(uintptr_t,[ac_cv_header_stdint_x=$i],continue,[#include <$i>])
AC_CHECK_TYPE(uint64_t,[and64="/uint64_t"],[and64=""],[#include<$i>])
m4_ifvaln([$2],[$2]) break
done
AC_MSG_CHECKING([for stdint uintptr_t])
])
])
AC_DEFUN([AX_CHECK_HEADER_STDINT_O],[
AC_CACHE_CHECK([for stdint uint32_t], [ac_cv_header_stdint_o],[
ac_cv_header_stdint_o="" # the 1995 typedefs (sys/inttypes.h)
AC_MSG_RESULT([(..)])
for i in m4_ifval([$1],[$1],[inttypes.h sys/inttypes.h sys/types.h stdint.h])
do
unset ac_cv_type_uint32_t
unset ac_cv_type_uint64_t
AC_CHECK_TYPE(uint32_t,[ac_cv_header_stdint_o=$i],continue,[#include <$i>])
AC_CHECK_TYPE(uint64_t,[and64="/uint64_t"],[and64=""],[#include<$i>])
m4_ifvaln([$2],[$2]) break
break;
done
AC_MSG_CHECKING([for stdint uint32_t])
])
])
AC_DEFUN([AX_CHECK_HEADER_STDINT_U],[
AC_CACHE_CHECK([for stdint u_int32_t], [ac_cv_header_stdint_u],[
ac_cv_header_stdint_u="" # the BSD typedefs (sys/types.h)
AC_MSG_RESULT([(..)])
for i in m4_ifval([$1],[$1],[sys/types.h inttypes.h sys/inttypes.h]) ; do
unset ac_cv_type_u_int32_t
unset ac_cv_type_u_int64_t
AC_CHECK_TYPE(u_int32_t,[ac_cv_header_stdint_u=$i],continue,[#include <$i>])
AC_CHECK_TYPE(u_int64_t,[and64="/u_int64_t"],[and64=""],[#include<$i>])
m4_ifvaln([$2],[$2]) break
break;
done
AC_MSG_CHECKING([for stdint u_int32_t])
])
])
AC_DEFUN([AX_CREATE_STDINT_H],
[# ------ AX CREATE STDINT H -------------------------------------
AC_MSG_CHECKING([for stdint types])
ac_stdint_h=`echo ifelse($1, , _stdint.h, $1)`
# try to shortcircuit - if the default include path of the compiler
# can find a "stdint.h" header then we assume that all compilers can.
AC_CACHE_VAL([ac_cv_header_stdint_t],[
old_CXXFLAGS="$CXXFLAGS" ; CXXFLAGS=""
old_CPPFLAGS="$CPPFLAGS" ; CPPFLAGS=""
old_CFLAGS="$CFLAGS" ; CFLAGS=""
AC_TRY_COMPILE([#include <stdint.h>],[int_least32_t v = 0;],
[ac_cv_stdint_result="(assuming C99 compatible system)"
ac_cv_header_stdint_t="stdint.h"; ],
[ac_cv_header_stdint_t=""])
if test "$GCC" = "yes" && test ".$ac_cv_header_stdint_t" = "."; then
CFLAGS="-std=c99"
AC_TRY_COMPILE([#include <stdint.h>],[int_least32_t v = 0;],
[AC_MSG_WARN(your GCC compiler has a defunct stdint.h for its default-mode)])
fi
CXXFLAGS="$old_CXXFLAGS"
CPPFLAGS="$old_CPPFLAGS"
CFLAGS="$old_CFLAGS" ])
v="... $ac_cv_header_stdint_h"
if test "$ac_stdint_h" = "stdint.h" ; then
AC_MSG_RESULT([(are you sure you want them in ./stdint.h?)])
elif test "$ac_stdint_h" = "inttypes.h" ; then
AC_MSG_RESULT([(are you sure you want them in ./inttypes.h?)])
elif test "_$ac_cv_header_stdint_t" = "_" ; then
AC_MSG_RESULT([(putting them into $ac_stdint_h)$v])
else
ac_cv_header_stdint="$ac_cv_header_stdint_t"
AC_MSG_RESULT([$ac_cv_header_stdint (shortcircuit)])
fi
if test "_$ac_cv_header_stdint_t" = "_" ; then # cannot shortcircuit..
dnl .....intro message done, now do a few system checks.....
dnl btw, all old CHECK_TYPE macros do automatically "DEFINE" a type,
dnl therefore we use the autoconf implementation detail CHECK_TYPE_NEW
dnl instead that is triggered with 3 or more arguments (see types.m4)
inttype_headers=`echo $2 | sed -e 's/,/ /g'`
ac_cv_stdint_result="(no helpful system typedefs seen)"
AX_CHECK_HEADER_STDINT_X(dnl
stdint.h inttypes.h sys/inttypes.h $inttype_headers,
ac_cv_stdint_result="(seen uintptr_t$and64 in $i)")
if test "_$ac_cv_header_stdint_x" = "_" ; then
AX_CHECK_HEADER_STDINT_O(dnl,
inttypes.h sys/inttypes.h stdint.h $inttype_headers,
ac_cv_stdint_result="(seen uint32_t$and64 in $i)")
fi
if test "_$ac_cv_header_stdint_x" = "_" ; then
if test "_$ac_cv_header_stdint_o" = "_" ; then
AX_CHECK_HEADER_STDINT_U(dnl,
sys/types.h inttypes.h sys/inttypes.h $inttype_headers,
ac_cv_stdint_result="(seen u_int32_t$and64 in $i)")
fi fi
dnl if there was no good C99 header file, do some typedef checks...
if test "_$ac_cv_header_stdint_x" = "_" ; then
AC_MSG_CHECKING([for stdint datatype model])
AC_MSG_RESULT([(..)])
AX_CHECK_DATA_MODEL
fi
if test "_$ac_cv_header_stdint_x" != "_" ; then
ac_cv_header_stdint="$ac_cv_header_stdint_x"
elif test "_$ac_cv_header_stdint_o" != "_" ; then
ac_cv_header_stdint="$ac_cv_header_stdint_o"
elif test "_$ac_cv_header_stdint_u" != "_" ; then
ac_cv_header_stdint="$ac_cv_header_stdint_u"
else
ac_cv_header_stdint="stddef.h"
fi
AC_MSG_CHECKING([for extra inttypes in chosen header])
AC_MSG_RESULT([($ac_cv_header_stdint)])
dnl see if int_least and int_fast types are present in _this_ header.
unset ac_cv_type_int_least32_t
unset ac_cv_type_int_fast32_t
AC_CHECK_TYPE(int_least32_t,,,[#include <$ac_cv_header_stdint>])
AC_CHECK_TYPE(int_fast32_t,,,[#include<$ac_cv_header_stdint>])
AC_CHECK_TYPE(intmax_t,,,[#include <$ac_cv_header_stdint>])
fi # shortcircut to system "stdint.h"
# ------------------ PREPARE VARIABLES ------------------------------
if test "$GCC" = "yes" ; then
ac_cv_stdint_message="using gnu compiler "`$CC --version | head -1`
else
ac_cv_stdint_message="using $CC"
fi
AC_MSG_RESULT([make use of $ac_cv_header_stdint in $ac_stdint_h dnl
$ac_cv_stdint_result])
dnl -----------------------------------------------------------------
# ----------------- DONE inttypes.h checks START header -------------
AC_CONFIG_COMMANDS([$ac_stdint_h],[
AC_MSG_NOTICE(creating $ac_stdint_h : $_ac_stdint_h)
ac_stdint=$tmp/_stdint.h
echo "#ifndef" $_ac_stdint_h >$ac_stdint
echo "#define" $_ac_stdint_h "1" >>$ac_stdint
echo "#ifndef" _GENERATED_STDINT_H >>$ac_stdint
echo "#define" _GENERATED_STDINT_H '"'$PACKAGE $VERSION'"' >>$ac_stdint
echo "/* generated $ac_cv_stdint_message */" >>$ac_stdint
if test "_$ac_cv_header_stdint_t" != "_" ; then
echo "#define _STDINT_HAVE_STDINT_H" "1" >>$ac_stdint
echo "#include <stdint.h>" >>$ac_stdint
echo "#endif" >>$ac_stdint
echo "#endif" >>$ac_stdint
else
cat >>$ac_stdint <<STDINT_EOF
/* ................... shortcircuit part ........................... */
#if defined HAVE_STDINT_H || defined _STDINT_HAVE_STDINT_H
#include <stdint.h>
#else
#include <stddef.h>
/* .................... configured part ............................ */
STDINT_EOF
echo "/* whether we have a C99 compatible stdint header file */" >>$ac_stdint
if test "_$ac_cv_header_stdint_x" != "_" ; then
ac_header="$ac_cv_header_stdint_x"
echo "#define _STDINT_HEADER_INTPTR" '"'"$ac_header"'"' >>$ac_stdint
else
echo "/* #undef _STDINT_HEADER_INTPTR */" >>$ac_stdint
fi
echo "/* whether we have a C96 compatible inttypes header file */" >>$ac_stdint
if test "_$ac_cv_header_stdint_o" != "_" ; then
ac_header="$ac_cv_header_stdint_o"
echo "#define _STDINT_HEADER_UINT32" '"'"$ac_header"'"' >>$ac_stdint
else
echo "/* #undef _STDINT_HEADER_UINT32 */" >>$ac_stdint
fi
echo "/* whether we have a BSD compatible inet types header */" >>$ac_stdint
if test "_$ac_cv_header_stdint_u" != "_" ; then
ac_header="$ac_cv_header_stdint_u"
echo "#define _STDINT_HEADER_U_INT32" '"'"$ac_header"'"' >>$ac_stdint
else
echo "/* #undef _STDINT_HEADER_U_INT32 */" >>$ac_stdint
fi
echo "" >>$ac_stdint
if test "_$ac_header" != "_" ; then if test "$ac_header" != "stddef.h" ; then
echo "#include <$ac_header>" >>$ac_stdint
echo "" >>$ac_stdint
fi fi
echo "/* which 64bit typedef has been found */" >>$ac_stdint
if test "$ac_cv_type_uint64_t" = "yes" ; then
echo "#define _STDINT_HAVE_UINT64_T" "1" >>$ac_stdint
else
echo "/* #undef _STDINT_HAVE_UINT64_T */" >>$ac_stdint
fi
if test "$ac_cv_type_u_int64_t" = "yes" ; then
echo "#define _STDINT_HAVE_U_INT64_T" "1" >>$ac_stdint
else
echo "/* #undef _STDINT_HAVE_U_INT64_T */" >>$ac_stdint
fi
echo "" >>$ac_stdint
echo "/* which type model has been detected */" >>$ac_stdint
if test "_$ac_cv_char_data_model" != "_" ; then
echo "#define _STDINT_CHAR_MODEL" "$ac_cv_char_data_model" >>$ac_stdint
echo "#define _STDINT_LONG_MODEL" "$ac_cv_long_data_model" >>$ac_stdint
else
echo "/* #undef _STDINT_CHAR_MODEL // skipped */" >>$ac_stdint
echo "/* #undef _STDINT_LONG_MODEL // skipped */" >>$ac_stdint
fi
echo "" >>$ac_stdint
echo "/* whether int_least types were detected */" >>$ac_stdint
if test "$ac_cv_type_int_least32_t" = "yes"; then
echo "#define _STDINT_HAVE_INT_LEAST32_T" "1" >>$ac_stdint
else
echo "/* #undef _STDINT_HAVE_INT_LEAST32_T */" >>$ac_stdint
fi
echo "/* whether int_fast types were detected */" >>$ac_stdint
if test "$ac_cv_type_int_fast32_t" = "yes"; then
echo "#define _STDINT_HAVE_INT_FAST32_T" "1" >>$ac_stdint
else
echo "/* #undef _STDINT_HAVE_INT_FAST32_T */" >>$ac_stdint
fi
echo "/* whether intmax_t type was detected */" >>$ac_stdint
if test "$ac_cv_type_intmax_t" = "yes"; then
echo "#define _STDINT_HAVE_INTMAX_T" "1" >>$ac_stdint
else
echo "/* #undef _STDINT_HAVE_INTMAX_T */" >>$ac_stdint
fi
echo "" >>$ac_stdint
cat >>$ac_stdint <<STDINT_EOF
/* .................... detections part ............................ */
/* whether we need to define bitspecific types from compiler base types */
#ifndef _STDINT_HEADER_INTPTR
#ifndef _STDINT_HEADER_UINT32
#ifndef _STDINT_HEADER_U_INT32
#define _STDINT_NEED_INT_MODEL_T
#else
#define _STDINT_HAVE_U_INT_TYPES
#endif
#endif
#endif
#ifdef _STDINT_HAVE_U_INT_TYPES
#undef _STDINT_NEED_INT_MODEL_T
#endif
#ifdef _STDINT_CHAR_MODEL
#if _STDINT_CHAR_MODEL+0 == 122 || _STDINT_CHAR_MODEL+0 == 124
#ifndef _STDINT_BYTE_MODEL
#define _STDINT_BYTE_MODEL 12
#endif
#endif
#endif
#ifndef _STDINT_HAVE_INT_LEAST32_T
#define _STDINT_NEED_INT_LEAST_T
#endif
#ifndef _STDINT_HAVE_INT_FAST32_T
#define _STDINT_NEED_INT_FAST_T
#endif
#ifndef _STDINT_HEADER_INTPTR
#define _STDINT_NEED_INTPTR_T
#ifndef _STDINT_HAVE_INTMAX_T
#define _STDINT_NEED_INTMAX_T
#endif
#endif
/* .................... definition part ............................ */
/* some system headers have good uint64_t */
#ifndef _HAVE_UINT64_T
#if defined _STDINT_HAVE_UINT64_T || defined HAVE_UINT64_T
#define _HAVE_UINT64_T
#elif defined _STDINT_HAVE_U_INT64_T || defined HAVE_U_INT64_T
#define _HAVE_UINT64_T
typedef u_int64_t uint64_t;
#endif
#endif
#ifndef _HAVE_UINT64_T
/* .. here are some common heuristics using compiler runtime specifics */
#if defined __STDC_VERSION__ && defined __STDC_VERSION__ >= 199901L
#define _HAVE_UINT64_T
#define _HAVE_LONGLONG_UINT64_T
typedef long long int64_t;
typedef unsigned long long uint64_t;
#elif !defined __STRICT_ANSI__
#if defined _MSC_VER || defined __WATCOMC__ || defined __BORLANDC__
#define _HAVE_UINT64_T
typedef __int64 int64_t;
typedef unsigned __int64 uint64_t;
#elif defined __GNUC__ || defined __MWERKS__ || defined __ELF__
/* note: all ELF-systems seem to have loff-support which needs 64-bit */
#if !defined _NO_LONGLONG
#define _HAVE_UINT64_T
#define _HAVE_LONGLONG_UINT64_T
typedef long long int64_t;
typedef unsigned long long uint64_t;
#endif
#elif defined __alpha || (defined __mips && defined _ABIN32)
#if !defined _NO_LONGLONG
typedef long int64_t;
typedef unsigned long uint64_t;
#endif
/* compiler/cpu type to define int64_t */
#endif
#endif
#endif
#if defined _STDINT_HAVE_U_INT_TYPES
/* int8_t int16_t int32_t defined by inet code, redeclare the u_intXX types */
typedef u_int8_t uint8_t;
typedef u_int16_t uint16_t;
typedef u_int32_t uint32_t;
/* glibc compatibility */
#ifndef __int8_t_defined
#define __int8_t_defined
#endif
#endif
#ifdef _STDINT_NEED_INT_MODEL_T
/* we must guess all the basic types. Apart from byte-adressable system, */
/* there a few 32-bit-only dsp-systems that we guard with BYTE_MODEL 8-} */
/* (btw, those nibble-addressable systems are way off, or so we assume) */
dnl /* have a look at "64bit and data size neutrality" at */
dnl /* http://unix.org/version2/whatsnew/login_64bit.html */
dnl /* (the shorthand "ILP" types always have a "P" part) */
#if defined _STDINT_BYTE_MODEL
#if _STDINT_LONG_MODEL+0 == 242
/* 2:4:2 = IP16 = a normal 16-bit system */
typedef unsigned char uint8_t;
typedef unsigned short uint16_t;
typedef unsigned long uint32_t;
#ifndef __int8_t_defined
#define __int8_t_defined
typedef char int8_t;
typedef short int16_t;
typedef long int32_t;
#endif
#elif _STDINT_LONG_MODEL+0 == 244 || _STDINT_LONG_MODEL == 444
/* 2:4:4 = LP32 = a 32-bit system derived from a 16-bit */
/* 4:4:4 = ILP32 = a normal 32-bit system */
typedef unsigned char uint8_t;
typedef unsigned short uint16_t;
typedef unsigned int uint32_t;
#ifndef __int8_t_defined
#define __int8_t_defined
typedef char int8_t;
typedef short int16_t;
typedef int int32_t;
#endif
#elif _STDINT_LONG_MODEL+0 == 484 || _STDINT_LONG_MODEL+0 == 488
/* 4:8:4 = IP32 = a 32-bit system prepared for 64-bit */
/* 4:8:8 = LP64 = a normal 64-bit system */
typedef unsigned char uint8_t;
typedef unsigned short uint16_t;
typedef unsigned int uint32_t;
#ifndef __int8_t_defined
#define __int8_t_defined
typedef char int8_t;
typedef short int16_t;
typedef int int32_t;
#endif
/* this system has a "long" of 64bit */
#ifndef _HAVE_UINT64_T
#define _HAVE_UINT64_T
typedef unsigned long uint64_t;
typedef long int64_t;
#endif
#elif _STDINT_LONG_MODEL+0 == 448
/* LLP64 a 64-bit system derived from a 32-bit system */
typedef unsigned char uint8_t;
typedef unsigned short uint16_t;
typedef unsigned int uint32_t;
#ifndef __int8_t_defined
#define __int8_t_defined
typedef char int8_t;
typedef short int16_t;
typedef int int32_t;
#endif
/* assuming the system has a "long long" */
#ifndef _HAVE_UINT64_T
#define _HAVE_UINT64_T
#define _HAVE_LONGLONG_UINT64_T
typedef unsigned long long uint64_t;
typedef long long int64_t;
#endif
#else
#define _STDINT_NO_INT32_T
#endif
#else
#define _STDINT_NO_INT8_T
#define _STDINT_NO_INT32_T
#endif
#endif
/*
* quote from SunOS-5.8 sys/inttypes.h:
* Use at your own risk. As of February 1996, the committee is squarely
* behind the fixed sized types; the "least" and "fast" types are still being
* discussed. The probability that the "fast" types may be removed before
* the standard is finalized is high enough that they are not currently
* implemented.
*/
#if defined _STDINT_NEED_INT_LEAST_T
typedef int8_t int_least8_t;
typedef int16_t int_least16_t;
typedef int32_t int_least32_t;
#ifdef _HAVE_UINT64_T
typedef int64_t int_least64_t;
#endif
typedef uint8_t uint_least8_t;
typedef uint16_t uint_least16_t;
typedef uint32_t uint_least32_t;
#ifdef _HAVE_UINT64_T
typedef uint64_t uint_least64_t;
#endif
/* least types */
#endif
#if defined _STDINT_NEED_INT_FAST_T
typedef int8_t int_fast8_t;
typedef int int_fast16_t;
typedef int32_t int_fast32_t;
#ifdef _HAVE_UINT64_T
typedef int64_t int_fast64_t;
#endif
typedef uint8_t uint_fast8_t;
typedef unsigned uint_fast16_t;
typedef uint32_t uint_fast32_t;
#ifdef _HAVE_UINT64_T
typedef uint64_t uint_fast64_t;
#endif
/* fast types */
#endif
#ifdef _STDINT_NEED_INTMAX_T
#ifdef _HAVE_UINT64_T
typedef int64_t intmax_t;
typedef uint64_t uintmax_t;
#else
typedef long intmax_t;
typedef unsigned long uintmax_t;
#endif
#endif
#ifdef _STDINT_NEED_INTPTR_T
#ifndef __intptr_t_defined
#define __intptr_t_defined
/* we encourage using "long" to store pointer values, never use "int" ! */
#if _STDINT_LONG_MODEL+0 == 242 || _STDINT_LONG_MODEL+0 == 484
typedef unsigned int uintptr_t;
typedef int intptr_t;
#elif _STDINT_LONG_MODEL+0 == 244 || _STDINT_LONG_MODEL+0 == 444
typedef unsigned long uintptr_t;
typedef long intptr_t;
#elif _STDINT_LONG_MODEL+0 == 448 && defined _HAVE_UINT64_T
typedef uint64_t uintptr_t;
typedef int64_t intptr_t;
#else /* matches typical system types ILP32 and LP64 - but not IP16 or LLP64 */
typedef unsigned long uintptr_t;
typedef long intptr_t;
#endif
#endif
#endif
/* The ISO C99 standard specifies that in C++ implementations these
should only be defined if explicitly requested. */
#if !defined __cplusplus || defined __STDC_CONSTANT_MACROS
#ifndef UINT32_C
/* Signed. */
# define INT8_C(c) c
# define INT16_C(c) c
# define INT32_C(c) c
# ifdef _HAVE_LONGLONG_UINT64_T
# define INT64_C(c) c ## L
# else
# define INT64_C(c) c ## LL
# endif
/* Unsigned. */
# define UINT8_C(c) c ## U
# define UINT16_C(c) c ## U
# define UINT32_C(c) c ## U
# ifdef _HAVE_LONGLONG_UINT64_T
# define UINT64_C(c) c ## UL
# else
# define UINT64_C(c) c ## ULL
# endif
/* Maximal type. */
# ifdef _HAVE_LONGLONG_UINT64_T
# define INTMAX_C(c) c ## L
# define UINTMAX_C(c) c ## UL
# else
# define INTMAX_C(c) c ## LL
# define UINTMAX_C(c) c ## ULL
# endif
/* literalnumbers */
#endif
#endif
/* These limits are merily those of a two complement byte-oriented system */
/* Minimum of signed integral types. */
# define INT8_MIN (-128)
# define INT16_MIN (-32767-1)
# define INT32_MIN (-2147483647-1)
# define INT64_MIN (-__INT64_C(9223372036854775807)-1)
/* Maximum of signed integral types. */
# define INT8_MAX (127)
# define INT16_MAX (32767)
# define INT32_MAX (2147483647)
# define INT64_MAX (__INT64_C(9223372036854775807))
/* Maximum of unsigned integral types. */
# define UINT8_MAX (255)
# define UINT16_MAX (65535)
# define UINT32_MAX (4294967295U)
# define UINT64_MAX (__UINT64_C(18446744073709551615))
/* Minimum of signed integral types having a minimum size. */
# define INT_LEAST8_MIN INT8_MIN
# define INT_LEAST16_MIN INT16_MIN
# define INT_LEAST32_MIN INT32_MIN
# define INT_LEAST64_MIN INT64_MIN
/* Maximum of signed integral types having a minimum size. */
# define INT_LEAST8_MAX INT8_MAX
# define INT_LEAST16_MAX INT16_MAX
# define INT_LEAST32_MAX INT32_MAX
# define INT_LEAST64_MAX INT64_MAX
/* Maximum of unsigned integral types having a minimum size. */
# define UINT_LEAST8_MAX UINT8_MAX
# define UINT_LEAST16_MAX UINT16_MAX
# define UINT_LEAST32_MAX UINT32_MAX
# define UINT_LEAST64_MAX UINT64_MAX
/* shortcircuit*/
#endif
/* once */
#endif
#endif
STDINT_EOF
fi
if cmp -s $ac_stdint_h $ac_stdint 2>/dev/null; then
AC_MSG_NOTICE([$ac_stdint_h is unchanged])
else
ac_dir=`AS_DIRNAME(["$ac_stdint_h"])`
AS_MKDIR_P(["$ac_dir"])
rm -f $ac_stdint_h
mv $ac_stdint $ac_stdint_h
fi
],[# variables for create stdint.h replacement
PACKAGE="$PACKAGE"
VERSION="$VERSION"
ac_stdint_h="$ac_stdint_h"
_ac_stdint_h=AS_TR_CPP(_$PACKAGE-$ac_stdint_h)
ac_cv_stdint_message="$ac_cv_stdint_message"
ac_cv_header_stdint_t="$ac_cv_header_stdint_t"
ac_cv_header_stdint_x="$ac_cv_header_stdint_x"
ac_cv_header_stdint_o="$ac_cv_header_stdint_o"
ac_cv_header_stdint_u="$ac_cv_header_stdint_u"
ac_cv_type_uint64_t="$ac_cv_type_uint64_t"
ac_cv_type_u_int64_t="$ac_cv_type_u_int64_t"
ac_cv_char_data_model="$ac_cv_char_data_model"
ac_cv_long_data_model="$ac_cv_long_data_model"
ac_cv_type_int_least32_t="$ac_cv_type_int_least32_t"
ac_cv_type_int_fast32_t="$ac_cv_type_int_fast32_t"
ac_cv_type_intmax_t="$ac_cv_type_intmax_t"
])
])

@ -162,7 +162,7 @@ SOFTWARE.
#define XK_Zen_Koho 0xFF3D /* Multiple/All Candidate(s) */
#define XK_Mae_Koho 0xFF3E /* Previous Candidate */
/* 0xFF31 thru 0xFF3F are under XK_KOREAN */
/* 0xFF31 through 0xFF3F are under XK_KOREAN */
/* Cursor control & motion */
@ -240,7 +240,7 @@ SOFTWARE.
/*
* Auxilliary Functions; note the duplicate definitions for left and right
* Auxiliary Functions; note the duplicate definitions for left and right
* function keys; Sun keyboards and a few other manufactures have such
* function key groups on the left and/or right sides of the keyboard.
* We've not found a keyboard with more than 35 function keys total.

@ -486,7 +486,7 @@ typedef struct _rfbClientRec {
authentication. If the right conditions are met this state will be
set (see the auth.c file) when rfbProcessClientInitMessage is called.
If the state is RFB_INITIALISATION_SHARED we should not expect to recieve
If the state is RFB_INITIALISATION_SHARED we should not expect to receive
any ClientInit message, but instead should proceed to the next stage
of initialisation as though an implicit ClientInit message was received
with a shared-flag of true. (There is currently no corresponding
@ -730,10 +730,10 @@ typedef struct _rfbClientRec {
#define Swap24(l) ((((l) & 0xff) << 16) | (((l) >> 16) & 0xff) | \
(((l) & 0x00ff00)))
#define Swap32(l) (((l) >> 24) | \
#define Swap32(l) ((((l) >> 24) & 0x000000ff)| \
(((l) & 0x00ff0000) >> 8) | \
(((l) & 0x0000ff00) << 8) | \
((l) << 24))
(((l) & 0x000000ff) << 24))
extern char rfbEndianTest;
@ -775,6 +775,7 @@ extern rfbBool webSocketsCheck(rfbClientPtr cl);
extern rfbBool webSocketCheckDisconnect(rfbClientPtr cl);
extern int webSocketsEncode(rfbClientPtr cl, const char *src, int len, char **dst);
extern int webSocketsDecode(rfbClientPtr cl, char *dst, int len);
extern rfbBool webSocketsHasDataInBuffer(rfbClientPtr cl);
#endif
/* rfbserver.c */
@ -1262,14 +1263,14 @@ rfbBool rfbUpdateClient(rfbClientPtr cl);
Try example.c: it outputs on which port it listens (default: 5900), so it is
display 0. To view, call @code vncviewer :0 @endcode
You should see a sheet with a gradient and "Hello World!" written on it. Try
to paint something. Note that everytime you click, there is some bigger blot,
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 @code vncviewer machine.where.example.runs.com:0 @endcode
or similar for the remote client. Now you are ready to type something. Be sure
that your mouse sits still, because everytime the mouse moves, the cursor is
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

@ -47,13 +47,13 @@
(*(char *)&client->endianTest ? ((((s) & 0xff) << 8) | (((s) >> 8) & 0xff)) : (s))
#define rfbClientSwap32IfLE(l) \
(*(char *)&client->endianTest ? ((((l) & 0xff000000) >> 24) | \
(*(char *)&client->endianTest ? ((((l) >> 24) & 0x000000ff) | \
(((l) & 0x00ff0000) >> 8) | \
(((l) & 0x0000ff00) << 8) | \
(((l) & 0x000000ff) << 24)) : (l))
#define rfbClientSwap64IfLE(l) \
(*(char *)&client->endianTest ? ((((l) & 0xff00000000000000ULL) >> 56) | \
(*(char *)&client->endianTest ? ((((l) >> 56 ) & 0x00000000000000ffULL) | \
(((l) & 0x00ff000000000000ULL) >> 40) | \
(((l) & 0x0000ff0000000000ULL) >> 24) | \
(((l) & 0x000000ff00000000ULL) >> 8) | \
@ -175,9 +175,17 @@ typedef rfbCredential* (*GetCredentialProc)(struct _rfbClient* client, int crede
typedef rfbBool (*MallocFrameBufferProc)(struct _rfbClient* client);
typedef void (*GotXCutTextProc)(struct _rfbClient* client, const char *text, int textlen);
typedef void (*BellProc)(struct _rfbClient* client);
/**
Called when a cursor shape update was received from the server. The decoded cursor shape
will be in client->rcSource. It's up to the application to do something with this, e.g. draw
into a viewer's window. If you want the server to draw the cursor into the framebuffer, be
careful not to announce remote cursor support, i.e. not include rfbEncodingXCursor or
rfbEncodingRichCursor in SetFormatAndEncodings().
*/
typedef void (*GotCursorShapeProc)(struct _rfbClient* client, int xhot, int yhot, int width, int height, int bytesPerPixel);
typedef void (*GotCopyRectProc)(struct _rfbClient* client, int src_x, int src_y, int w, int h, int dest_x, int dest_y);
typedef rfbBool (*LockWriteToTLSProc)(struct _rfbClient* client);
typedef rfbBool (*UnlockWriteToTLSProc)(struct _rfbClient* client);
typedef struct _rfbClient {
uint8_t* frameBuffer;
@ -272,6 +280,7 @@ typedef struct _rfbClient {
/* cursor.c */
/** Holds cursor shape data when received from server. */
uint8_t *rcSource, *rcMask;
/** private data pointer */
@ -358,10 +367,19 @@ typedef struct _rfbClient {
/* Output Window ID. When set, client application enables libvncclient to perform direct rendering in its window */
unsigned long outputWindow;
/** Hooks for optional protection WriteToTLS() by mutex */
LockWriteToTLSProc LockWriteToTLS;
UnlockWriteToTLSProc UnlockWriteToTLS;
} rfbClient;
/* cursor.c */
/**
* Handles XCursor and RichCursor shape updates from the server.
* We emulate cursor operating on the frame buffer (that is
* why we call it "software cursor"). This decodes the received cursor
* shape and hands it over to GotCursorShapeProc, if set.
*/
extern rfbBool HandleCursorShape(rfbClient* client,int xhot, int yhot, int width, int height, uint32_t enc);
/* listen.c */

@ -54,6 +54,27 @@
/* Define to 1 if you have the <unistd.h> header file. */
#cmakedefine LIBVNCSERVER_HAVE_UNISTD_H 1
/* Define to 1 if you have the `vfork' function. */
#cmakedefine LIBVNCSERVER_HAVE_VFORK 1
/* Define to 1 if you have the <vfork.h> header file. */
#cmakedefine LIBVNCSERVER_HAVE_VFORK_H 1
/* Define to 1 if you have the `vprintf' function. */
#cmakedefine LIBVNCSERVER_HAVE_VPRINTF 1
/* Define to 1 if `fork' works. */
#cmakedefine LIBVNCSERVER_HAVE_WORKING_FORK 1
/* Define to 1 if `vfork' works. */
#cmakedefine LIBVNCSERVER_HAVE_WORKING_VFORK 1
/* Define to 1 if you have the <ws2tcpip.h> header file. */
#cmakedefine LIBVNCSERVER_HAVE_WS2TCPIP_H 1
/* Enable IPv6 support */
#cmakedefine LIBVNCSERVER_IPv6 1
/* Need a typedef for in_addr_t */
#cmakedefine LIBVNCSERVER_NEED_INADDR_T 1

@ -61,6 +61,7 @@
* messages have to be explained by comments.
*/
#include <stdint.h>
#if defined(WIN32) && !defined(__MINGW32__)
#define LIBVNCSERVER_WORDS_BIGENDIAN
@ -71,7 +72,6 @@
#define SOCKET int
#else
#include <rfb/rfbconfig.h>
#include <rfb/rfbint.h>
#endif
#ifdef LIBVNCSERVER_HAVE_LIBZ
@ -82,10 +82,11 @@
#endif
#endif
/* some autotool versions do not properly prefix
WORDS_BIGENDIAN, so do that manually */
#ifdef WORDS_BIGENDIAN
#define LIBVNCSERVER_WORDS_BIGENDIAN
#if LIBVNCSERVER_HAVE_ENDIAN_H
# include <endian.h>
# if __BYTE_ORDER == __BIG_ENDIAN
# define LIBVNCSERVER_WORDS_BIGENDIAN 1
# endif
#endif
/* MS compilers don't have strncasecmp */
@ -93,8 +94,8 @@
#define strncasecmp _strnicmp
#endif
#define rfbMax(a,b) (((a)>(b))?(a):(b))
#if !defined(WIN32) || defined(__MINGW32__)
#define max(a,b) (((a)>(b))?(a):(b))
#ifdef LIBVNCSERVER_HAVE_SYS_TIME_H
#include <sys/time.h>
#endif
@ -109,10 +110,6 @@ typedef int8_t rfbBool;
#define TRUE -1
#endif
#ifdef _MSC_VER
#include <stdint.h>
#endif
typedef uint32_t rfbKeySym;
typedef uint32_t rfbPixel;
@ -124,7 +121,7 @@ typedef uint32_t in_addr_t;
#define INADDR_NONE ((in_addr_t) 0xffffffff)
#endif
#define MAX_ENCODINGS 21
#define MAX_ENCODINGS 64
#define rfbNetworkConnectionSuccess 0
#define rfbNetworkRFBConnectionSuccess 1
@ -890,21 +887,6 @@ typedef struct {
#endif
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
* h264 - h264 encoding. We have an rfbH264Header structure
* giving the number of bytes following. Finally the data follows is
* h264 encoded frame.
*/
typedef struct {
uint32_t nBytes;
uint32_t slice_type;
uint32_t width;
uint32_t height;
} rfbH264Header;
#define sz_rfbH264Header 16
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
* XCursor encoding. This is a special encoding used to transmit X-style
* cursor shapes from server to clients. Note that for this encoding,
@ -1100,7 +1082,7 @@ typedef struct _rfbFileTransferMsg {
#define rfbRErrorCmd 0xFFFFFFFF/* Error when a command fails on remote side (ret in "size" field) */
#define sz_rfbBlockSize 8192 /* Size of a File Transfer packet (before compression) */
#define rfbZipDirectoryPrefix "!UVNCDIR-\0" /* Transfered directory are zipped in a file with this prefix. Must end with "-" */
#define rfbZipDirectoryPrefix "!UVNCDIR-\0" /* Transferred directory are zipped in a file with this prefix. Must end with "-" */
#define sz_rfbZipDirectoryPrefix 9
#define rfbDirPrefix "[ "
#define rfbDirSuffix " ]"

@ -1,7 +1,8 @@
check_PROGRAMS =
if HAVE_LIBJPEG
# TurboJPEG wrapper tests
noinst_PROGRAMS=tjunittest tjbench
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 \
@ -19,7 +20,7 @@ endif
copyrecttest_LDADD=$(LDADD) -lm
check_PROGRAMS=$(ENCODINGS_TEST) cargstest copyrecttest $(BACKGROUND_TEST) \
check_PROGRAMS += $(ENCODINGS_TEST) cargstest copyrecttest $(BACKGROUND_TEST) \
cursortest
test: encodingstest$(EXEEXT) cargstest$(EXEEXT) copyrecttest$(EXEEXT)

@ -41,5 +41,5 @@ If the above Java applet does not work, you can also try the new JavaScript-only
<br/>
<br/>
<br/>
<A href="http://libvncserver.sf.net/">LibVNCServer/LibVNCClient Homepage</A>
<A href="https://libvnc.github.io/">LibVNCServer/LibVNCClient Homepage</A>
</HTML>

@ -42,9 +42,9 @@ Send full Java Console output for failures.
Tips:
When doing single-port proxy connections (e.g. both VNC and HTTPS
thru port 5900) it helps to move through the 'do you trust this site'
through port 5900) it helps to move through the 'do you trust this site'
dialogs quickly. x11vnc has to wait to see if the traffic is VNC or
HTTP and this can cause timeouts if you don't move thru them quickly.
HTTP and this can cause timeouts if you don't move through them quickly.
You may have to restart your browser completely if it gets into a
weird state. For one case we saw the JVM requesting VncViewer.class
@ -172,7 +172,7 @@ Both TightVNC and UltraVNC Java viewers:
Set to do a special HTTP GET (/request.https.vnc.connection)
to the vnc server that will cause it to switch to VNC instead.
This is to speedup/make more robust, the single port HTTPS and VNC
mode of x11vnc (e.g. both services thru port 5900, etc)
mode of x11vnc (e.g. both services through port 5900, etc)
urlPrefix
string, default: none

@ -25,7 +25,7 @@ fails in the proxy environment.
The applet is not allowed to open a socket connection to the proxy (since
that would let it connect to just about any host, e.g. CONNECT method).
This is indpendent of SSL but of course fails for that socket connection
This is independent of SSL but of course fails for that socket connection
as well. I.e. this is a problem for non-SSL VNC Viewers as well.
Solution? Sign the applet and have the user click on "Yes" that they

@ -91,7 +91,7 @@
#
# [user1@]host1[:port1],[user2@]host2[:port2]
#
# in which case a ssh to host1 and thru it via a -L redir a 2nd
# in which case a ssh to host1 and through it via a -L redir a 2nd
# ssh is established to host2.
#
# Examples:
@ -109,10 +109,10 @@
#
# -sshargs "args" pass "args" to the ssh process, e.g. -L/-R port redirs.
#
# -sshssl Tunnel the SSL connection thru a SSH connection. The tunnel as
# under -ssh is set up and the SSL connection goes thru it. Use
# -sshssl Tunnel the SSL connection through a SSH connection. The tunnel as
# under -ssh is set up and the SSL connection goes through it. Use
# this if you want to have and end-to-end SSL connection but must
# go thru a SSH gateway host (e.g. not the vnc server). Or use
# go through a SSH gateway host (e.g. not the vnc server). Or use
# this if you need to tunnel additional services via -R and -L
# (see -sshargs above).
#
@ -351,7 +351,7 @@ if [ "X$SKIP_STUNNEL_NO_SYSLOG" = "X" ]; then
STUNNEL_NO_SYSLOG=1; export STUNNEL_NO_SYSLOG
fi
# this is the -t ssh option (gives better keyboard response thru SSH tunnel)
# this is the -t ssh option (gives better keyboard response through SSH tunnel)
targ="-t"
if [ "X$SS_VNCVIEWER_NO_T" != "X" ]; then
targ=""

@ -978,7 +978,7 @@ diff -Naur JavaViewer.orig/FTPFrame.java JavaViewer/FTPFrame.java
+ }
+ String sFileName = ((String) selected);
// sf@2004 - Directory can't be transfered
// sf@2004 - Directory can't be transferred
if (sFileName.substring(0, 2).equals(" [") && sFileName.substring((sFileName.length() - 1), sFileName.length()).equals("]"))
{
- JOptionPane.showMessageDialog(null, (String)"Directory Transfer is not yet available in this version...", "FileTransfer Info", JOptionPane.INFORMATION_MESSAGE);
@ -1036,7 +1036,7 @@ diff -Naur JavaViewer.orig/FTPFrame.java JavaViewer/FTPFrame.java
+ return null;
+ }
+
+ // sf@2004 - Directory can't be transfered
+ // sf@2004 - Directory can't be transferred
+ if (sFileName.substring(0, 2).equals(" [") && sFileName.substring((sFileName.length() - 1), sFileName.length()).equals("]"))
+ {
+ return null;
@ -1084,7 +1084,7 @@ diff -Naur JavaViewer.orig/FTPFrame.java JavaViewer/FTPFrame.java
+ }
+ String sFileName = ((String) selected);
// sf@2004 - Directory can't be transfered
// sf@2004 - Directory can't be transferred
if (sFileName.substring(0, 2).equals(" [") && sFileName.substring((sFileName.length() - 1), sFileName.length()).equals("]"))
{
- JOptionPane.showMessageDialog(null, (String)"Directory Transfer is not yet available in this version...", "FileTransfer Info", JOptionPane.INFORMATION_MESSAGE);

@ -76,7 +76,7 @@ var Display;
}
if (this._prefer_js === null) {
Util.Info("Prefering javascript operations");
Util.Info("Preferring javascript operations");
this._prefer_js = true;
}
@ -318,7 +318,7 @@ var Display;
// Clearing the current viewport first fixes the issue
this._drawCtx.clearRect(0, 0, this._viewportLoc.w, this._viewportLoc.h);
}
this.resize(640, 20);
this.resize(240, 20);
this._drawCtx.clearRect(0, 0, this._viewportLoc.w, this._viewportLoc.h);
}
@ -713,6 +713,12 @@ var Display;
cur.push(rgb[1]); // green
cur.push(rgb[0]); // red
cur.push(alpha); // alpha
} else {
idx = ((w0 * y) + x) * 4;
cur.push(pixels[idx + 2]); // blue
cur.push(pixels[idx + 1]); // green
cur.push(pixels[idx]); // red
cur.push(alpha); // alpha
}
}
}

@ -31,7 +31,7 @@ var kbdUtil = (function() {
function hasShortcutModifier(charModifier, currentModifiers) {
var mods = {};
for (var key in currentModifiers) {
if (parseInt(key) !== 0xffe1) {
if (parseInt(key) !== XK_Shift_L) {
mods[key] = currentModifiers[key];
}
}
@ -65,24 +65,18 @@ var kbdUtil = (function() {
// Helper object tracking modifier key state
// and generates fake key events to compensate if it gets out of sync
function ModifierSync(charModifier) {
var ctrl = 0xffe3;
var alt = 0xffe9;
var altGr = 0xfe03;
var shift = 0xffe1;
var meta = 0xffe7;
if (!charModifier) {
if (isMac()) {
// on Mac, Option (AKA Alt) is used as a char modifier
charModifier = [alt];
charModifier = [XK_Alt_L];
}
else if (isWindows()) {
// on Windows, Ctrl+Alt is used as a char modifier
charModifier = [alt, ctrl];
charModifier = [XK_Alt_L, XK_Control_L];
}
else if (isLinux()) {
// on Linux, AltGr is used as a char modifier
charModifier = [altGr];
// on Linux, ISO Level 3 Shift (AltGr) is used as a char modifier
charModifier = [XK_ISO_Level3_Shift];
}
else {
charModifier = [];
@ -90,11 +84,11 @@ var kbdUtil = (function() {
}
var state = {};
state[ctrl] = false;
state[alt] = false;
state[altGr] = false;
state[shift] = false;
state[meta] = false;
state[XK_Control_L] = false;
state[XK_Alt_L] = false;
state[XK_ISO_Level3_Shift] = false;
state[XK_Shift_L] = false;
state[XK_Meta_L] = false;
function sync(evt, keysym) {
var result = [];
@ -102,25 +96,30 @@ var kbdUtil = (function() {
return {keysym: keysyms.lookup(keysym), type: state[keysym] ? 'keydown' : 'keyup'};
}
if (evt.ctrlKey !== undefined && evt.ctrlKey !== state[ctrl] && keysym !== ctrl) {
state[ctrl] = evt.ctrlKey;
result.push(syncKey(ctrl));
if (evt.ctrlKey !== undefined &&
evt.ctrlKey !== state[XK_Control_L] && keysym !== XK_Control_L) {
state[XK_Control_L] = evt.ctrlKey;
result.push(syncKey(XK_Control_L));
}
if (evt.altKey !== undefined && evt.altKey !== state[alt] && keysym !== alt) {
state[alt] = evt.altKey;
result.push(syncKey(alt));
if (evt.altKey !== undefined &&
evt.altKey !== state[XK_Alt_L] && keysym !== XK_Alt_L) {
state[XK_Alt_L] = evt.altKey;
result.push(syncKey(XK_Alt_L));
}
if (evt.altGraphKey !== undefined && evt.altGraphKey !== state[altGr] && keysym !== altGr) {
state[altGr] = evt.altGraphKey;
result.push(syncKey(altGr));
if (evt.altGraphKey !== undefined &&
evt.altGraphKey !== state[XK_ISO_Level3_Shift] && keysym !== XK_ISO_Level3_Shift) {
state[XK_ISO_Level3_Shift] = evt.altGraphKey;
result.push(syncKey(XK_ISO_Level3_Shift));
}
if (evt.shiftKey !== undefined && evt.shiftKey !== state[shift] && keysym !== shift) {
state[shift] = evt.shiftKey;
result.push(syncKey(shift));
if (evt.shiftKey !== undefined &&
evt.shiftKey !== state[XK_Shift_L] && keysym !== XK_Shift_L) {
state[XK_Shift_L] = evt.shiftKey;
result.push(syncKey(XK_Shift_L));
}
if (evt.metaKey !== undefined && evt.metaKey !== state[meta] && keysym !== meta) {
state[meta] = evt.metaKey;
result.push(syncKey(meta));
if (evt.metaKey !== undefined &&
evt.metaKey !== state[XK_Meta_L] && keysym !== XK_Meta_L) {
state[XK_Meta_L] = evt.metaKey;
result.push(syncKey(XK_Meta_L));
}
return result;
}
@ -211,21 +210,21 @@ var kbdUtil = (function() {
return shiftPressed ? keycode : keycode + 32; // A-Z
}
if (keycode >= 0x60 && keycode <= 0x69) {
return 0xffb0 + (keycode - 0x60); // numpad 0-9
return XK_KP_0 + (keycode - 0x60); // numpad 0-9
}
switch(keycode) {
case 0x20: return 0x20; // space
case 0x6a: return 0xffaa; // multiply
case 0x6b: return 0xffab; // add
case 0x6c: return 0xffac; // separator
case 0x6d: return 0xffad; // subtract
case 0x6e: return 0xffae; // decimal
case 0x6f: return 0xffaf; // divide
case 0xbb: return 0x2b; // +
case 0xbc: return 0x2c; // ,
case 0xbd: return 0x2d; // -
case 0xbe: return 0x2e; // .
case 0x20: return XK_space;
case 0x6a: return XK_KP_Multiply;
case 0x6b: return XK_KP_Add;
case 0x6c: return XK_KP_Separator;
case 0x6d: return XK_KP_Subtract;
case 0x6e: return XK_KP_Decimal;
case 0x6f: return XK_KP_Divide;
case 0xbb: return XK_plus;
case 0xbc: return XK_comma;
case 0xbd: return XK_minus;
case 0xbe: return XK_period;
}
return nonCharacterKey({keyCode: keycode});
@ -239,37 +238,38 @@ var kbdUtil = (function() {
var keycode = evt.keyCode;
if (keycode >= 0x70 && keycode <= 0x87) {
return 0xffbe + keycode - 0x70; // F1-F24
return XK_F1 + keycode - 0x70; // F1-F24
}
switch (keycode) {
case 8 : return 0xFF08; // BACKSPACE
case 13 : return 0xFF0D; // ENTER
case 9 : return 0xFF09; // TAB
case 27 : return 0xFF1B; // ESCAPE
case 46 : return 0xFFFF; // DELETE
case 36 : return 0xFF50; // HOME
case 35 : return 0xFF57; // END
case 33 : return 0xFF55; // PAGE_UP
case 34 : return 0xFF56; // PAGE_DOWN
case 45 : return 0xFF63; // INSERT
case 37 : return 0xFF51; // LEFT
case 38 : return 0xFF52; // UP
case 39 : return 0xFF53; // RIGHT
case 40 : return 0xFF54; // DOWN
case 16 : return 0xFFE1; // SHIFT
case 17 : return 0xFFE3; // CONTROL
case 18 : return 0xFFE9; // Left ALT (Mac Option)
case 224 : return 0xFE07; // Meta
case 225 : return 0xFE03; // AltGr
case 91 : return 0xFFEC; // Super_L (Win Key)
case 92 : return 0xFFED; // Super_R (Win Key)
case 93 : return 0xFF67; // Menu (Win Menu), Mac Command
case 8 : return XK_BackSpace;
case 13 : return XK_Return;
case 9 : return XK_Tab;
case 27 : return XK_Escape;
case 46 : return XK_Delete;
case 36 : return XK_Home;
case 35 : return XK_End;
case 33 : return XK_Page_Up;
case 34 : return XK_Page_Down;
case 45 : return XK_Insert;
case 37 : return XK_Left;
case 38 : return XK_Up;
case 39 : return XK_Right;
case 40 : return XK_Down;
case 16 : return XK_Shift_L;
case 17 : return XK_Control_L;
case 18 : return XK_Alt_L; // also: Option-key on Mac
case 224 : return XK_Meta_L;
case 225 : return XK_ISO_Level3_Shift; // AltGr
case 91 : return XK_Super_L; // also: Windows-key
case 92 : return XK_Super_R; // also: Windows-key
case 93 : return XK_Menu; // also: Windows-Menu, Command on Mac
default: return null;
}
}

@ -170,6 +170,8 @@ XK_Super_R = 0xffec, /* Right super */
XK_Hyper_L = 0xffed, /* Left hyper */
XK_Hyper_R = 0xffee, /* Right hyper */
XK_ISO_Level3_Shift = 0xfe03, /* AltGr */
/*
* Latin 1
* (ISO/IEC 8859-1 = Unicode U+0020..U+00FF)

@ -252,12 +252,12 @@ var RFB;
Util.Info("Sending Ctrl-Alt-Del");
var arr = [];
arr = arr.concat(RFB.messages.keyEvent(0xFFE3, 1)); // Control
arr = arr.concat(RFB.messages.keyEvent(0xFFE9, 1)); // Alt
arr = arr.concat(RFB.messages.keyEvent(0xFFFF, 1)); // Delete
arr = arr.concat(RFB.messages.keyEvent(0xFFFF, 0)); // Delete
arr = arr.concat(RFB.messages.keyEvent(0xFFE9, 0)); // Alt
arr = arr.concat(RFB.messages.keyEvent(0xFFE3, 0)); // Control
arr = arr.concat(RFB.messages.keyEvent(XK_Control_L, 1));
arr = arr.concat(RFB.messages.keyEvent(XK_Alt_L, 1));
arr = arr.concat(RFB.messages.keyEvent(XK_Delete, 1));
arr = arr.concat(RFB.messages.keyEvent(XK_Delete, 0));
arr = arr.concat(RFB.messages.keyEvent(XK_Alt_L, 0));
arr = arr.concat(RFB.messages.keyEvent(XK_Control_L, 0));
this._sock.send(arr);
},
@ -1496,8 +1496,7 @@ var RFB;
// Weird: ignore blanks are RAW
Util.Debug(" Ignoring blank after RAW");
} else {
this._display.fillRect(x, y, w, h, rQ, rQi);
rQi += this._FBU.bytes - 1;
this._display.fillRect(x, y, w, h, this._FBU.background);
}
} else if (this._FBU.subencoding & 0x01) { // Raw
this._display.blitImage(x, y, w, h, rQ, rQi);

@ -22,7 +22,7 @@ var UI;
"keysymdef.js", "keyboard.js", "input.js", "display.js",
"jsunzip.js", "rfb.js", "keysym.js"]);
var UI = {
UI = {
rfb_state : 'loaded',
settingsOpen : false,
@ -883,7 +883,7 @@ var UI;
$D('showKeyboard').className = "noVNC_status_button";
//Weird bug in iOS if you change keyboardVisible
//here it does not actually occur so next time
//you click keyboard icon it doesnt work.
//you click keyboard icon it doesn't work.
UI.hideKeyboardTimeout = setTimeout(function() { UI.setKeyboard(); },100);
},

@ -1,43 +0,0 @@
/*
* noVNC: HTML5 VNC client
* Copyright (C) 2012 Joel Martin
* Licensed under LGPL-3 (see LICENSE.txt)
*
* See README.md for usage and integration instructions.
*/
/*jslint evil: true */
/*global window, document, INCLUDE_URI */
/*
* Load supporting scripts
*/
function get_INCLUDE_URI() {
return (typeof INCLUDE_URI !== "undefined") ? INCLUDE_URI : "include/";
}
(function () {
"use strict";
var extra = "", start, end;
start = "<script src='" + get_INCLUDE_URI();
end = "'><\/script>";
// Uncomment to activate firebug lite
//extra += "<script src='http://getfirebug.com/releases/lite/1.2/" +
// "firebug-lite-compressed.js'><\/script>";
extra += start + "util.js" + end;
extra += start + "webutil.js" + end;
extra += start + "base64.js" + end;
extra += start + "websock.js" + end;
extra += start + "des.js" + end;
extra += start + "input.js" + end;
extra += start + "display.js" + end;
extra += start + "rfb.js" + end;
extra += start + "jsunzip.js" + end;
document.write(extra);
}());

@ -77,7 +77,7 @@
// Load supporting scripts
Util.load_scripts(["webutil.js", "base64.js", "websock.js", "des.js",
"keysymdef.js", "keyboard.js", "input.js", "display.js",
"jsunzip.js", "rfb.js"]);
"jsunzip.js", "rfb.js", "keysym.js"]);
var rfb;

Loading…
Cancel
Save