aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.travis.yml2
-rw-r--r--CMakeLists.txt4
-rw-r--r--common/network/TcpSocket.cxx2
-rw-r--r--common/rfb/CMsgReader.cxx12
-rw-r--r--common/rfb/CSecurityTLS.cxx4
-rw-r--r--common/rfb/Cursor.cxx35
-rw-r--r--common/rfb/SSecurityPlain.cxx2
-rw-r--r--common/rfb/TightDecoder.cxx13
-rw-r--r--common/rfb/VNCSConnectionST.cxx125
-rw-r--r--common/rfb/VNCSConnectionST.h1
-rwxr-xr-xcontrib/packages/deb/ubuntu-trusty/debian/rules6
-rw-r--r--contrib/packages/deb/ubuntu-xenial/debian/rules12
-rw-r--r--contrib/packages/rpm/el7/SPECS/tigervnc.spec11
-rw-r--r--tests/encperf.cxx5
-rw-r--r--unix/tx/TXWindow.cxx16
-rw-r--r--unix/vncpasswd/vncpasswd.cxx15
-rw-r--r--unix/x0vncserver/x0vncserver.cxx3
-rw-r--r--unix/x0vncserver/x0vncserver.man4
-rw-r--r--unix/xserver/hw/vnc/vncExtInit.cc4
-rw-r--r--unix/xserver/hw/vnc/vncSelection.c2
-rw-r--r--unix/xserver/hw/vnc/xvnc.c9
-rw-r--r--vncviewer/DesktopWindow.cxx4
-rw-r--r--vncviewer/OptionsDialog.cxx2
-rw-r--r--vncviewer/ServerDialog.cxx10
-rw-r--r--vncviewer/gettext.h31
-rw-r--r--vncviewer/parameters.cxx29
-rw-r--r--vncviewer/vncviewer.cxx2
27 files changed, 220 insertions, 145 deletions
diff --git a/.travis.yml b/.travis.yml
index 74878fca..ceafcbb7 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -16,5 +16,5 @@ before_install:
- popd
script:
- - cmake . && make
+ - cmake -DCMAKE_BUILD_TYPE=Debug . && make
- cd java && cmake . && make
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 8a89d454..7a9a7ce1 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -74,8 +74,8 @@ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wformat=2")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wformat=2")
# Make sure we catch these issues whilst developing
IF(CMAKE_BUILD_TYPE MATCHES Debug)
- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror")
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror -Werror=vla")
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Werror=vla")
ENDIF()
option(ENABLE_ASAN "Enable address sanitizer support" OFF)
diff --git a/common/network/TcpSocket.cxx b/common/network/TcpSocket.cxx
index 51d77c76..9e277cbb 100644
--- a/common/network/TcpSocket.cxx
+++ b/common/network/TcpSocket.cxx
@@ -736,7 +736,7 @@ char* TcpFilter::patternToStr(const TcpFilter::Pattern& p) {
buffer + 1, sizeof (buffer) - 2, NULL, 0, NI_NUMERICHOST);
strcat(buffer, "]");
addr.buf = rfb::strDup(buffer);
- } else if (p.address.u.sa.sa_family == AF_UNSPEC)
+ } else
addr.buf = rfb::strDup("");
char action;
diff --git a/common/rfb/CMsgReader.cxx b/common/rfb/CMsgReader.cxx
index 1d359d2c..e42546d4 100644
--- a/common/rfb/CMsgReader.cxx
+++ b/common/rfb/CMsgReader.cxx
@@ -210,7 +210,7 @@ void CMsgReader::readSetXCursor(int width, int height, const Point& hotspot)
if (width > maxCursorSize || height > maxCursorSize)
throw Exception("Too big cursor");
- rdr::U8 buf[width*height*4];
+ rdr::U8Array rgba(width*height*4);
if (width * height > 0) {
rdr::U8 pr, pg, pb;
@@ -235,7 +235,7 @@ void CMsgReader::readSetXCursor(int width, int height, const Point& hotspot)
is->readBytes(mask.buf, mask_len);
int maskBytesPerRow = (width+7)/8;
- out = buf;
+ out = rgba.buf;
for (y = 0;y < height;y++) {
for (x = 0;x < width;x++) {
int byte = y * maskBytesPerRow + x / 8;
@@ -261,7 +261,7 @@ void CMsgReader::readSetXCursor(int width, int height, const Point& hotspot)
}
}
- handler->setCursor(width, height, hotspot, buf);
+ handler->setCursor(width, height, hotspot, rgba.buf);
}
void CMsgReader::readSetCursor(int width, int height, const Point& hotspot)
@@ -275,7 +275,7 @@ void CMsgReader::readSetCursor(int width, int height, const Point& hotspot)
rdr::U8Array mask(mask_len);
int x, y;
- rdr::U8 buf[width*height*4];
+ rdr::U8Array rgba(width*height*4);
rdr::U8* in;
rdr::U8* out;
@@ -284,7 +284,7 @@ void CMsgReader::readSetCursor(int width, int height, const Point& hotspot)
int maskBytesPerRow = (width+7)/8;
in = data.buf;
- out = buf;
+ out = rgba.buf;
for (y = 0;y < height;y++) {
for (x = 0;x < width;x++) {
int byte = y * maskBytesPerRow + x / 8;
@@ -302,7 +302,7 @@ void CMsgReader::readSetCursor(int width, int height, const Point& hotspot)
}
}
- handler->setCursor(width, height, hotspot, buf);
+ handler->setCursor(width, height, hotspot, rgba.buf);
}
void CMsgReader::readSetCursorWithAlpha(int width, int height, const Point& hotspot)
diff --git a/common/rfb/CSecurityTLS.cxx b/common/rfb/CSecurityTLS.cxx
index 000331c0..d6a8d7f8 100644
--- a/common/rfb/CSecurityTLS.cxx
+++ b/common/rfb/CSecurityTLS.cxx
@@ -95,9 +95,9 @@ void CSecurityTLS::setDefaults()
delete [] homeDir;
if (!fileexists(caDefault.buf))
- X509CA.setDefaultStr(strdup(caDefault.buf));
+ X509CA.setDefaultStr(caDefault.buf);
if (!fileexists(crlDefault.buf))
- X509CRL.setDefaultStr(strdup(crlDefault.buf));
+ X509CRL.setDefaultStr(crlDefault.buf);
}
void CSecurityTLS::shutdown(bool needbye)
diff --git a/common/rfb/Cursor.cxx b/common/rfb/Cursor.cxx
index 99df82d6..d7b536de 100644
--- a/common/rfb/Cursor.cxx
+++ b/common/rfb/Cursor.cxx
@@ -76,7 +76,7 @@ static unsigned short srgb_to_lin(unsigned char srgb)
}
// Floyd-Steinberg dithering
-static void dither(int width, int height, int* data)
+static void dither(int width, int height, rdr::S32* data)
{
for (int y = 0; y < height; y++) {
for (int x_ = 0; x_ < width; x_++) {
@@ -122,31 +122,33 @@ static void dither(int width, int height, int* data)
rdr::U8* Cursor::getBitmap() const
{
// First step is converting to luminance
- int luminance[width()*height()];
- int *lum_ptr = luminance;
+ rdr::S32Array luminance(width()*height());
+ rdr::S32 *lum_ptr = luminance.buf;
const rdr::U8 *data_ptr = data;
for (int y = 0; y < height(); y++) {
for (int x = 0; x < width(); x++) {
+ rdr::S32 lum;
+
// Use BT.709 coefficients for grayscale
- *lum_ptr = 0;
- *lum_ptr += (int)srgb_to_lin(data_ptr[0]) * 6947; // 0.2126
- *lum_ptr += (int)srgb_to_lin(data_ptr[1]) * 23436; // 0.7152
- *lum_ptr += (int)srgb_to_lin(data_ptr[2]) * 2366; // 0.0722
- *lum_ptr /= 32768;
+ lum = 0;
+ lum += (rdr::U32)srgb_to_lin(data_ptr[0]) * 6947; // 0.2126
+ lum += (rdr::U32)srgb_to_lin(data_ptr[1]) * 23436; // 0.7152
+ lum += (rdr::U32)srgb_to_lin(data_ptr[2]) * 2366; // 0.0722
+ lum /= 32768;
- lum_ptr++;
+ *lum_ptr++ = lum;
data_ptr += 4;
}
}
// Then diterhing
- dither(width(), height(), luminance);
+ dither(width(), height(), luminance.buf);
// Then conversion to a bit mask
rdr::U8Array source((width()+7)/8*height());
memset(source.buf, 0, (width()+7)/8*height());
int maskBytesPerRow = (width() + 7) / 8;
- lum_ptr = luminance;
+ lum_ptr = luminance.buf;
data_ptr = data;
for (int y = 0; y < height(); y++) {
for (int x = 0; x < width(); x++) {
@@ -165,25 +167,24 @@ rdr::U8* Cursor::getBitmap() const
rdr::U8* Cursor::getMask() const
{
// First step is converting to integer array
- int alpha[width()*height()];
- int *alpha_ptr = alpha;
+ rdr::S32Array alpha(width()*height());
+ rdr::S32 *alpha_ptr = alpha.buf;
const rdr::U8 *data_ptr = data;
for (int y = 0; y < height(); y++) {
for (int x = 0; x < width(); x++) {
- *alpha_ptr = (int)data_ptr[3] * 65535 / 255;
- alpha_ptr++;
+ *alpha_ptr++ = (rdr::U32)data_ptr[3] * 65535 / 255;
data_ptr += 4;
}
}
// Then diterhing
- dither(width(), height(), alpha);
+ dither(width(), height(), alpha.buf);
// Then conversion to a bit mask
rdr::U8Array mask((width()+7)/8*height());
memset(mask.buf, 0, (width()+7)/8*height());
int maskBytesPerRow = (width() + 7) / 8;
- alpha_ptr = alpha;
+ alpha_ptr = alpha.buf;
data_ptr = data;
for (int y = 0; y < height(); y++) {
for (int x = 0; x < width(); x++) {
diff --git a/common/rfb/SSecurityPlain.cxx b/common/rfb/SSecurityPlain.cxx
index 6d48b65c..6f72432a 100644
--- a/common/rfb/SSecurityPlain.cxx
+++ b/common/rfb/SSecurityPlain.cxx
@@ -41,7 +41,7 @@ StringParameter PasswordValidator::plainUsers
bool PasswordValidator::validUser(const char* username)
{
- CharArray users(strDup(plainUsers.getValueStr())), user;
+ CharArray users(plainUsers.getValueStr()), user;
while (users.buf) {
strSplit(users.buf, ',', &user.buf, &users.buf);
diff --git a/common/rfb/TightDecoder.cxx b/common/rfb/TightDecoder.cxx
index cc786f5b..548c1906 100644
--- a/common/rfb/TightDecoder.cxx
+++ b/common/rfb/TightDecoder.cxx
@@ -266,15 +266,16 @@ void TightDecoder::decodeRect(const Rect& r, const void* buffer,
buflen -= 1;
if (pf.is888()) {
- rdr::U8 tightPalette[palSize * 3];
+ size_t len = palSize * 3;
+ rdr::U8Array tightPalette(len);
- assert(buflen >= sizeof(tightPalette));
+ assert(buflen >= len);
- memcpy(tightPalette, bufptr, sizeof(tightPalette));
- bufptr += sizeof(tightPalette);
- buflen -= sizeof(tightPalette);
+ memcpy(tightPalette.buf, bufptr, len);
+ bufptr += len;
+ buflen -= len;
- pf.bufferFromRGB(palette, tightPalette, palSize);
+ pf.bufferFromRGB(palette, tightPalette.buf, palSize);
} else {
size_t len;
diff --git a/common/rfb/VNCSConnectionST.cxx b/common/rfb/VNCSConnectionST.cxx
index 8758362c..dbbf1d80 100644
--- a/common/rfb/VNCSConnectionST.cxx
+++ b/common/rfb/VNCSConnectionST.cxx
@@ -871,7 +871,7 @@ void VNCSConnectionST::writeNoDataUpdate()
void VNCSConnectionST::writeDataUpdate()
{
- Region req, pending;
+ Region req;
UpdateInfo ui;
bool needNewUpdateInfo;
const RenderedCursor *cursor;
@@ -887,9 +887,6 @@ void VNCSConnectionST::writeDataUpdate()
if (req.is_empty())
return;
- // Get any framebuffer changes we haven't yet been informed of
- pending = server->getPendingRegion();
-
// Get the lists of updates. Prior to exporting the data to the `ui' object,
// getUpdateInfo() will normalize the `updates' object such way that its
// `changed' and `copied' regions would not intersect.
@@ -938,13 +935,8 @@ void VNCSConnectionST::writeDataUpdate()
// If there are queued updates then we cannot safely send an update
// without risking a partially updated screen
-
- if (!pending.is_empty()) {
- // However we might still be able to send a lossless refresh
- req.assign_subtract(pending);
- req.assign_subtract(ui.changed);
- req.assign_subtract(ui.copied);
-
+ if (!server->getPendingRegion().is_empty()) {
+ req.clear();
ui.changed.clear();
ui.copied.clear();
}
@@ -970,54 +962,97 @@ void VNCSConnectionST::writeDataUpdate()
damagedCursorRegion.assign_union(ui.changed.intersect(renderedCursorRect));
}
- // Return if there is nothing to send the client.
+ // If we don't have a normal update, then try a lossless refresh
if (ui.is_empty() && !writer()->needFakeUpdate()) {
- int eta;
+ writeLosslessRefresh();
+ return;
+ }
- // Any lossless refresh that needs handling?
- if (!encodeManager.needsLosslessRefresh(req))
- return;
+ // We have something to send, so let's get to it
- // Now? Or later?
- eta = encodeManager.getNextLosslessRefresh(req);
- if (eta > 0) {
- losslessTimer.start(eta);
- return;
- }
- }
+ writeRTTPing();
+
+ encodeManager.writeUpdate(ui, server->getPixelBuffer(), cursor);
writeRTTPing();
- if (!ui.is_empty())
- encodeManager.writeUpdate(ui, server->getPixelBuffer(), cursor);
- else {
- int nextUpdate;
+ // The request might be for just part of the screen, so we cannot
+ // just clear the entire update tracker.
+ updates.subtract(req);
- // FIXME: If continuous updates aren't used then the client might
- // be slower than frameRate in its requests and we could
- // afford a larger update size
- nextUpdate = server->msToNextUpdate();
- if (nextUpdate > 0) {
- size_t bandwidth, maxUpdateSize;
+ requested.clear();
+}
- // FIXME: Bandwidth estimation without congestion control
- bandwidth = congestion.getBandwidth();
+void VNCSConnectionST::writeLosslessRefresh()
+{
+ Region req, pending;
+ const RenderedCursor *cursor;
- // FIXME: Hard coded value for maximum CPU throughput
- if (bandwidth > 5000000)
- bandwidth = 5000000;
+ int nextRefresh, nextUpdate;
+ size_t bandwidth, maxUpdateSize;
- maxUpdateSize = bandwidth * nextUpdate / 1000;
- encodeManager.writeLosslessRefresh(req, server->getPixelBuffer(),
- cursor, maxUpdateSize);
- }
+ if (continuousUpdates)
+ req = cuRegion.union_(requested);
+ else
+ req = requested;
+
+ // If there are queued updates then we could not safely send an
+ // update without risking a partially updated screen, however we
+ // might still be able to send a lossless refresh
+ pending = server->getPendingRegion();
+ if (!pending.is_empty()) {
+ UpdateInfo ui;
+
+ // Don't touch the updates pending in the server core
+ req.assign_subtract(pending);
+
+ // Or any updates pending just for this connection
+ updates.getUpdateInfo(&ui, req);
+ req.assign_subtract(ui.changed);
+ req.assign_subtract(ui.copied);
+ }
+
+ // Any lossy area we can refresh?
+ if (!encodeManager.needsLosslessRefresh(req))
+ return;
+
+ // Right away? Or later?
+ nextRefresh = encodeManager.getNextLosslessRefresh(req);
+ if (nextRefresh > 0) {
+ losslessTimer.start(nextRefresh);
+ return;
}
+ // Prepare the cursor in case it overlaps with a region getting
+ // refreshed
+ cursor = NULL;
+ if (needRenderedCursor())
+ cursor = server->getRenderedCursor();
+
+ // FIXME: If continuous updates aren't used then the client might
+ // be slower than frameRate in its requests and we could
+ // afford a larger update size
+ nextUpdate = server->msToNextUpdate();
+
+ // Don't bother if we're about to send a real update
+ if (nextUpdate == 0)
+ return;
+
+ // FIXME: Bandwidth estimation without congestion control
+ bandwidth = congestion.getBandwidth();
+
+ // FIXME: Hard coded value for maximum CPU throughput
+ if (bandwidth > 5000000)
+ bandwidth = 5000000;
+
+ maxUpdateSize = bandwidth * nextUpdate / 1000;
+
writeRTTPing();
- // The request might be for just part of the screen, so we cannot
- // just clear the entire update tracker.
- updates.subtract(req);
+ encodeManager.writeLosslessRefresh(req, server->getPixelBuffer(),
+ cursor, maxUpdateSize);
+
+ writeRTTPing();
requested.clear();
}
diff --git a/common/rfb/VNCSConnectionST.h b/common/rfb/VNCSConnectionST.h
index c992d145..662d9f34 100644
--- a/common/rfb/VNCSConnectionST.h
+++ b/common/rfb/VNCSConnectionST.h
@@ -143,6 +143,7 @@ namespace rfb {
void writeFramebufferUpdate();
void writeNoDataUpdate();
void writeDataUpdate();
+ void writeLosslessRefresh();
void screenLayoutChange(rdr::U16 reason);
void setCursor();
diff --git a/contrib/packages/deb/ubuntu-trusty/debian/rules b/contrib/packages/deb/ubuntu-trusty/debian/rules
index 81f4f89d..ea9f1437 100755
--- a/contrib/packages/deb/ubuntu-trusty/debian/rules
+++ b/contrib/packages/deb/ubuntu-trusty/debian/rules
@@ -151,7 +151,7 @@ build-indep-stamp:
# anything for this package.
#/usr/bin/docbook-to-man debian/vnc.sgml > vnc.1
(cd media;make)
- (cd java;cmake -G"Unix Makefiles";make)
+ #(cd java;cmake -G"Unix Makefiles";make)
touch build-indep-stamp
@@ -213,8 +213,8 @@ install: build
mv $(CURDIR)/debian/xtigervncviewer/usr/share/man/man1/vncviewer.1 \
$(CURDIR)/debian/xtigervncviewer/usr/share/man/man1/xtigervncviewer.1
# tigervnc-java
- mkdir -p $(CURDIR)/debian/tigervnc-java/usr/share
- (cd java; make install DESTDIR=$(CURDIR)/debian/tigervnc-java/usr/share)
+ #mkdir -p $(CURDIR)/debian/tigervnc-java/usr/share
+ #(cd java; make install DESTDIR=$(CURDIR)/debian/tigervnc-java/usr/share)
#dh_movefiles
# Build architecture-independent files here.
diff --git a/contrib/packages/deb/ubuntu-xenial/debian/rules b/contrib/packages/deb/ubuntu-xenial/debian/rules
index 531a1c44..7509e7b4 100644
--- a/contrib/packages/deb/ubuntu-xenial/debian/rules
+++ b/contrib/packages/deb/ubuntu-xenial/debian/rules
@@ -138,7 +138,7 @@ build-indep-stamp:
# anything for this package.
#/usr/bin/docbook-to-man debian/vnc.sgml > vnc.1
(cd media;make)
- (cd java;cmake -G"Unix Makefiles";make)
+ #(cd java;cmake -G"Unix Makefiles";make)
touch build-indep-stamp
@@ -204,15 +204,15 @@ install: build
mv $(CURDIR)/debian/tigervncserver/usr/share/icons \
$(CURDIR)/debian/xtigervncviewer/usr/share/
# tigervnc-java
- mkdir -p $(CURDIR)/debian/tigervnc-java/usr/share
- (cd java; make install DESTDIR=$(CURDIR)/debian/tigervnc-java/usr/share)
+ #mkdir -p $(CURDIR)/debian/tigervnc-java/usr/share
+ #(cd java; make install DESTDIR=$(CURDIR)/debian/tigervnc-java/usr/share)
# install additional license files
mkdir -p $(CURDIR)/debian/xtigervncviewer/usr/share/doc/xtigervncviewer
cp $(CURDIR)/debian/tigervncserver/usr/share/doc/tigervnc-*/* \
$(CURDIR)/debian/xtigervncviewer/usr/share/doc/xtigervncviewer/
- mkdir -p $(CURDIR)/debian/tigervnc-java/usr/share/doc/tigervnc-java
- cp $(CURDIR)/debian/tigervncserver/usr/share/doc/tigervnc-*/* \
- $(CURDIR)/debian/tigervnc-java/usr/share/doc/tigervnc-java/
+ #mkdir -p $(CURDIR)/debian/tigervnc-java/usr/share/doc/tigervnc-java
+ #cp $(CURDIR)/debian/tigervncserver/usr/share/doc/tigervnc-*/* \
+ #$(CURDIR)/debian/tigervnc-java/usr/share/doc/tigervnc-java/
mkdir -p $(CURDIR)/debian/tigervncserver/usr/share/doc/tigervncserver
mv $(CURDIR)/debian/tigervncserver/usr/share/doc/tigervnc-*/* \
$(CURDIR)/debian/tigervncserver/usr/share/doc/tigervncserver/
diff --git a/contrib/packages/rpm/el7/SPECS/tigervnc.spec b/contrib/packages/rpm/el7/SPECS/tigervnc.spec
index 1b8630a6..77db8261 100644
--- a/contrib/packages/rpm/el7/SPECS/tigervnc.spec
+++ b/contrib/packages/rpm/el7/SPECS/tigervnc.spec
@@ -9,8 +9,8 @@
%endif
Name: tigervnc
-Version: 1.6.80
-Release: 1%{?snap:.%{snap}}%{?dist}
+Version: 1.9.80
+Release: 2%{?snap:.%{snap}}%{?dist}
Summary: A TigerVNC remote display system
Group: User Interface/Desktops
@@ -151,7 +151,7 @@ pushd unix/xserver
for all in `find . -type f -perm -001`; do
chmod -x "$all"
done
-patch -p1 -b --suffix .vnc < ../xserver119.patch
+patch -p1 -b --suffix .vnc < ../xserver120.patch
popd
# Don't use shebang in vncserver script.
@@ -219,7 +219,7 @@ autoreconf -fiv
--with-fontdir=%{_datadir}/X11/fonts \
--with-xkb-output=%{_localstatedir}/lib/xkb \
--enable-install-libxf86config \
- --enable-glx --disable-dri --enable-dri2 \
+ --enable-glx --disable-dri --enable-dri2 --disable-dri3 \
--disable-wayland \
--disable-present \
--disable-config-dbus \
@@ -354,6 +354,9 @@ fi
%endif
%changelog
+* Sun Nov 26 2018 Brian P. Hinz <bphinz@users.sourceforge.net> 1.9.80-2
+- Bumped Xorg version to 1.2.0
+
* Sun Jul 22 2018 Brian P. Hinz <bphinz@users.sourceforge.net> 1.9.80-1
- Updated fltk to latest version
diff --git a/tests/encperf.cxx b/tests/encperf.cxx
index 4e7038fd..733d55b6 100644
--- a/tests/encperf.cxx
+++ b/tests/encperf.cxx
@@ -423,8 +423,9 @@ int main(int argc, char **argv)
}
int runCount = count;
- struct stats runs[runCount];
- double values[runCount], dev[runCount];
+ struct stats *runs = new struct stats[runCount];
+ double *values = new double[runCount];
+ double *dev = new double[runCount];
double median, meddev;
if (fn == NULL) {
diff --git a/unix/tx/TXWindow.cxx b/unix/tx/TXWindow.cxx
index a6819179..6129840e 100644
--- a/unix/tx/TXWindow.cxx
+++ b/unix/tx/TXWindow.cxx
@@ -24,6 +24,7 @@
#include <list>
#include <stdio.h>
#include <stdlib.h>
+#include <vector>
#include <rfb/util.h>
std::list<TXWindow*> windows;
@@ -132,20 +133,20 @@ TXGlobalEventHandler* TXWindow::setGlobalEventHandler(TXGlobalEventHandler* h)
void TXWindow::getColours(Display* dpy, XColor* cols, int nCols)
{
- bool* got = new bool[nCols];
+ std::vector<bool> got;
+
bool failed = false;
int i;
for (i = 0; i < nCols; i++) {
if (XAllocColor(dpy, cmap, &cols[i])) {
- got[i] = true;
+ got.push_back(true);
} else {
- got[i] = false;
+ got.push_back(false);
failed = true;
}
}
if (!failed) {
- delete [] got;
return;
}
@@ -168,12 +169,13 @@ void TXWindow::getColours(Display* dpy, XColor* cols, int nCols)
int cmapSize = DisplayCells(dpy,DefaultScreen(dpy));
XColor* cm = new XColor[cmapSize];
- bool* shared = new bool[cmapSize];
- bool* usedAsNearest = new bool[cmapSize];
+ std::vector<bool> shared;
+ std::vector<bool> usedAsNearest;
for (i = 0; i < cmapSize; i++) {
cm[i].pixel = i;
- shared[i] = usedAsNearest[i] = false;
+ shared.push_back(false);
+ usedAsNearest.push_back(false);
}
XQueryColors(dpy, cmap, cm, cmapSize);
diff --git a/unix/vncpasswd/vncpasswd.cxx b/unix/vncpasswd/vncpasswd.cxx
index 8bd4e48e..3055223e 100644
--- a/unix/vncpasswd/vncpasswd.cxx
+++ b/unix/vncpasswd/vncpasswd.cxx
@@ -134,7 +134,7 @@ int main(int argc, char** argv)
} else if (argv[i][0] == '-') {
usage();
} else if (!fname) {
- fname = argv[i];
+ fname = strDup(argv[i]);
} else {
usage();
}
@@ -165,24 +165,37 @@ int main(int argc, char** argv)
FILE* fp = fopen(fname,"w");
if (!fp) {
fprintf(stderr,"Couldn't open %s for writing\n",fname);
+ delete [] fname;
+ delete obfuscated;
+ delete obfuscatedReadOnly;
exit(1);
}
chmod(fname, S_IRUSR|S_IWUSR);
if (fwrite(obfuscated->buf, obfuscated->length, 1, fp) != 1) {
fprintf(stderr,"Writing to %s failed\n",fname);
+ delete [] fname;
+ delete obfuscated;
+ delete obfuscatedReadOnly;
exit(1);
}
+ delete obfuscated;
+
if (obfuscatedReadOnly) {
if (fwrite(obfuscatedReadOnly->buf, obfuscatedReadOnly->length, 1, fp) != 1) {
fprintf(stderr,"Writing to %s failed\n",fname);
+ delete [] fname;
+ delete obfuscatedReadOnly;
exit(1);
}
}
fclose(fp);
+ delete [] fname;
+ delete obfuscatedReadOnly;
+
return 0;
}
}
diff --git a/unix/x0vncserver/x0vncserver.cxx b/unix/x0vncserver/x0vncserver.cxx
index cf2c35a2..eac9edfb 100644
--- a/unix/x0vncserver/x0vncserver.cxx
+++ b/unix/x0vncserver/x0vncserver.cxx
@@ -206,9 +206,6 @@ int main(int argc, char** argv)
Configuration::enableServerParams();
- // Disable configuration parameters which we do not support
- Configuration::removeParam("AcceptSetDesktopSize");
-
for (int i = 1; i < argc; i++) {
if (Configuration::setParam(argv[i]))
continue;
diff --git a/unix/x0vncserver/x0vncserver.man b/unix/x0vncserver/x0vncserver.man
index 5f1508c0..5aaf694e 100644
--- a/unix/x0vncserver/x0vncserver.man
+++ b/unix/x0vncserver/x0vncserver.man
@@ -187,6 +187,10 @@ Accept key press and release events from clients. Default is on.
Accept pointer press and release events from clients. Default is on.
.
.TP
+.B \-AcceptSetDesktopSize
+Accept requests to resize the size of the desktop. Default is on.
+.
+.TP
.B \-RemapKeys \fImapping
Sets up a keyboard mapping.
.I mapping
diff --git a/unix/xserver/hw/vnc/vncExtInit.cc b/unix/xserver/hw/vnc/vncExtInit.cc
index 286a04f6..20072f48 100644
--- a/unix/xserver/hw/vnc/vncExtInit.cc
+++ b/unix/xserver/hw/vnc/vncExtInit.cc
@@ -179,7 +179,7 @@ void vncExtensionInit(void)
listeners.push_back(new network::TcpListener(vncInetdSock));
vlog.info("inetd wait");
}
- } else if (rfbunixpath.getValueStr()[0] != '\0') {
+ } else if (((const char*)rfbunixpath)[0] != '\0') {
char path[PATH_MAX];
int mode = (int)rfbunixmode;
@@ -187,7 +187,7 @@ void vncExtensionInit(void)
strncpy(path, rfbunixpath, sizeof(path));
else
snprintf(path, sizeof(path), "%s.%d",
- rfbunixpath.getValueStr(), scr);
+ (const char*)rfbunixpath, scr);
path[sizeof(path)-1] = '\0';
listeners.push_back(new network::UnixListener(path, mode));
diff --git a/unix/xserver/hw/vnc/vncSelection.c b/unix/xserver/hw/vnc/vncSelection.c
index 51dfd9c6..4f3538d4 100644
--- a/unix/xserver/hw/vnc/vncSelection.c
+++ b/unix/xserver/hw/vnc/vncSelection.c
@@ -105,7 +105,7 @@ void vncClientCutText(const char* str, int len)
LOG_ERROR("Could not set PRIMARY selection");
}
- vncOwnSelection(xaCLIPBOARD);
+ rc = vncOwnSelection(xaCLIPBOARD);
if (rc != Success)
LOG_ERROR("Could not set CLIPBOARD selection");
}
diff --git a/unix/xserver/hw/vnc/xvnc.c b/unix/xserver/hw/vnc/xvnc.c
index 79b0e3d2..98c4a15b 100644
--- a/unix/xserver/hw/vnc/xvnc.c
+++ b/unix/xserver/hw/vnc/xvnc.c
@@ -766,10 +766,13 @@ vfbUninstallColormap(ColormapPtr pmap)
curpmap = (ColormapPtr) LookupIDByType(pmap->pScreen->defColormap,
RT_COLORMAP);
#else
- dixLookupResourceByType((void * *) &curpmap, pmap->pScreen->defColormap,
- RT_COLORMAP, serverClient, DixUnknownAccess);
+ int rc = dixLookupResourceByType((void * *) &curpmap, pmap->pScreen->defColormap,
+ RT_COLORMAP, serverClient, DixUnknownAccess);
+ if (rc != Success)
+ ErrorF("Failed to uninstall color map\n");
+ else
#endif
- (*pmap->pScreen->InstallColormap)(curpmap);
+ (*pmap->pScreen->InstallColormap)(curpmap);
}
}
}
diff --git a/vncviewer/DesktopWindow.cxx b/vncviewer/DesktopWindow.cxx
index d070b648..1843485a 100644
--- a/vncviewer/DesktopWindow.cxx
+++ b/vncviewer/DesktopWindow.cxx
@@ -103,12 +103,12 @@ DesktopWindow::DesktopWindow(int w, int h, const char *name,
int geom_x = 0, geom_y = 0;
if (strcmp(geometry, "") != 0) {
int matched;
- matched = sscanf(geometry.getValueStr(), "+%d+%d", &geom_x, &geom_y);
+ matched = sscanf((const char*)geometry, "+%d+%d", &geom_x, &geom_y);
if (matched == 2) {
force_position(1);
} else {
int geom_w, geom_h;
- matched = sscanf(geometry.getValueStr(), "%dx%d+%d+%d", &geom_w, &geom_h, &geom_x, &geom_y);
+ matched = sscanf((const char*)geometry, "%dx%d+%d+%d", &geom_w, &geom_h, &geom_x, &geom_y);
switch (matched) {
case 4:
force_position(1);
diff --git a/vncviewer/OptionsDialog.cxx b/vncviewer/OptionsDialog.cxx
index b018c95b..62b5d9c5 100644
--- a/vncviewer/OptionsDialog.cxx
+++ b/vncviewer/OptionsDialog.cxx
@@ -282,7 +282,7 @@ void OptionsDialog::loadOptions(void)
/* Screen */
int width, height;
- if (sscanf(desktopSize.getValueStr(), "%dx%d", &width, &height) != 2) {
+ if (sscanf((const char*)desktopSize, "%dx%d", &width, &height) != 2) {
desktopSizeCheckbox->value(false);
desktopWidthInput->value("1024");
desktopHeightInput->value("768");
diff --git a/vncviewer/ServerDialog.cxx b/vncviewer/ServerDialog.cxx
index de67f87b..fec17896 100644
--- a/vncviewer/ServerDialog.cxx
+++ b/vncviewer/ServerDialog.cxx
@@ -150,7 +150,7 @@ void ServerDialog::handleLoad(Fl_Widget *widget, void *data)
return;
}
- const char* filename = strdup(file_chooser->value());
+ const char* filename = file_chooser->value();
try {
dialog->serverName->value(loadViewerParameters(filename));
@@ -165,8 +165,8 @@ void ServerDialog::handleLoad(Fl_Widget *widget, void *data)
void ServerDialog::handleSaveAs(Fl_Widget *widget, void *data)
{
ServerDialog *dialog = (ServerDialog*)data;
- const char* servername = strdup(dialog->serverName->value());
- char* filename;
+ const char* servername = dialog->serverName->value();
+ const char* filename;
Fl_File_Chooser* file_chooser = new Fl_File_Chooser("", _("TigerVNC configuration (*.tigervnc)"),
2, _("Save the TigerVNC configuration to file"));
@@ -187,7 +187,7 @@ void ServerDialog::handleSaveAs(Fl_Widget *widget, void *data)
return;
}
- filename = strdup(file_chooser->value());
+ filename = file_chooser->value();
FILE* f = fopen(filename, "r");
if (f) {
@@ -235,7 +235,7 @@ void ServerDialog::handleCancel(Fl_Widget *widget, void *data)
void ServerDialog::handleConnect(Fl_Widget *widget, void *data)
{
ServerDialog *dialog = (ServerDialog*)data;
- const char* servername = strdup(dialog->serverName->value());
+ const char* servername = dialog->serverName->value();
dialog->hide();
diff --git a/vncviewer/gettext.h b/vncviewer/gettext.h
index ac4d7d59..768a6995 100644
--- a/vncviewer/gettext.h
+++ b/vncviewer/gettext.h
@@ -1,24 +1,26 @@
/* Convenience header for conditional use of GNU <libintl.h>.
- Copyright (C) 1995-1998, 2000-2002, 2004-2006, 2009-2011 Free Software Foundation, Inc.
+ Copyright (C) 1995-1998, 2000-2002, 2004-2006, 2009-2018 Free Software
+ Foundation, Inc.
- This program is free software: you can redistribute it and/or modify
+ 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.
+ the Free Software Foundation; either version 2, 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/>. */
+ You should have received a copy of the GNU General Public License along
+ with this program; if not, see <https://www.gnu.org/licenses/>. */
#ifndef _LIBGETTEXT_H
#define _LIBGETTEXT_H 1
-/* NLS can be disabled through the configure --disable-nls option. */
-#if ENABLE_NLS
+/* NLS can be disabled through the configure --disable-nls option
+ or through "#define ENABLE NLS 0" before including this file. */
+#if defined ENABLE_NLS && ENABLE_NLS
/* Get declarations of GNU message catalog functions. */
# include <libintl.h>
@@ -182,8 +184,9 @@ npgettext_aux (const char *domain,
#include <string.h>
-#if (((__GNUC__ >= 3 || __GNUG__ >= 2) && !defined __STRICT_ANSI__) \
- /* || __STDC_VERSION__ >= 199901L */ )
+#if (((__GNUC__ >= 3 || __GNUG__ >= 2) && !defined __STRICT_ANSI__ && !defined __cplusplus) \
+ /* || __STDC_VERSION__ == 199901L
+ || (__STDC_VERSION__ >= 201112L && !defined __STDC_NO_VLA__) */ )
# define _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS 1
#else
# define _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS 0
@@ -224,15 +227,17 @@ dcpgettext_expr (const char *domain,
if (msg_ctxt_id != NULL)
#endif
{
+ int found_translation;
memcpy (msg_ctxt_id, msgctxt, msgctxt_len - 1);
msg_ctxt_id[msgctxt_len - 1] = '\004';
memcpy (msg_ctxt_id + msgctxt_len, msgid, msgid_len);
translation = dcgettext (domain, msg_ctxt_id, category);
+ found_translation = (translation != msg_ctxt_id);
#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
if (msg_ctxt_id != buf)
free (msg_ctxt_id);
#endif
- if (translation != msg_ctxt_id)
+ if (found_translation)
return translation;
}
return msgid;
@@ -270,15 +275,17 @@ dcnpgettext_expr (const char *domain,
if (msg_ctxt_id != NULL)
#endif
{
+ int found_translation;
memcpy (msg_ctxt_id, msgctxt, msgctxt_len - 1);
msg_ctxt_id[msgctxt_len - 1] = '\004';
memcpy (msg_ctxt_id + msgctxt_len, msgid, msgid_len);
translation = dcngettext (domain, msg_ctxt_id, msgid_plural, n, category);
+ found_translation = !(translation == msg_ctxt_id || translation == msgid_plural);
#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
if (msg_ctxt_id != buf)
free (msg_ctxt_id);
#endif
- if (!(translation == msg_ctxt_id || translation == msgid_plural))
+ if (found_translation)
return translation;
}
return (n == 1 ? msgid : msgid_plural);
diff --git a/vncviewer/parameters.cxx b/vncviewer/parameters.cxx
index 51cce3d7..84278186 100644
--- a/vncviewer/parameters.cxx
+++ b/vncviewer/parameters.cxx
@@ -325,9 +325,10 @@ static void setKeyInt(const char *_name, const int _value, HKEY* hKey) {
static bool getKeyString(const char* _name, char* dest, size_t destSize, HKEY* hKey) {
- DWORD buffersize = 256;
- WCHAR value[destSize];
+ const DWORD buffersize = 256;
wchar_t name[buffersize];
+ WCHAR* value;
+ DWORD valuesize;
unsigned size = fl_utf8towc(_name, strlen(_name)+1, name, buffersize);
if (size >= buffersize) {
@@ -335,8 +336,11 @@ static bool getKeyString(const char* _name, char* dest, size_t destSize, HKEY* h
return false;
}
- LONG res = RegQueryValueExW(*hKey, name, 0, NULL, (LPBYTE)value, &buffersize);
+ value = new WCHAR[destSize];
+ valuesize = destSize;
+ LONG res = RegQueryValueExW(*hKey, name, 0, NULL, (LPBYTE)value, &valuesize);
if (res != ERROR_SUCCESS){
+ delete [] value;
if (res == ERROR_FILE_NOT_FOUND) {
// The value does not exist, defaults will be used.
} else {
@@ -346,18 +350,19 @@ static bool getKeyString(const char* _name, char* dest, size_t destSize, HKEY* h
return false;
}
- char utf8val[destSize];
- size = fl_utf8fromwc(utf8val, sizeof(utf8val), value, wcslen(value)+1);
- if (size >= sizeof(utf8val)) {
+ char* utf8val = new char[destSize];
+ size = fl_utf8fromwc(utf8val, destSize, value, wcslen(value)+1);
+ delete [] value;
+ if (size >= destSize) {
+ delete [] utf8val;
vlog.error(_("The parameter %s was too large to read from the registry"), _name);
return false;
}
- const char *ret = utf8val;
- if(decodeValue(ret, dest, destSize))
- return true;
- else
- return false;
+ bool ret = decodeValue(utf8val, dest, destSize);
+ delete [] utf8val;
+
+ return ret;
}
@@ -499,6 +504,7 @@ void saveViewerParameters(const char *filename, const char *servername) {
}
snprintf(filepath, sizeof(filepath), "%sdefault.tigervnc", homeDir);
+ free(homeDir);
} else {
snprintf(filepath, sizeof(filepath), "%s", filename);
}
@@ -555,6 +561,7 @@ char* loadViewerParameters(const char *filename) {
"can't obtain home directory path."));
snprintf(filepath, sizeof(filepath), "%sdefault.tigervnc", homeDir);
+ free(homeDir);
} else {
snprintf(filepath, sizeof(filepath), "%s", filename);
}
diff --git a/vncviewer/vncviewer.cxx b/vncviewer/vncviewer.cxx
index ac4afca4..1c6f5244 100644
--- a/vncviewer/vncviewer.cxx
+++ b/vncviewer/vncviewer.cxx
@@ -479,9 +479,9 @@ static int mktunnel()
int localPort = findFreeTcpPort();
int remotePort;
- gatewayHost = strDup(via.getValueStr());
if (interpretViaParam(remoteHost, &remotePort, localPort) != 0)
return 1;
+ gatewayHost = (const char*)via;
createTunnel(gatewayHost, remoteHost, remotePort, localPort);
return 0;