The attached adds support for the unofficial rfbTightNoZlib extension used by the TurboVNC Server to transmit Raw, indexed color, and mono subrectangles without Zlib compression. This prevents the TigerVNC Viewer from crashing if the user attempts to select Compress level 0 while connected to a TurboVNC server.

DRC
Index: common/rfb/tightDecode.h
===================================================================
--- common/rfb/tightDecode.h    (revision 4999)
+++ common/rfb/tightDecode.h    (working copy)
@@ -1,6 +1,6 @@
 /* Copyright (C) 2000-2003 Constantin Kaplinsky.  All Rights Reserved.
  * Copyright 2004-2005 Cendio AB.
- * Copyright (C) 2011 D. R. Commander.  All Rights Reserved.
+ * Copyright (C) 2011-2012 D. R. Commander.  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
@@ -70,6 +70,12 @@
     comp_ctl >>= 1;
   }
 
+  bool readUncompressed = false;
+  if ((comp_ctl & rfbTightNoZlib) == rfbTightNoZlib) {
+    comp_ctl &= ~(rfbTightNoZlib);
+    readUncompressed = true;
+  }
+
   // "Fill" compression type.
   if (comp_ctl == rfbTightFill) {
     PIXEL_T pix;
@@ -138,7 +144,7 @@
   int dataSize = r.height() * rowSize;
   int streamId = -1;
   rdr::InStream *input;
-  if (dataSize < TIGHT_MIN_TO_COMPRESS) {
+  if (dataSize < TIGHT_MIN_TO_COMPRESS || readUncompressed) {
     input = is;
   } else {
     int length = is->readCompactLength();
@@ -147,6 +153,9 @@
     input = &zis[streamId];
   }
 
+  if (readUncompressed && dataSize >= TIGHT_MIN_TO_COMPRESS)
+    dataSize = is->readCompactLength();
+
   // Allocate netbuf and read in data
   rdr::U8 *netbuf = new rdr::U8[dataSize];
   if (!netbuf) {
Index: common/rfb/TightDecoder.h
===================================================================
--- common/rfb/TightDecoder.h   (revision 4999)
+++ common/rfb/TightDecoder.h   (working copy)
@@ -1,5 +1,5 @@
 /* Copyright (C) 2000-2003 Constantin Kaplinsky.  All Rights Reserved.
- * Copyright (C) 2011 D. R. Commander.  All Rights Reserved.
+ * Copyright (C) 2011-2012 D. R. Commander.  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
@@ -71,6 +71,7 @@
   const unsigned int rfbTightFill = 0x08;
   const unsigned int rfbTightJpeg = 0x09;
   const unsigned int rfbTightMaxSubencoding = 0x09;
+  const unsigned int rfbTightNoZlib = 0x0A;
 
   // Filters to improve compression efficiency
   const unsigned int rfbTightFilterCopy = 0x00;
------------------------------------------------------------------------------
Don't let slow site performance ruin your business. Deploy New Relic APM
Deploy New Relic app performance management and know exactly
what is happening inside your Ruby, Python, PHP, Java, and .NET app
Try New Relic at no cost today and get our sweet Data Nerd shirt too!
http://p.sf.net/sfu/newrelic-dev2dev
_______________________________________________
Tigervnc-devel mailing list
Tigervnc-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tigervnc-devel

Reply via email to