From 5dff6535ed3f748d133d96090f295255e3be9a44 Mon Sep 17 00:00:00 2001 From: ansuz Date: Mon, 17 Feb 2020 10:19:51 -0500 Subject: [PATCH 1/2] add a simple guard against unparsed messages when trimming history --- lib/storage/file.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/storage/file.js b/lib/storage/file.js index 6b1577d80..1d4061c4b 100644 --- a/lib/storage/file.js +++ b/lib/storage/file.js @@ -970,6 +970,15 @@ var trimChannel = function (env, channelName, hash, _cb) { } var msg = Util.tryParse(s_msg); + + if (!msg) { + Log.error("TRIM_HISTORY_UNPARSED_LINE", { + content: s_msg, + index: i, + }); + return void readMore(); + } + var msgHash = Extras.getHash(msg[4]); if (msgHash === hash) { From e8949168ecd668d3b1ca024962c36affdf0e2df2 Mon Sep 17 00:00:00 2001 From: ansuz Date: Mon, 17 Feb 2020 10:30:44 -0500 Subject: [PATCH 2/2] lint compliance --- lib/historyKeeper.js | 4 ++-- lib/storage/file.js | 9 +-------- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/lib/historyKeeper.js b/lib/historyKeeper.js index e99b279eb..49c199141 100644 --- a/lib/historyKeeper.js +++ b/lib/historyKeeper.js @@ -6,6 +6,7 @@ const WriteQueue = require("./write-queue"); const BatchRead = require("./batch-read"); const RPC = require("./rpc"); const HK = require("./hk-util.js"); +const Core = require("./commands/core"); const Store = require("./storage/file"); const BlobStore = require("./storage/blob"); @@ -54,7 +55,6 @@ module.exports.create = function (config, cb) { limits: {}, admins: [], - Log: Log, WARN: WARN, flushCache: config.flushCache, adminEmail: config.adminEmail, @@ -149,7 +149,7 @@ module.exports.create = function (config, cb) { blobStagingPath: config.blobStagingPath, archivePath: config.archivePath, getSession: function (safeKey) { - return Core.getSession(Sessions, safeKey); + return Core.getSession(Env.Sessions, safeKey); }, }, w(function (err, blob) { if (err) { throw new Error(err); } diff --git a/lib/storage/file.js b/lib/storage/file.js index 1d4061c4b..ee9a4fd91 100644 --- a/lib/storage/file.js +++ b/lib/storage/file.js @@ -970,14 +970,7 @@ var trimChannel = function (env, channelName, hash, _cb) { } var msg = Util.tryParse(s_msg); - - if (!msg) { - Log.error("TRIM_HISTORY_UNPARSED_LINE", { - content: s_msg, - index: i, - }); - return void readMore(); - } + if (!msg) { return void readMore(); } var msgHash = Extras.getHash(msg[4]);