Conversation
osdHudDrawPoi() formats into char buff[4], but both of the poiType == 1 paths write a terminator at index 4: tfp_sprintf(buff + 1, "%3d", altc) writes three digits into buff[1..3] and the terminator into buff[4], and osdFormatCentiNumber(buff, ..., 4, 4, false) starts with buff[length] = '\0' with length 4, so it writes buff[4] directly. poiType == 1 is the radar POI, so this happens for every radar marker drawn, on every OSD frame that has one on screen. Both other branches use a width of 3 and stay inside the array. The four characters are all read back (buff[0..3] are written to the display for poiType == 1), so the array needs five bytes, not four.
Raffi1202
marked this pull request as ready for review
September 11, 2026 15:36
Contributor
|
ⓘ Qodo reviews are paused because the subscription is no longer active. Ask your workspace admin to reactivate the subscription to resume reviews. Manage billing |
PR Summary by QodoPrevent HUD radar POI buffer overflow
AI Description
High-Level Assessment
Files changed (1)
|
Code Review by Qodo🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)
Great, no issues found!Qodo reviewed your code and found no material issues that require reviewTip of the day💡 Did you know, you can switch off images and animations for a plain-text comment |
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.
Problem
No issue was filed. The defect was found by reading the code while writing the OSD HUD documentation page (iNavFlight/iNavFlight.github.io#24). Whenever a radar POI (ESP32 craft radar peer) is drawn on the HUD,
osdHudDrawPoi()writes one byte past the end of its localbuffarray, on every OSD frame that shows the marker. No visible symptom is known; the byte lands on adjacent stack memory.Cause
src/main/io/osd_hud.c:130onmaintenance-10.xdeclareschar buff[4], but bothpoiType == 1(radar POI) paths write a terminator at index 4.osd_hud.c:250tfp_sprintf(buff+1, "%3d", altc)puts three digits inbuff[1..3]and'\0'inbuff[4].osd_hud.c:264,:273and:286callosdFormatCentiNumber(buff, ..., 4, 4, false), whose first statement isbuff[length] = '\0'(src/main/io/osd_utils.c:50) withlength = 4. The non-radar branches use width 3 and stay in bounds. All four charactersbuff[0..3]are read back atosd_hud.c:295-299, so the format cannot be shortened. The same lines are present at the same line numbers onrelease/9.1.Change
Enlarges
bufffrom 4 to 5 bytes inosdHudDrawPoi()and adds a comment naming the two writers of index 4. No control-flow or output change.Test
Not run on hardware or SITL. Cause verified by reading
src/main/io/osd_hud.c:130,250,264,273,286andsrc/main/io/osd_utils.c:50onmaintenance-10.x. The upstream "Build firmware" run for the head commit is waiting for maintainer approval (https://github.com/iNavFlight/inav/actions/runs/34533380329); no fork build exists for the head SHA. Qodo review: no issues found.Flash / RAM
Not measured yet. The upstream firmware CI has not been released for this PR, so no size report exists.
Docs
No documentation change needed: the displayed characters are unchanged; the fix only removes an out-of-bounds write.