From ac9c81f6d136438f3e8a9fe96b46929770b588ef Mon Sep 17 00:00:00 2001 From: Jonathan Bennett Date: Mon, 24 Jul 2023 09:37:56 -0500 Subject: [PATCH] Check Position Request for Primary Channel (#2638) Prevents leaking location data to secondary channels. Co-authored-by: Ben Meadors --- src/modules/PositionModule.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/modules/PositionModule.cpp b/src/modules/PositionModule.cpp index 35457a23e..10289b837 100644 --- a/src/modules/PositionModule.cpp +++ b/src/modules/PositionModule.cpp @@ -52,11 +52,22 @@ bool PositionModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp, mes nodeDB.updatePosition(getFrom(&mp), p); + // Only respond to location requests on the channel where we broadcast location. + if (channels.getByIndex(mp.channel).role == meshtastic_Channel_Role_PRIMARY) { + ignoreRequest = false; + } else { + ignoreRequest = true; + } + return false; // Let others look at this message also if they want } meshtastic_MeshPacket *PositionModule::allocReply() { + if (ignoreRequest) { + return NULL; + } + meshtastic_NodeInfoLite *node = service.refreshLocalMeshNode(); // should guarantee there is now a position assert(node->has_position);