AP_Terrain: Fix SIGFPE crash on invalid TERRAIN_CHECK command#32366
Closed
Ttl wants to merge 2 commits intoArduPilot:masterfrom
Closed
AP_Terrain: Fix SIGFPE crash on invalid TERRAIN_CHECK command#32366Ttl wants to merge 2 commits intoArduPilot:masterfrom
Ttl wants to merge 2 commits intoArduPilot:masterfrom
Conversation
Author
|
Just found ArduPilot/ardupilot_wiki#7359. This is probably not critical on real hardware and should instead be fixed in Mission Planner. |
peterbarker
requested changes
Mar 4, 2026
Contributor
peterbarker
left a comment
There was a problem hiding this comment.
We have a check_latlng method to do this.
.... but I think you're correct, we can simply say GIGO in this case; it's on the client to make correct requests.
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.
Summary
Sending TERRAIN_CHECK Mavlink command with out of range latitude leads to SIGFPE crash.
Testing (more checks increases chance of being merged)
Description
Can be reproduced in Mission Planner 1.3.83 (latest stable as of now) with mission that has single
DO_DIGICAM_CONFIGcommand with param5=138, param6=218.Reproduction mission
Backtrace
In the first place there shouldn't be a reason for mission planner to send TERRAIN_CHECK for this command. However, if TERRAIN_CHECK with out of range lat or lon is given it first overflows
lat_degreesint8_t in AP_Terrain. This ends up callingLocation::offset_latlngwith very large float input. Lineconst int32_t dlat = ofs_north * LOCATION_SCALING_FACTOR_INV;inLocation.cpp:482causes the crash as the multiplication output is too large to fit in int32_t.This PR adds guard in height_asml to reject inputs that are out of valid range.