Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 9 additions & 11 deletions src/Mesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,10 @@ DispatcherAction Mesh::onRecvPacket(Packet* pkt) {

if (pkt->isRouteDirect() && pkt->path_len >= PATH_HASH_SIZE) {
// check for 'early received' ACK
if (pkt->getPayloadType() == PAYLOAD_TYPE_ACK) {
int i = 0;
if (pkt->getPayloadType() == PAYLOAD_TYPE_ACK && pkt->payload_len >= 4) {
uint32_t ack_crc;
memcpy(&ack_crc, &pkt->payload[i], 4); i += 4;
if (i <= pkt->payload_len) {
onAckRecv(pkt, ack_crc);
}
memcpy(&ack_crc, pkt->payload, 4);
onAckRecv(pkt, ack_crc);
}

if (self_id.isHashMatch(pkt->path) && allowPacketForward(pkt)) {
Expand Down Expand Up @@ -115,12 +112,13 @@ DispatcherAction Mesh::onRecvPacket(Packet* pkt) {

switch (pkt->getPayloadType()) {
case PAYLOAD_TYPE_ACK: {
int i = 0;
uint32_t ack_crc;
memcpy(&ack_crc, &pkt->payload[i], 4); i += 4;
if (i > pkt->payload_len) {
if (pkt->payload_len < 4) {
MESH_DEBUG_PRINTLN("%s Mesh::onRecvPacket(): incomplete ACK packet", getLogDateTime());
} else if (!_tables->hasSeen(pkt)) {
break;
}
uint32_t ack_crc;
memcpy(&ack_crc, pkt->payload, 4);
if (!_tables->hasSeen(pkt)) {
onAckRecv(pkt, ack_crc);
action = routeRecvPacket(pkt);
}
Expand Down