From dab2193f2f798771db4e969fe8dba658e524467c Mon Sep 17 00:00:00 2001 From: Ylian Saint-Hilaire Date: Mon, 24 Jan 2022 14:00:20 -0800 Subject: [PATCH] Added KVM buffer overflow detection. --- amt-desktop-0.0.2.js | 5 +++++ index.html | 6 +++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/amt-desktop-0.0.2.js b/amt-desktop-0.0.2.js index b836a46..aa36f57 100644 --- a/amt-desktop-0.0.2.js +++ b/amt-desktop-0.0.2.js @@ -269,6 +269,11 @@ var CreateAmtRemoteDesktop = function (divid, scrolldiv) { cmdsize = 12; if (obj.onScreenSizeChange != null) { obj.onScreenSizeChange(obj, obj.ScreenWidth, obj.ScreenHeight); } //console.log('Desktop width: ' + obj.width + ', height: ' + obj.height); + + // Check if the screen size is larger than Intel AMT should be able to handle + if ((obj.parent) && ((obj.bpp * obj.width * obj.height) > 8388608)) { + obj.parent.disconnectCode = 50002; // Display buffer too large, more than 8MB. + } } else if (encoding == 0) { // RAW encoding var ptr = 12, cs = 12 + (s * obj.bpp); diff --git a/index.html b/index.html index 9696ba6..092d195 100644 --- a/index.html +++ b/index.html @@ -8553,10 +8553,12 @@ } else if (desktop.disconnectCode == 3) { // UNSUPPORTED messagebox("Remote Desktop", "The device indicated that this type of connection of not supported."); } else if (desktop.disconnectCode == 50000) { // KVM-Disconnect - messagebox("Remote Desktop", "KVM disconnection, they may indicate that Intel AMT is unable to capture the display (Try RLE8 encoding), or unsupported GPU."); + messagebox("Remote Desktop", "KVM disconnection, this may indicate that Intel AMT is unable to capture the display (Try RLE8 encoding), or unsupported GPU."); } else if (desktop.disconnectCode == 50001) { // Intel AMT disconnect, try to connect again if connection was more than 5 seconds long. reconnect = (desktop.connectTime != null) && ((desktop.connectTime + 5000) < Date.now()); console.log(desktop.disconnectCode, reconnect); + } else if (desktop.disconnectCode == 50002) { // KVM-BufferOverflow + messagebox("Remote Desktop", "KVM disconnection that may be due to the display size and resolution being too large for the Intel AMT KVM buffer. Try RLE8 encoding or reducing the display resolution."); } break; case 3: @@ -13164,13 +13166,11 @@ var view = new Uint8Array(data.length - 8); for (var i = 8; i < data.length; i++) { view[i] = data.charCodeAt(i); } amtDesktop.ProcessBinaryData(view.buffer); - //amtDesktop.ProcessData(data.substring(8)); } } else if (readState == 1) { var view = new Uint8Array(data.length); for (var i = 0; i < data.length; i++) { view[i] = data.charCodeAt(i); } amtDesktop.ProcessBinaryData(view.buffer); - //amtDesktop.ProcessData(data); } } else if (recFileProtocol == 200) { // Intel AMT midstream KVM