diff --git a/U_tigervnc_clear_up_zlibinstream_reset_behaviour.patch b/U_tigervnc_clear_up_zlibinstream_reset_behaviour.patch new file mode 100644 index 0000000..b3b0a14 --- /dev/null +++ b/U_tigervnc_clear_up_zlibinstream_reset_behaviour.patch @@ -0,0 +1,159 @@ +From 6f318e4451fcb45054408eaf568ca1c30c2d1ab6 Mon Sep 17 00:00:00 2001 +From: Pierre Ossman +Date: Wed, 11 Nov 2015 13:11:09 +0100 +Subject: [PATCH] Clear up ZlibInStream::reset() behaviour + +It previously only did a reset of the ZlibInStream object, not the +underlying zlib stream. It also had the side effect of flushing +the underlying stream and disassociating from it. + +Clear things up by changing the naming, and introducing a proper +reset function (which is needed by the Tight decoder). + +Index: tigervnc-1.5.0/common/rdr/ZlibInStream.cxx +=================================================================== +--- tigervnc-1.5.0.orig/common/rdr/ZlibInStream.cxx ++++ tigervnc-1.5.0/common/rdr/ZlibInStream.cxx +@@ -16,6 +16,8 @@ + * USA. + */ + ++#include ++ + #include + #include + #include +@@ -26,26 +28,16 @@ enum { DEFAULT_BUF_SIZE = 16384 }; + + ZlibInStream::ZlibInStream(int bufSize_) + : underlying(0), bufSize(bufSize_ ? bufSize_ : DEFAULT_BUF_SIZE), offset(0), +- bytesIn(0) ++ zs(NULL), bytesIn(0) + { +- zs = new z_stream; +- zs->zalloc = Z_NULL; +- zs->zfree = Z_NULL; +- zs->opaque = Z_NULL; +- zs->next_in = Z_NULL; +- zs->avail_in = 0; +- if (inflateInit(zs) != Z_OK) { +- delete zs; +- throw Exception("ZlibInStream: inflateInit failed"); +- } + ptr = end = start = new U8[bufSize]; ++ init(); + } + + ZlibInStream::~ZlibInStream() + { ++ deinit(); + delete [] start; +- inflateEnd(zs); +- delete zs; + } + + void ZlibInStream::setUnderlying(InStream* is, int bytesIn_) +@@ -60,7 +52,7 @@ int ZlibInStream::pos() + return offset + ptr - start; + } + +-void ZlibInStream::reset() ++void ZlibInStream::removeUnderlying() + { + ptr = end = start; + if (!underlying) return; +@@ -72,6 +64,38 @@ void ZlibInStream::reset() + underlying = 0; + } + ++void ZlibInStream::reset() ++{ ++ deinit(); ++ init(); ++} ++ ++void ZlibInStream::init() ++{ ++ assert(zs == NULL); ++ ++ zs = new z_stream; ++ zs->zalloc = Z_NULL; ++ zs->zfree = Z_NULL; ++ zs->opaque = Z_NULL; ++ zs->next_in = Z_NULL; ++ zs->avail_in = 0; ++ if (inflateInit(zs) != Z_OK) { ++ delete zs; ++ zs = NULL; ++ throw Exception("ZlibInStream: inflateInit failed"); ++ } ++} ++ ++void ZlibInStream::deinit() ++{ ++ assert(zs != NULL); ++ removeUnderlying(); ++ inflateEnd(zs); ++ delete zs; ++ zs = NULL; ++} ++ + int ZlibInStream::overrun(int itemSize, int nItems, bool wait) + { + if (itemSize > bufSize) +Index: tigervnc-1.5.0/common/rdr/ZlibInStream.h +=================================================================== +--- tigervnc-1.5.0.orig/common/rdr/ZlibInStream.h ++++ tigervnc-1.5.0/common/rdr/ZlibInStream.h +@@ -38,11 +38,15 @@ namespace rdr { + virtual ~ZlibInStream(); + + void setUnderlying(InStream* is, int bytesIn); +- void reset(); ++ void removeUnderlying(); + int pos(); ++ void reset(); + + private: + ++ void init(); ++ void deinit(); ++ + int overrun(int itemSize, int nItems, bool wait); + bool decompress(bool wait); + +Index: tigervnc-1.5.0/common/rfb/zrleDecode.h +=================================================================== +--- tigervnc-1.5.0.orig/common/rfb/zrleDecode.h ++++ tigervnc-1.5.0/common/rfb/zrleDecode.h +@@ -177,7 +177,7 @@ void ZRLE_DECODE (const Rect& r, rdr::In + } + } + +- zis->reset(); ++ zis->removeUnderlying(); + } + + #undef ZRLE_DECODE +Index: tigervnc-1.5.0/common/rfb/tightDecode.h +=================================================================== +--- tigervnc-1.5.0.orig/common/rfb/tightDecode.h ++++ tigervnc-1.5.0/common/rfb/tightDecode.h +@@ -59,7 +59,7 @@ void TIGHT_DECODE (const Rect& r) + + rdr::U8 comp_ctl = is->readU8(); + +- // Flush zlib streams if we are told by the server to do so. ++ // Reset zlib streams if we are told by the server to do so. + for (int i = 0; i < 4; i++) { + if (comp_ctl & 1) { + zis[i].reset(); +@@ -231,7 +231,7 @@ void TIGHT_DECODE (const Rect& r) + delete [] netbuf; + + if (streamId != -1) { +- zis[streamId].reset(); ++ zis[streamId].removeUnderlying(); + } + } + diff --git a/tigervnc.changes b/tigervnc.changes index 9c0b431..96c5540 100644 --- a/tigervnc.changes +++ b/tigervnc.changes @@ -1,3 +1,9 @@ +------------------------------------------------------------------- +Mon Jun 13 15:21:19 UTC 2016 - msrb@suse.com + +- Add U_tigervnc_clear_up_zlibinstream_reset_behaviour.patch + * Fix zlib stream reset in tight encoding. (bnc#963417) + ------------------------------------------------------------------- Tue May 24 12:46:07 UTC 2016 - msrb@suse.com diff --git a/tigervnc.spec b/tigervnc.spec index c302225..80fbac6 100644 --- a/tigervnc.spec +++ b/tigervnc.spec @@ -120,6 +120,7 @@ Patch9: u_tigervnc_update_default_vncxstartup.patch Patch10: U_add_allowoverride_parameter.patch Patch11: u_build_libXvnc_as_separate_library.patch Patch12: u_tigervnc-show-unencrypted-warning.patch +Patch13: U_tigervnc_clear_up_zlibinstream_reset_behaviour.patch %description TigerVNC is a high-performance, platform-neutral implementation of VNC (Virtual Network Computing), @@ -180,6 +181,7 @@ cp -r /usr/src/xserver/* unix/xserver/ %patch10 -p1 %patch11 -p1 %patch12 -p1 +%patch13 -p1 pushd unix/xserver patch -p1 < ../xserver117.patch