Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AP_Mission: get_item: ensure returned item is clean #29038

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

IamPete1
Copy link
Member

@IamPete1 IamPete1 commented Jan 10, 2025

Mission does not fill in all fields of the returned item, this means you can get random data. This results in getting bad data via misison ftp or scripting. The mavlink mission item protocol does not use this method. The other mission ftp types are OK because they always fill in the full set of information.

To reproduce, upload a misison and then read it back again. For example before.txt. Testing shown for SITL but the bug also exists on real hardware.

This is what we upload:
image

This is what we read back on master:
image

With the fix we get the same as what is written:
image

This only shows up in the x,y,z fields of a item without location because the other fields are defaulted here:

// command's position in mission list and mavlink id
packet.seq = cmd.index;
packet.command = cmd.id;
// set defaults
packet.current = 0; // 1 if we are passing back the mission command that is currently being executed
packet.param1 = 0;
packet.param2 = 0;
packet.param3 = 0;
packet.param4 = 0;
packet.frame = 0;
packet.autocontinue = 1;

A alternate (or complementary) fix would be to also set default values for the x,y and z values there.

@IamPete1 IamPete1 added the BUG label Jan 10, 2025
@IamPete1
Copy link
Member Author

I caved and added the defaulting in the mission_cmd_to_mavlink_int function too. There is no change in behavior from that fix because all callers pass in a clean command object.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant