From fc73347177709d7b0ff3ad02c3b2e7ae3c024c49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6ren=20Beye?= Date: Sun, 2 Apr 2023 17:16:39 +0200 Subject: [PATCH] fix(vendor.viomi): Fix parser freezing when encountering unexpected segment name data --- backend/lib/robots/3irobotix/ThreeIRobotixMapParser.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/backend/lib/robots/3irobotix/ThreeIRobotixMapParser.js b/backend/lib/robots/3irobotix/ThreeIRobotixMapParser.js index 2eca9ab4bb..e622322b4e 100644 --- a/backend/lib/robots/3irobotix/ThreeIRobotixMapParser.js +++ b/backend/lib/robots/3irobotix/ThreeIRobotixMapParser.js @@ -311,6 +311,11 @@ class ThreeIRobotixMapParser { const segmentCount = block.view.readUInt32LE(offset); offset += 4; + if (segmentCount > 0xff) { + // This seems to be a map file that contains more than one map name. Aborting for now + return segments; + } + for (let i = 0; i < segmentCount; i++) { const segmentId = block.view[offset]; const nameLength = block.view[offset +1];