From a13f055d62cb5f3912141765c55f3ef8e403bc53 Mon Sep 17 00:00:00 2001 From: Brian Gough Date: Mon, 22 May 2017 14:58:38 +0100 Subject: [PATCH 1/3] add null byte check for ops --- services/document-updater/app/coffee/RedisManager.coffee | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/services/document-updater/app/coffee/RedisManager.coffee b/services/document-updater/app/coffee/RedisManager.coffee index 4aad7ec109..8be17c647d 100644 --- a/services/document-updater/app/coffee/RedisManager.coffee +++ b/services/document-updater/app/coffee/RedisManager.coffee @@ -162,6 +162,11 @@ module.exports = RedisManager = return callback(error) jsonOps = appliedOps.map (op) -> JSON.stringify op + if jsonOps.indexOf("\u0000") != -1 + error = new Error("null bytes found in jsonOps") + logger.error err: error, doc_id: doc_id, jsonOps: jsonOps, error.message + return callback(error) + newDocLines = JSON.stringify(docLines) if newDocLines.indexOf("\u0000") != -1 error = new Error("null bytes found in doc lines") From 54ad45c870e6e7d1bc08da24368d657acb888d27 Mon Sep 17 00:00:00 2001 From: Brian Gough Date: Mon, 22 May 2017 14:58:51 +0100 Subject: [PATCH 2/3] add null byte check for ranges --- services/document-updater/app/coffee/RedisManager.coffee | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/services/document-updater/app/coffee/RedisManager.coffee b/services/document-updater/app/coffee/RedisManager.coffee index 8be17c647d..e3bae7d56f 100644 --- a/services/document-updater/app/coffee/RedisManager.coffee +++ b/services/document-updater/app/coffee/RedisManager.coffee @@ -181,6 +181,10 @@ module.exports = RedisManager = if error? logger.error {err: error, doc_id}, error.message return callback(error) + if ranges? and ranges.indexOf("\u0000") != -1 + error = new Error("null bytes found in ranges") + logger.error err: error, doc_id: doc_id, ranges: ranges, error.message + return callback(error) multi = rclient.multi() multi.eval setScript, 1, keys.docLines(doc_id:doc_id), newDocLines # index 0 multi.set keys.docVersion(doc_id:doc_id), newVersion # index 1 From a3947c587fd4aa9a44ea4657f09e8e3145a3dea8 Mon Sep 17 00:00:00 2001 From: Brian Gough Date: Mon, 22 May 2017 15:20:28 +0100 Subject: [PATCH 3/3] fix bug, jsonOps is array not string --- services/document-updater/app/coffee/RedisManager.coffee | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/services/document-updater/app/coffee/RedisManager.coffee b/services/document-updater/app/coffee/RedisManager.coffee index e3bae7d56f..5e2cc5c84b 100644 --- a/services/document-updater/app/coffee/RedisManager.coffee +++ b/services/document-updater/app/coffee/RedisManager.coffee @@ -162,10 +162,11 @@ module.exports = RedisManager = return callback(error) jsonOps = appliedOps.map (op) -> JSON.stringify op - if jsonOps.indexOf("\u0000") != -1 - error = new Error("null bytes found in jsonOps") - logger.error err: error, doc_id: doc_id, jsonOps: jsonOps, error.message - return callback(error) + for op in jsonOps + if op.indexOf("\u0000") != -1 + error = new Error("null bytes found in jsonOps") + logger.error err: error, doc_id: doc_id, jsonOps: jsonOps, error.message + return callback(error) newDocLines = JSON.stringify(docLines) if newDocLines.indexOf("\u0000") != -1