Browse Source
add debug log for malformed PATH payload
Log path_len and len when the bounds check fails, making it easier to
diagnose malformed or corrupt packets during development.
pull/1654/head
Wessel Nieboer
4 months ago
No known key found for this signature in database
GPG Key ID: 929C8E45E33B5FD2
1 changed files with
4 additions and
1 deletions
-
src/Mesh.cpp
|
|
@ -155,7 +155,10 @@ DispatcherAction Mesh::onRecvPacket(Packet* pkt) { |
|
|
uint8_t path_len = data[k++]; |
|
|
uint8_t path_len = data[k++]; |
|
|
uint8_t hash_size = (path_len >> 6) + 1; |
|
|
uint8_t hash_size = (path_len >> 6) + 1; |
|
|
uint8_t hash_count = path_len & 63; |
|
|
uint8_t hash_count = path_len & 63; |
|
|
if (k + hash_size*hash_count + 1 > len) break; // bounds check: need path bytes + extra_type byte
|
|
|
if (k + hash_size*hash_count + 1 > len) { // bounds check: need path bytes + extra_type byte
|
|
|
|
|
|
MESH_DEBUG_PRINTLN("%s Mesh::onRecvPacket(): bad PATH payload format, path_len=%d len=%d", getLogDateTime(), (int)path_len, (int)len); |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
uint8_t* path = &data[k]; k += hash_size*hash_count; |
|
|
uint8_t* path = &data[k]; k += hash_size*hash_count; |
|
|
uint8_t extra_type = data[k++] & 0x0F; // upper 4 bits reserved for future use
|
|
|
uint8_t extra_type = data[k++] & 0x0F; // upper 4 bits reserved for future use
|
|
|
uint8_t* extra = &data[k]; |
|
|
uint8_t* extra = &data[k]; |
|
|
|