Conversation
JUMP targets are uploaded as 1 based WP numbers and converted to a zero based index on storage, so a target of 0 ended up stored as -1 and was later used to index the waypoint list. Reject such uploads and refuse a negative target in the mission validation as well. Fixes iNavFlight#11841
|
ⓘ 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 QodoReject out-of-range JUMP waypoint targets
AI Description
Diagram
High-Level Assessment
Files changed (1)
|
Code Review by Qodo
1.
|
|
RAM / Flash usage vs. base commit
See RAM/flash optimization guide for techniques to reduce usage. |
|
Test firmware build ready — commit Download firmware for PR #11900 250 targets built. Find your board's
|
Problem
Fixes #11841. The reporter uploaded a mission via
MSP_SET_WPcontaining a JUMP waypoint withp1 = 0. INAV accepted it:setWaypoint()converts the 1-based target to a 0-based index, so the stored target became-1. The arming check then computeduint16_t target = p1 + startWpIndex= 65535 and readposControl.waypointList[65535]; if the mission ran, the FSM assigned the negative value toactiveWaypointIndex. @breadoven confirmed the bug.Cause
src/main/navigation/navigation.c:5482(maintenance-10.x):posControl.waypointList[wpNumber - 1].p1 -= 1;runs with no lower-bound check onp1.navigationIsBlockingArming()atnavigation.c:6369only testsp1 >= waypointCount, notp1 < 0, before the lookup at:6375. The FSM uses the stored index unchecked at:3050.Change
In
setWaypoint(), a JUMP withp1 < 1orp1 > NAV_MAX_WAYPOINTSreturns before the waypoint is copied and before the index conversion, so nothing is stored. The check runs after thewpNumber == 1reset, so a rejected first waypoint leaves the list empty (waypointCount0,waypointListValidfalse) instead of keeping the previous mission; that reset now also clears the staticnonGeoWaypointCount.navigationIsBlockingArming()additionally returnsNAV_ARMING_BLOCKER_JUMP_WAYPOINT_ERRORfor a negative storedp1, which covers the CLIwpcommand (cli.c:2015,:2031) that writesp1straight intowaypointList.Test
Not run on hardware or SITL. Cause verified by reading
navigation.c:5482and:6369on maintenance-10.x; theMSP_SET_WPhandler (fc_msp.c:3336) and the CLIwppath were traced to confirm both entry points are covered. No unit test exercisessetWaypoint()ornavigationIsBlockingArming()(navigation_unittest.cc.txtis disabled). Built by fork CI: pending. Compiled for all targets and the four SITL builds on the fork, green: https://github.com/Raffi1202/inav/actions/runs/34770668275Flash / RAM
Builds clean on all targets. No size comparison yet: the fork build has no baseline for this branch, and the upstream size report runs once CI is released for this PR.
Docs
No documentation change needed:
docs/Navigation.md:86(CLIp1= target WP index) and theMSP_SET_WPreference indocs/development/msp/README.md:2485describe the field, not the handling of an out-of-range target, which previously had no defined behaviour.