From 9b75bcaadaa5671683224bd2bf22316d6260d586 Mon Sep 17 00:00:00 2001 From: Mike Tinglof Date: Tue, 31 Jan 2012 00:15:56 -0500 Subject: [PATCH] add tight zlib stream reset; add error if tight encoding is used w/o true color --- include/rfb.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/include/rfb.js b/include/rfb.js index 64e4b98c..cb01fe1e 100644 --- a/include/rfb.js +++ b/include/rfb.js @@ -1276,6 +1276,11 @@ encHandlers.HEXTILE = function display_hextile() { encHandlers.TIGHT = function display_tight() { Util.Debug(">> display_tight"); + + if (fb_depth == 1) { + fail("Tight protocol handler only implements true color mode"); + } + var ctl, cmode, clength, getCLength, color, img, data; var filterId = -1, resetStreams = 0, streamId = -1; var rQ = ws.get_rQ(), rQi = ws.get_rQi(); @@ -1308,10 +1313,15 @@ encHandlers.TIGHT = function display_tight() { } var decompress = function(data) { - // TODO: process resetStreams here + for (var i=0; i<4; i++) { + if ((resetStreams >> i) & 1) { + FBU.zlibs[i].reset(); + Util.Info("Reset zlib stream " + i); + } + } var uncompressed = FBU.zlibs[streamId].uncompress(data, 0); if (uncompressed.status !== 0) - throw("Invalid data in zlib stream"); + Util.Error("Invalid data in zlib stream"); //Util.Warn("Decompressed " + data.length + " to " + uncompressed.data.length + " checksums " + // checksum(data) + ":" + checksum(uncompressed.data)); @@ -1427,7 +1437,6 @@ encHandlers.TIGHT = function display_tight() { // Keep tight reset bits resetStreams = ctl & 0xF; - if (resetStreams) throw ("Tight reset"); // Figure out filter ctl = ctl >> 4;