From c442fd3886cf29e1dbd098447736fe9aa94d266b Mon Sep 17 00:00:00 2001 From: a-f-G-U-C <65810997+a-f-G-U-C@users.noreply.github.com> Date: Fri, 10 Sep 2021 15:12:12 +0000 Subject: [PATCH] input sanitization - TinyGPS course() Reduce the impact of issue #863 (and similar issues in the future) by filtering out obvious bogons --- src/gps/NMEAGPS.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/gps/NMEAGPS.cpp b/src/gps/NMEAGPS.cpp index dcb24d61..c652fab6 100644 --- a/src/gps/NMEAGPS.cpp +++ b/src/gps/NMEAGPS.cpp @@ -163,7 +163,12 @@ bool NMEAGPS::lookForLocation() } if (reader.course.isUpdated() && reader.course.isValid()) { - heading = reader.course.value() * 1e3; // Scale the heading (in degrees * 10^-2) to match the expected degrees * 10^-5 + if (reader.course.value() < 36000) { // sanity check + heading = reader.course.value() * 1e3; // Scale the heading (in degrees * 10^-2) to match the expected degrees * 10^-5 + } else { + DEBUG_MSG("BOGUS course.value() REJECTED: %d\n", + reader.course.value()); + } } /*