Skip to content

Conversation

@weebl2000
Copy link
Contributor

Severity: Low

Summary

When a node forwards a TRACE packet, it appends its SNR reading to pkt->path and increments path_len. The existing guard checks path_len < MAX_PATH_SIZE, which allows path_len of 63 through. After the append, path_len becomes 64 — equal to MAX_PATH_SIZE. The write itself is in-bounds (the array is 64 bytes, index 63 is valid), but path_len is now at the maximum, which could cause an off-by-one in any downstream code that uses path_len as an array index without re-checking.

Not exploitable in the current codebase, but a defensive fix to prevent future bugs as the code evolves.

Fix

Change the guard from path_len < MAX_PATH_SIZE to path_len + 1 < MAX_PATH_SIZE, ensuring there is always room for the SNR append without path_len reaching MAX_PATH_SIZE.

Test plan

  • TRACE packets still forwarded correctly through multi-hop paths
  • Long paths (62+ hops) terminate gracefully instead of appending at the boundary
  • Build tested on Heltec_v3_companion_radio_ble

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant