Fixed Intel AMT server IDE-redirect session not closing correctly.
Ylian Saint-Hilaire committed
Jul 5, 2022 at 22:12 UTC
2189b92745f2fdb406b124598096e1c8a4299091
3 files changed
+11
-15
amt/amt-ider-module.js
+2
-2
@@ -122,7 +122,7 @@ module.exports.CreateAmtRemoteIder = function (webserver, meshcentral) {
122
}
123
124
obj.Start = function () {
125
- if (obj.debug) { console.log("IDER-Start"); console.log(obj.floppy, obj.cdrom); }
125
+ if (obj.debug) { console.log('IDER-Start'); console.log(obj.floppy, obj.cdrom); }
126
obj.bytesToAmt = 0;
127
obj.bytesFromAmt = 0;
128
obj.inSequence = 0;
@@ -143,7 +143,7 @@ module.exports.CreateAmtRemoteIder = function (webserver, meshcentral) {
143
}
144
145
obj.Stop = function () {
146
- if (obj.debug) console.log("IDER-Stop");
146
+ if (obj.debug) console.log('IDER-Stop');
147
//if (obj.pingTimer) { clearInterval(obj.pingTimer); obj.pingTimer = null; }
148
obj.parent.Stop();
149
}
amt/amt-ider.js
+3
-3
@@ -127,8 +127,8 @@ module.exports.CreateAmtIderSession = function (parent, db, ws, req, args, domai
127
if ((command.args.floppyPath != null) && (typeof command.args.floppyPath != 'string')) { command.args.floppyPath = null; } else { command.args.floppyPath = decodeURIComponent(command.args.floppyPath); }
128
if ((command.args.cdromPath != null) && (typeof command.args.cdromPath != 'string')) { command.args.cdromPath = null; } else { command.args.cdromPath = decodeURIComponent(command.args.cdromPath); }
129
// TODO: Double check that "." or ".." are not used.
130
- if ((command.args.floppyPath != null) && (command.args.floppyPath.indexOf("..") >= 0)) { delete command.args.floppyPath; }
131
- if ((command.args.cdromPath != null) && (command.args.cdromPath.indexOf("..") >= 0)) { delete command.args.cdromPath; }
130
+ if ((command.args.floppyPath != null) && (command.args.floppyPath.indexOf('..') >= 0)) { delete command.args.floppyPath; }
131
+ if ((command.args.cdromPath != null) && (command.args.cdromPath.indexOf('..') >= 0)) { delete command.args.cdromPath; }
132
133
// Get the disk image paths
134
var domainx = 'domain' + ((domain.id == '') ? '' : ('-' + domain.id));
@@ -148,7 +148,7 @@ module.exports.CreateAmtIderSession = function (parent, db, ws, req, args, domai
148
var iderError = obj.ider.m.diskSetup(floppyPath, cdromPath);
149
150
// Error with the disk images, unable to start IDER
151
- if (iderError != 0) { try { ws.send(JSON.stringify({ action: "error", code: iderError })); } catch (ex) { } break; }
151
+ if (iderError != 0) { try { ws.send(JSON.stringify({ action: 'error', code: iderError })); } catch (ex) { } break; }
152
153
// Start the IDER session
154
obj.ider.Start(req.query.host, req.query.port, req.query.tls);
amt/amt-redir-mesh.js
+6
-10
@@ -479,16 +479,12 @@ module.exports.CreateAmtRedirect = function (module, domain, user, webserver, me
479
480
obj.xxSend = function (x) {
481
if (typeof x == 'string') {
482
- //if (obj.redirTrace) {
483
- //console.log("REDIR-SEND1(" + x.length + "): " + Buffer.from(x, 'binary').toString('hex'), typeof x);
484
- //}
482
+ if (obj.redirTrace) { console.log("REDIR-SEND(" + x.length + "): " + Buffer.from(x, 'binary').toString('hex'), typeof x); }
483
//obj.Debug("Send(" + x.length + "): " + webserver.common.rstr2hex(x));
484
//obj.forwardclient.write(x); // FIXES CIRA
485
obj.forwardclient.write(Buffer.from(x, 'binary'));
486
} else {
489
- //if (obj.redirTrace) {
490
- //console.log("REDIR-SEND2(" + x.length + "): " + x.toString('hex'), typeof x);
491
- //}
487
+ if (obj.redirTrace) { console.log("REDIR-SEND(" + x.length + "): " + x.toString('hex'), typeof x); }
488
//obj.Debug("Send(" + x.length + "): " + webserver.common.rstr2hex(x));
489
//obj.forwardclient.write(x); // FIXES CIRA
490
obj.forwardclient.write(x);
@@ -508,7 +504,7 @@ module.exports.CreateAmtRedirect = function (module, domain, user, webserver, me
504
obj.xxRandomValueHex = function(len) { return obj.crypto.randomBytes(Math.ceil(len / 2)).toString('hex').slice(0, len); }
505
506
obj.xxOnSocketClosed = function () {
511
- if (obj.redirTrace) { console.log("REDIR-CLOSED"); }
507
+ if (obj.redirTrace) { console.log('REDIR-CLOSED'); }
508
//obj.Debug("Socket Closed");
509
obj.Stop();
510
}
@@ -521,12 +517,12 @@ module.exports.CreateAmtRedirect = function (module, domain, user, webserver, me
517
}
518
519
obj.Stop = function () {
524
- if (obj.redirTrace) { console.log("REDIR-CLOSED"); }
520
+ if (obj.redirTrace) { console.log('REDIR-CLOSED'); }
521
//obj.Debug("Socket Stopped");
522
obj.xxStateChange(0);
523
obj.connectstate = -1;
528
- obj.amtaccumulator = "";
529
- if (obj.forwardclient != null) { try { obj.forwardclient.close(); } catch (ex) { } delete obj.forwardclient; }
524
+ obj.amtaccumulator = '';
525
+ if (obj.forwardclient != null) { try { obj.forwardclient.destroy(); } catch (ex) { } delete obj.forwardclient; }
526
if (obj.amtkeepalivetimer != null) { clearInterval(obj.amtkeepalivetimer); delete obj.amtkeepalivetimer; }
527
}
528