From bb7cf6c0b68d0a9346601874ba7e1849d1f999d3 Mon Sep 17 00:00:00 2001 From: Michael du Breuil Date: Mon, 11 Apr 2016 14:06:03 -0700 Subject: [PATCH] AP_Math: Update location_sanitize to sanitize for lat/lng --- libraries/AP_Math/location.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/libraries/AP_Math/location.cpp b/libraries/AP_Math/location.cpp index b4f3368939..789942640f 100644 --- a/libraries/AP_Math/location.cpp +++ b/libraries/AP_Math/location.cpp @@ -259,6 +259,14 @@ bool location_sanitize(const struct Location &defaultLoc, struct Location &loc) loc.alt = defaultLoc.alt; has_changed = true; } + + // limit lat/lng to appropriate ranges + if (abs(loc.lat) > 90 * 1e7 || abs(loc.lng) > 180 * 1e7) { + loc.lat = defaultLoc.lat; + loc.lng = defaultLoc.lng; + has_changed = true; + } + return has_changed; }