From e8afd4fb4b9f73f381301a0468c12f5cb3f51264 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Wed, 1 Jun 2022 17:09:57 +0200 Subject: [PATCH] If we get an unreadable buffer, don't try to process it. --- src/mesh/ProtobufModule.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/mesh/ProtobufModule.h b/src/mesh/ProtobufModule.h index 4e411c2a4..6d307d921 100644 --- a/src/mesh/ProtobufModule.h +++ b/src/mesh/ProtobufModule.h @@ -77,10 +77,13 @@ template class ProtobufModule : protected SinglePortModule T *decoded = NULL; if (mp.which_payloadVariant == MeshPacket_decoded_tag && mp.decoded.portnum == ourPortNum) { memset(&scratch, 0, sizeof(scratch)); - if (pb_decode_from_bytes(p.payload.bytes, p.payload.size, fields, &scratch)) + if (pb_decode_from_bytes(p.payload.bytes, p.payload.size, fields, &scratch)) { decoded = &scratch; - else + } else { DEBUG_MSG("Error decoding protobuf module!\n"); + // if we can't decode it, nobody can process it! + return ProcessMessage::STOP; + } } return handleReceivedProtobuf(mp, decoded) ? ProcessMessage::STOP : ProcessMessage::CONTINUE;