Skip to content

Commit 7a57e7a

Browse files
committed
tighten TRACE path_len guard to account for SNR append
The TRACE forwarding path appends an SNR byte to pkt->path via path_len++, but the guard only checked path_len < MAX_PATH_SIZE. When path_len entered as MAX_PATH_SIZE - 1, the write was in-bounds but left path_len equal to MAX_PATH_SIZE, which could cause off-by-one issues in downstream code that uses path_len as an index. Change the guard to path_len + 1 < MAX_PATH_SIZE so there is always room for the append without path_len reaching MAX_PATH_SIZE.
1 parent df01fd3 commit 7a57e7a

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

src/Mesh.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ int Mesh::searchChannelsByHash(const uint8_t* hash, GroupChannel channels[], int
4040

4141
DispatcherAction Mesh::onRecvPacket(Packet* pkt) {
4242
if (pkt->isRouteDirect() && pkt->getPayloadType() == PAYLOAD_TYPE_TRACE) {
43-
if (pkt->path_len < MAX_PATH_SIZE) {
43+
if (pkt->path_len + 1 < MAX_PATH_SIZE) {
4444
uint8_t i = 0;
4545
uint32_t trace_tag;
4646
memcpy(&trace_tag, &pkt->payload[i], 4); i += 4;

0 commit comments

Comments
 (0)