mirror of
https://github.com/meshtastic/firmware.git
synced 2025-08-05 13:14:45 +00:00
If we get an unreadable buffer, don't try to process it.
This commit is contained in:
parent
71a43a97cc
commit
e8afd4fb4b
@ -77,10 +77,13 @@ template <class T> class ProtobufModule : protected SinglePortModule
|
|||||||
T *decoded = NULL;
|
T *decoded = NULL;
|
||||||
if (mp.which_payloadVariant == MeshPacket_decoded_tag && mp.decoded.portnum == ourPortNum) {
|
if (mp.which_payloadVariant == MeshPacket_decoded_tag && mp.decoded.portnum == ourPortNum) {
|
||||||
memset(&scratch, 0, sizeof(scratch));
|
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;
|
decoded = &scratch;
|
||||||
else
|
} else {
|
||||||
DEBUG_MSG("Error decoding protobuf module!\n");
|
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;
|
return handleReceivedProtobuf(mp, decoded) ? ProcessMessage::STOP : ProcessMessage::CONTINUE;
|
||||||
|
Loading…
Reference in New Issue
Block a user