Skip to content

Conversation

@sensei-hacker
Copy link
Member

@sensei-hacker sensei-hacker commented Dec 10, 2025

User description

Summary

Minor fixes found during cppcheck static analysis review. None of these are likely to cause issues in practice, but they're worth cleaning up.

Changes

  • fc/config.h: Use 1U << 31 instead of 1 << 31 for FEATURE_FW_AUTOTRIM to avoid signed integer overflow with a different compiler (undefined behavior in C)
  • sensors/temperature.c: Fix doubled sizeof in memset - was sizeof(array) * sizeof(*array), should be just sizeof(array)
  • rx/crsf.c: Add bounds check on frame length to prevent potential buffer overflow from malformed packets
  • io/dashboard.c: Change tickerCharacters from pointer to array so sizeof() returns string length, not pointer size

@github-actions
Copy link

Branch Targeting Suggestion

You've targeted the master branch with this PR. Please consider if a version branch might be more appropriate:

  • maintenance-9.x - If your change is backward-compatible and won't create compatibility issues between INAV firmware and Configurator 9.x versions. This will allow your PR to be included in the next 9.x release.

  • maintenance-10.x - If your change introduces compatibility requirements between firmware and configurator that would break 9.x compatibility. This is for PRs which will be included in INAV 10.x

If master is the correct target for this change, no action is needed.


This is an automated suggestion to help route contributions to the appropriate branch.

@qodo-code-review
Copy link
Contributor

qodo-code-review bot commented Dec 10, 2025

PR Compliance Guide 🔍

All compliance sections have been disabled in the configurations.

@sensei-hacker sensei-hacker force-pushed the fix/cppcheck-critical-bugs branch from 85b4b78 to 5c182ae Compare December 10, 2025 05:24
@sensei-hacker sensei-hacker changed the base branch from master to maintenance-9.x December 10, 2025 05:25
@sensei-hacker sensei-hacker force-pushed the fix/cppcheck-critical-bugs branch 4 times, most recently from b19b191 to bfadfc5 Compare December 10, 2025 05:27
sensei-hacker and others added 2 commits December 9, 2025 23:28
Two bugs found by cppcheck static analysis:

1. fc/config.h:66 - Integer overflow in FEATURE_FW_AUTOTRIM
   - `1 << 31` could cause signed integer overflow (undefined behavior in C)
   - Fixed by using `1U << 31` for unsigned shift

2. sensors/temperature.c:101 - Buffer overrun in memset
   - sizeof(array) is already the size in bytes, so should not be multiplied by element size.
   - Fixed by using just `sizeof(sensorStatus)`
CRSF buffer overflow (rx/crsf.c):
- fullFrameLength computed from untrusted frameLength field
- Malformed packet with large frameLength could overflow crsfFrame.bytes[]
- Added bounds check against CRSF_FRAME_SIZE_MAX before writing

Dashboard sizeof bug (io/dashboard.c):
- tickerCharacters was a pointer, so sizeof() returned pointer size (4/8)
- On 64-bit systems, TICKER_CHARACTER_COUNT was 8 instead of 4
- Could read past end of string when indexing tickerCharacters[]
- Changed to array declaration and sizeof()-1 for correct count

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@sensei-hacker sensei-hacker force-pushed the fix/cppcheck-critical-bugs branch from bfadfc5 to cdca77e Compare December 10, 2025 05:28
@sensei-hacker sensei-hacker merged commit 2152748 into iNavFlight:maintenance-9.x Dec 12, 2025
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant