From ba90f0109f0e327954487f86e7340f1ea9b429fc Mon Sep 17 00:00:00 2001 From: Mischa Untaga <99098079+MischaU8@users.noreply.github.com> Date: Sun, 27 Aug 2023 21:28:08 +0200 Subject: check we have sufficient bytes to continue, fix for nevsky --- rtt-module.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/rtt-module.js b/rtt-module.js index a0df345..a12f520 100755 --- a/rtt-module.js +++ b/rtt-module.js @@ -14,6 +14,10 @@ const RULES = require(RULES_JS_FILE) module.exports.fuzz = function(fuzzerInputData) { let data = new FuzzedDataProvider(fuzzerInputData) + if (data.remainingBytes < 16) { + // insufficient bytes to start + return + } let seed = data.consumeIntegralInRange(1, 2**35-31) let scenario = data.pickValue(RULES.scenarios) @@ -30,6 +34,10 @@ module.exports.fuzz = function(fuzzerInputData) { let step = 0 while (true) { + if (data.remainingBytes < 16) { + // insufficient bytes to continue + return + } let active = state.active if (active === 'Both' || active === 'All') { // If multiple players can act, we'll pick a random player to go first. @@ -58,8 +66,9 @@ module.exports.fuzz = function(fuzzerInputData) { } // Tor: view.actions["foo"] === 0 means the "foo" action is disabled (show the button in a disabled state) + // Also ignoring the actions with `[]` as args, unsure about this but needed for Nevsky. for (const [key, value] of Object.entries(actions)) { - if (value === false || value === 0) { + if (value === false || value === 0 || value.length === 0) { delete actions[key] } } -- cgit v1.2.3