Small C nitpicks from static analysis#11172
Merged
sensei-hacker merged 2 commits intoiNavFlight:maintenance-9.xfrom Dec 12, 2025
Merged
Small C nitpicks from static analysis#11172sensei-hacker merged 2 commits intoiNavFlight:maintenance-9.xfrom
sensei-hacker merged 2 commits intoiNavFlight:maintenance-9.xfrom
Conversation
Branch Targeting SuggestionYou've targeted the
If This is an automated suggestion to help route contributions to the appropriate branch. |
Contributor
PR Compliance Guide 🔍All compliance sections have been disabled in the configurations. |
85b4b78 to
5c182ae
Compare
b19b191 to
bfadfc5
Compare
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 <[email protected]>
bfadfc5 to
cdca77e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
1U << 31instead of1 << 31for FEATURE_FW_AUTOTRIM to avoid signed integer overflow with a different compiler (undefined behavior in C)sizeof(array) * sizeof(*array), should be justsizeof(array)tickerCharactersfrom pointer to array so sizeof() returns string length, not pointer size