Fix for invalid amtactivation.log parsing.
Ylian Saint-Hilaire committed
Oct 12, 2021 at 22:36 UTC
0240d1a651fadcfeaa18865146978261a56bc432
1 file changed
+10
-7
meshcentral.js
+10
-7
@@ -2851,16 +2851,19 @@ function CreateMeshCentralServer(config, args) {
2851
obj.fs.readFile(amtlogfilename, 'utf8', function (err, data) {
2852
var amtPasswords = {}; // UUID --> [Passwords]
2853
if ((err == null) && (data != null)) {
2854
- const lines = data.split('\r\n');
2854
+ const lines = data.split('\r\n').join('\n').split('\n');
2855
for (var i in lines) {
2856
var line = lines[i];
2857
if (line.startsWith('{')) {
2858
- var j = JSON.parse(line);
2859
- if ((typeof j.amtUuid == 'string') && (typeof j.password == 'string')) {
2860
- if (amtPasswords[j.amtUuid] == null) {
2861
- amtPasswords[j.amtUuid] = [j.password]; // Add password to array
2862
- } else {
2863
- amtPasswords[j.amtUuid].unshift(j.password); // Add password at the start of the array
2858
+ var j = null;
2859
+ try { j = JSON.parse(line); } catch (ex) { }
2860
+ if ((j != null) && (typeof j == 'object')) {
2861
+ if ((typeof j.amtUuid == 'string') && (typeof j.password == 'string')) {
2862
+ if (amtPasswords[j.amtUuid] == null) {
2863
+ amtPasswords[j.amtUuid] = [j.password]; // Add password to array
2864
+ } else {
2865
+ amtPasswords[j.amtUuid].unshift(j.password); // Add password at the start of the array
2866
+ }
2867
}
2868
}
2869
}