From a597384040a4a5a1f55c1159ed546afd4a4a93a0 Mon Sep 17 00:00:00 2001 From: Eric Severance Date: Thu, 19 Dec 2024 12:49:17 -0800 Subject: [PATCH] Create a copy of bytes for each channel decrypt --- src/mesh/Router.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/mesh/Router.cpp b/src/mesh/Router.cpp index 10bb03ef8..f55e7cc5a 100644 --- a/src/mesh/Router.cpp +++ b/src/mesh/Router.cpp @@ -357,12 +357,13 @@ bool perhapsDecode(meshtastic_MeshPacket *p) // assert(p->which_payloadVariant == MeshPacket_encrypted_tag); if (!decrypted) { - memcpy(bytes, p->encrypted.bytes, - rawSize); // we have to copy into a scratch buffer, because these bytes are a union with the decoded protobuf // Try to find a channel that works with this hash for (chIndex = 0; chIndex < channels.getNumChannels(); chIndex++) { // Try to use this hash/channel pair if (channels.decryptForHash(chIndex, p->channel)) { + // we have to copy into a scratch buffer, because these bytes are a union with the decoded protobuf. Create a + // fresh copy for each decrypt attempt. + memcpy(bytes, p->encrypted.bytes, rawSize); // Try to decrypt the packet if we can crypto->decrypt(p->from, p->id, rawSize, bytes);