From 1a3a665b17554669169f4d4d9f5f37d88764e4c1 Mon Sep 17 00:00:00 2001 From: Matthew Wolter Date: Sat, 11 Apr 2026 18:30:54 -0700 Subject: [PATCH] =?UTF-8?q?G1:=20R02=20=E2=80=94=20fix=20txt=5Ftype=20empt?= =?UTF-8?q?y-slice=20(uncrypted[4:4]=20->=20[4:5])?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `uncrypted[4:4]` is the empty slice. `int.from_bytes(b"", "little")` returns 0, so `txt_type` was always 0 for every decrypted channel message — silently masking the upper 6 bits of byte 4. The line immediately above (`attempt = uncrypted[4] & 3`) already proves byte 4 is in range, so widening the slice to `[4:5]` is safe. This is a one-character fix and changes the observable value of `txt_type` for all callers. Existing consumers that branched on `txt_type` were effectively dead code; this restores the intended behavior. Finding: R02 (Info) File: src/meshcore/meshcore_parser.py --- src/meshcore/meshcore_parser.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/meshcore/meshcore_parser.py b/src/meshcore/meshcore_parser.py index a56165d..046709a 100644 --- a/src/meshcore/meshcore_parser.py +++ b/src/meshcore/meshcore_parser.py @@ -150,7 +150,7 @@ class MeshcorePacketParser: uncrypted = cipher.decrypt(msg) timestamp = int.from_bytes(uncrypted[0:4], "little", signed=False) attempt = uncrypted[4] & 3 - txt_type = int.from_bytes(uncrypted[4:4], "little", signed=False) >> 2 + txt_type = int.from_bytes(uncrypted[4:5], "little", signed=False) >> 2 message = uncrypted[5:].strip(b"\0") msg_hash = int.from_bytes(SHA256.new(timestamp.to_bytes(4, "little", signed=False) + message).digest()[0:4], "little", signed=False) log_data["message"] = message.decode("utf-8", "ignore")