From 0ccc679d322947a05f2fc169da22d915930a75a6 Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Sun, 4 Jun 2023 14:50:35 +0200 Subject: [PATCH] Return unsigned values from rQshift32() This is what we almost always want, and this makes it consistent with rQshift8() and rQshift16(). --- core/rfb.js | 2 ++ core/websock.js | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/core/rfb.js b/core/rfb.js index 8ac38aa..b4045e5 100644 --- a/core/rfb.js +++ b/core/rfb.js @@ -2491,6 +2491,8 @@ export default class RFB extends EventTargetMixin { this._FBU.width = this._sock.rQshift16(); this._FBU.height = this._sock.rQshift16(); this._FBU.encoding = this._sock.rQshift32(); + /* Encodings are signed */ + this._FBU.encoding >>= 0; } if (!this._handleRect()) { diff --git a/core/websock.js b/core/websock.js index 7cd8709..2b9b519 100644 --- a/core/websock.js +++ b/core/websock.js @@ -121,7 +121,7 @@ export default class Websock { for (let byte = bytes - 1; byte >= 0; byte--) { res += this._rQ[this._rQi++] << (byte * 8); } - return res; + return res >>> 0; } rQshiftStr(len) { -- 2.39.5