mirror of
https://github.com/kasmtech/KasmVNC.git
synced 2025-02-23 05:40:48 +01:00
Handle empty rects from the server
These are very pointless for the server to send, but not a violation of the protocol so we need to be able to handle them. We've seen this happen in real world scenarios a few times.
This commit is contained in:
parent
16c72ba0a7
commit
073737c8ac
@ -15,6 +15,11 @@ export default class CopyRectDecoder {
|
||||
|
||||
let deltaX = sock.rQshift16();
|
||||
let deltaY = sock.rQshift16();
|
||||
|
||||
if ((width === 0) || (height === 0)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
display.copyImage(deltaX, deltaY, x, y, width, height);
|
||||
|
||||
return true;
|
||||
|
@ -162,6 +162,10 @@ export default class TightDecoder {
|
||||
const uncompressedSize = width * height * 3;
|
||||
let data;
|
||||
|
||||
if (uncompressedSize === 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (uncompressedSize < 12) {
|
||||
if (sock.rQwait("TIGHT", uncompressedSize)) {
|
||||
return false;
|
||||
@ -217,6 +221,10 @@ export default class TightDecoder {
|
||||
|
||||
let data;
|
||||
|
||||
if (uncompressedSize === 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (uncompressedSize < 12) {
|
||||
if (sock.rQwait("TIGHT", uncompressedSize)) {
|
||||
return false;
|
||||
|
@ -57,4 +57,21 @@ describe('CopyRect Decoder', function () {
|
||||
|
||||
expect(display).to.have.displayed(targetData);
|
||||
});
|
||||
|
||||
it('should handle empty rects', function () {
|
||||
display.fillRect(0, 0, 4, 4, [ 0x00, 0x00, 0xff ]);
|
||||
display.fillRect(2, 0, 2, 2, [ 0x00, 0xff, 0x00 ]);
|
||||
display.fillRect(0, 2, 2, 2, [ 0x00, 0xff, 0x00 ]);
|
||||
|
||||
testDecodeRect(decoder, 1, 2, 0, 0, [0x00, 0x00, 0x00, 0x00], display, 24);
|
||||
|
||||
let targetData = new Uint8Array([
|
||||
0x00, 0x00, 0xff, 255, 0x00, 0x00, 0xff, 255, 0x00, 0xff, 0x00, 255, 0x00, 0xff, 0x00, 255,
|
||||
0x00, 0x00, 0xff, 255, 0x00, 0x00, 0xff, 255, 0x00, 0xff, 0x00, 255, 0x00, 0xff, 0x00, 255,
|
||||
0x00, 0xff, 0x00, 255, 0x00, 0xff, 0x00, 255, 0x00, 0x00, 0xff, 255, 0x00, 0x00, 0xff, 255,
|
||||
0x00, 0xff, 0x00, 255, 0x00, 0xff, 0x00, 255, 0x00, 0x00, 0xff, 255, 0x00, 0x00, 0xff, 255
|
||||
]);
|
||||
|
||||
expect(display).to.have.displayed(targetData);
|
||||
});
|
||||
});
|
||||
|
@ -206,4 +206,21 @@ describe('Hextile Decoder', function () {
|
||||
let data = [45]; // an invalid subencoding
|
||||
expect(() => testDecodeRect(decoder, 0, 0, 4, 4, data, display, 24)).to.throw();
|
||||
});
|
||||
|
||||
it('should handle empty rects', function () {
|
||||
display.fillRect(0, 0, 4, 4, [ 0x00, 0x00, 0xff ]);
|
||||
display.fillRect(2, 0, 2, 2, [ 0x00, 0xff, 0x00 ]);
|
||||
display.fillRect(0, 2, 2, 2, [ 0x00, 0xff, 0x00 ]);
|
||||
|
||||
testDecodeRect(decoder, 1, 2, 0, 0, [], display, 24);
|
||||
|
||||
let targetData = new Uint8Array([
|
||||
0x00, 0x00, 0xff, 255, 0x00, 0x00, 0xff, 255, 0x00, 0xff, 0x00, 255, 0x00, 0xff, 0x00, 255,
|
||||
0x00, 0x00, 0xff, 255, 0x00, 0x00, 0xff, 255, 0x00, 0xff, 0x00, 255, 0x00, 0xff, 0x00, 255,
|
||||
0x00, 0xff, 0x00, 255, 0x00, 0xff, 0x00, 255, 0x00, 0x00, 0xff, 255, 0x00, 0x00, 0xff, 255,
|
||||
0x00, 0xff, 0x00, 255, 0x00, 0xff, 0x00, 255, 0x00, 0x00, 0xff, 255, 0x00, 0x00, 0xff, 255
|
||||
]);
|
||||
|
||||
expect(display).to.have.displayed(targetData);
|
||||
});
|
||||
});
|
||||
|
@ -86,4 +86,38 @@ describe('Raw Decoder', function () {
|
||||
|
||||
expect(display).to.have.displayed(targetData);
|
||||
});
|
||||
|
||||
it('should handle empty rects', function () {
|
||||
display.fillRect(0, 0, 4, 4, [ 0x00, 0x00, 0xff ]);
|
||||
display.fillRect(2, 0, 2, 2, [ 0x00, 0xff, 0x00 ]);
|
||||
display.fillRect(0, 2, 2, 2, [ 0x00, 0xff, 0x00 ]);
|
||||
|
||||
testDecodeRect(decoder, 1, 2, 0, 0, [], display, 24);
|
||||
|
||||
let targetData = new Uint8Array([
|
||||
0x00, 0x00, 0xff, 255, 0x00, 0x00, 0xff, 255, 0x00, 0xff, 0x00, 255, 0x00, 0xff, 0x00, 255,
|
||||
0x00, 0x00, 0xff, 255, 0x00, 0x00, 0xff, 255, 0x00, 0xff, 0x00, 255, 0x00, 0xff, 0x00, 255,
|
||||
0x00, 0xff, 0x00, 255, 0x00, 0xff, 0x00, 255, 0x00, 0x00, 0xff, 255, 0x00, 0x00, 0xff, 255,
|
||||
0x00, 0xff, 0x00, 255, 0x00, 0xff, 0x00, 255, 0x00, 0x00, 0xff, 255, 0x00, 0x00, 0xff, 255
|
||||
]);
|
||||
|
||||
expect(display).to.have.displayed(targetData);
|
||||
});
|
||||
|
||||
it('should handle empty rects in low colour mode', function () {
|
||||
display.fillRect(0, 0, 4, 4, [ 0x00, 0x00, 0xff ]);
|
||||
display.fillRect(2, 0, 2, 2, [ 0x00, 0xff, 0x00 ]);
|
||||
display.fillRect(0, 2, 2, 2, [ 0x00, 0xff, 0x00 ]);
|
||||
|
||||
testDecodeRect(decoder, 1, 2, 0, 0, [], display, 8);
|
||||
|
||||
let targetData = new Uint8Array([
|
||||
0x00, 0x00, 0xff, 255, 0x00, 0x00, 0xff, 255, 0x00, 0xff, 0x00, 255, 0x00, 0xff, 0x00, 255,
|
||||
0x00, 0x00, 0xff, 255, 0x00, 0x00, 0xff, 255, 0x00, 0xff, 0x00, 255, 0x00, 0xff, 0x00, 255,
|
||||
0x00, 0xff, 0x00, 255, 0x00, 0xff, 0x00, 255, 0x00, 0x00, 0xff, 255, 0x00, 0x00, 0xff, 255,
|
||||
0x00, 0xff, 0x00, 255, 0x00, 0xff, 0x00, 255, 0x00, 0x00, 0xff, 255, 0x00, 0x00, 0xff, 255
|
||||
]);
|
||||
|
||||
expect(display).to.have.displayed(targetData);
|
||||
});
|
||||
});
|
||||
|
@ -81,4 +81,21 @@ describe('RRE Decoder', function () {
|
||||
|
||||
expect(display).to.have.displayed(targetData);
|
||||
});
|
||||
|
||||
it('should handle empty rects', function () {
|
||||
display.fillRect(0, 0, 4, 4, [ 0x00, 0x00, 0xff ]);
|
||||
display.fillRect(2, 0, 2, 2, [ 0x00, 0xff, 0x00 ]);
|
||||
display.fillRect(0, 2, 2, 2, [ 0x00, 0xff, 0x00 ]);
|
||||
|
||||
testDecodeRect(decoder, 1, 2, 0, 0, [ 0x00, 0xff, 0xff, 0xff, 0xff ], display, 24);
|
||||
|
||||
let targetData = new Uint8Array([
|
||||
0x00, 0x00, 0xff, 255, 0x00, 0x00, 0xff, 255, 0x00, 0xff, 0x00, 255, 0x00, 0xff, 0x00, 255,
|
||||
0x00, 0x00, 0xff, 255, 0x00, 0x00, 0xff, 255, 0x00, 0xff, 0x00, 255, 0x00, 0xff, 0x00, 255,
|
||||
0x00, 0xff, 0x00, 255, 0x00, 0xff, 0x00, 255, 0x00, 0x00, 0xff, 255, 0x00, 0x00, 0xff, 255,
|
||||
0x00, 0xff, 0x00, 255, 0x00, 0xff, 0x00, 255, 0x00, 0x00, 0xff, 255, 0x00, 0x00, 0xff, 255
|
||||
]);
|
||||
|
||||
expect(display).to.have.displayed(targetData);
|
||||
});
|
||||
});
|
||||
|
@ -210,6 +210,61 @@ describe('Tight Decoder', function () {
|
||||
// Not implemented yet
|
||||
});
|
||||
|
||||
it('should handle empty copy rects', function () {
|
||||
display.fillRect(0, 0, 4, 4, [ 0x00, 0x00, 0xff ]);
|
||||
display.fillRect(2, 0, 2, 2, [ 0x00, 0xff, 0x00 ]);
|
||||
display.fillRect(0, 2, 2, 2, [ 0x00, 0xff, 0x00 ]);
|
||||
|
||||
testDecodeRect(decoder, 1, 2, 0, 0, [ 0x00 ], display, 24);
|
||||
|
||||
let targetData = new Uint8Array([
|
||||
0x00, 0x00, 0xff, 255, 0x00, 0x00, 0xff, 255, 0x00, 0xff, 0x00, 255, 0x00, 0xff, 0x00, 255,
|
||||
0x00, 0x00, 0xff, 255, 0x00, 0x00, 0xff, 255, 0x00, 0xff, 0x00, 255, 0x00, 0xff, 0x00, 255,
|
||||
0x00, 0xff, 0x00, 255, 0x00, 0xff, 0x00, 255, 0x00, 0x00, 0xff, 255, 0x00, 0x00, 0xff, 255,
|
||||
0x00, 0xff, 0x00, 255, 0x00, 0xff, 0x00, 255, 0x00, 0x00, 0xff, 255, 0x00, 0x00, 0xff, 255
|
||||
]);
|
||||
|
||||
expect(display).to.have.displayed(targetData);
|
||||
});
|
||||
|
||||
it('should handle empty palette rects', function () {
|
||||
display.fillRect(0, 0, 4, 4, [ 0x00, 0x00, 0xff ]);
|
||||
display.fillRect(2, 0, 2, 2, [ 0x00, 0xff, 0x00 ]);
|
||||
display.fillRect(0, 2, 2, 2, [ 0x00, 0xff, 0x00 ]);
|
||||
|
||||
testDecodeRect(decoder, 1, 2, 0, 0,
|
||||
[ 0x40, 0x01, 0x01,
|
||||
0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff ], display, 24);
|
||||
|
||||
let targetData = new Uint8Array([
|
||||
0x00, 0x00, 0xff, 255, 0x00, 0x00, 0xff, 255, 0x00, 0xff, 0x00, 255, 0x00, 0xff, 0x00, 255,
|
||||
0x00, 0x00, 0xff, 255, 0x00, 0x00, 0xff, 255, 0x00, 0xff, 0x00, 255, 0x00, 0xff, 0x00, 255,
|
||||
0x00, 0xff, 0x00, 255, 0x00, 0xff, 0x00, 255, 0x00, 0x00, 0xff, 255, 0x00, 0x00, 0xff, 255,
|
||||
0x00, 0xff, 0x00, 255, 0x00, 0xff, 0x00, 255, 0x00, 0x00, 0xff, 255, 0x00, 0x00, 0xff, 255
|
||||
]);
|
||||
|
||||
expect(display).to.have.displayed(targetData);
|
||||
});
|
||||
|
||||
it('should handle empty fill rects', function () {
|
||||
display.fillRect(0, 0, 4, 4, [ 0x00, 0x00, 0xff ]);
|
||||
display.fillRect(2, 0, 2, 2, [ 0x00, 0xff, 0x00 ]);
|
||||
display.fillRect(0, 2, 2, 2, [ 0x00, 0xff, 0x00 ]);
|
||||
|
||||
testDecodeRect(decoder, 1, 2, 0, 0,
|
||||
[ 0x80, 0xff, 0xff, 0xff ], display, 24);
|
||||
|
||||
let targetData = new Uint8Array([
|
||||
0x00, 0x00, 0xff, 255, 0x00, 0x00, 0xff, 255, 0x00, 0xff, 0x00, 255, 0x00, 0xff, 0x00, 255,
|
||||
0x00, 0x00, 0xff, 255, 0x00, 0x00, 0xff, 255, 0x00, 0xff, 0x00, 255, 0x00, 0xff, 0x00, 255,
|
||||
0x00, 0xff, 0x00, 255, 0x00, 0xff, 0x00, 255, 0x00, 0x00, 0xff, 255, 0x00, 0x00, 0xff, 255,
|
||||
0x00, 0xff, 0x00, 255, 0x00, 0xff, 0x00, 255, 0x00, 0x00, 0xff, 255, 0x00, 0x00, 0xff, 255
|
||||
]);
|
||||
|
||||
expect(display).to.have.displayed(targetData);
|
||||
});
|
||||
|
||||
it('should handle JPEG rects', function (done) {
|
||||
let data = [
|
||||
// Control bytes
|
||||
|
Loading…
Reference in New Issue
Block a user