Skip to content

Commit

Permalink
Consider the LoRa header when checking packet length
Browse files Browse the repository at this point in the history
  • Loading branch information
jp-bennett committed Sep 22, 2024
1 parent 2e24d24 commit 18aac0b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/mesh/RadioInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#define MAX_TX_QUEUE 16 // max number of packets which can be waiting for transmission

#define MAX_RHPACKETLEN 256
#define LORA_HEADER_LENGTH 16

#define PACKET_FLAGS_HOP_LIMIT_MASK 0x07
#define PACKET_FLAGS_WANT_ACK_MASK 0x08
Expand Down
4 changes: 2 additions & 2 deletions src/mesh/Router.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ meshtastic_Routing_Error perhapsEncode(meshtastic_MeshPacket *p)
}
} */

if (numbytes > MAX_RHPACKETLEN)
if (numbytes + LORA_HEADER_LENGTH > MAX_RHPACKETLEN)
return meshtastic_Routing_Error_TOO_LARGE;

// printBytes("plaintext", bytes, numbytes);
Expand All @@ -499,7 +499,7 @@ meshtastic_Routing_Error perhapsEncode(meshtastic_MeshPacket *p)
p->decoded.portnum != meshtastic_PortNum_TRACEROUTE_APP && p->decoded.portnum != meshtastic_PortNum_NODEINFO_APP &&
p->decoded.portnum != meshtastic_PortNum_ROUTING_APP && p->decoded.portnum != meshtastic_PortNum_POSITION_APP) {
LOG_DEBUG("Using PKI!\n");
if (numbytes + 12 > MAX_RHPACKETLEN)
if (numbytes + LORA_HEADER_LENGTH + 12 > MAX_RHPACKETLEN)
return meshtastic_Routing_Error_TOO_LARGE;
if (p->pki_encrypted && !memfll(p->public_key.bytes, 0, 32) &&
memcmp(p->public_key.bytes, node->user.public_key.bytes, 32) != 0) {
Expand Down

0 comments on commit 18aac0b

Please sign in to comment.