From 9b1320a899f2db016786500a645759034ef4429b Mon Sep 17 00:00:00 2001 From: Wessel Date: Tue, 3 Mar 2026 00:35:33 +0100 Subject: [PATCH] Apply suggestions from code review Co-authored-by: J.C. Jones --- src/helpers/BaseChatMesh.cpp | 5 ++++- src/helpers/ClientACL.cpp | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/helpers/BaseChatMesh.cpp b/src/helpers/BaseChatMesh.cpp index 8cf942e44..b6a062937 100644 --- a/src/helpers/BaseChatMesh.cpp +++ b/src/helpers/BaseChatMesh.cpp @@ -1345,7 +1345,10 @@ uint8_t BaseChatMesh::handleIncomingSessionKeyInit(ContactInfo& from, const uint // 4. Store in pool (dual-decode: new key active, old key still valid) auto entry = allocateSessionKey(from.id.pub_key); - if (!entry) return 0; + if (!entry) { + memset(new_session_key, 0, SESSION_KEY_SIZE); + return 0; + } if (entry->state == SESSION_STATE_ACTIVE || entry->state == SESSION_STATE_DUAL_DECODE) { memcpy(entry->prev_session_key, entry->session_key, SESSION_KEY_SIZE); diff --git a/src/helpers/ClientACL.cpp b/src/helpers/ClientACL.cpp index fae658aa5..46ddea575 100644 --- a/src/helpers/ClientACL.cpp +++ b/src/helpers/ClientACL.cpp @@ -264,7 +264,10 @@ int ClientACL::handleSessionKeyInit(const ClientInfo* client, const uint8_t* eph // 4. Store in pool (dual-decode: new key active, old key still valid) auto entry = allocateSessionKey(client->id.pub_key); - if (!entry) return 0; + if (!entry) { + memset(new_session_key, 0, SESSION_KEY_SIZE); + return 0; + } if (entry->state == SESSION_STATE_ACTIVE || entry->state == SESSION_STATE_DUAL_DECODE) { memcpy(entry->prev_session_key, entry->session_key, SESSION_KEY_SIZE);