From 8561dfb8824946ce481ef795e5489e3d3d3c2f0a Mon Sep 17 00:00:00 2001 From: Noah Markert Date: Sat, 30 Nov 2024 23:55:59 +0100 Subject: [PATCH] GCS_MAVLink: add integer bound check --- libraries/GCS_MAVLink/GCS_Common.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/libraries/GCS_MAVLink/GCS_Common.cpp b/libraries/GCS_MAVLink/GCS_Common.cpp index e670339e7b..506ab0eee1 100644 --- a/libraries/GCS_MAVLink/GCS_Common.cpp +++ b/libraries/GCS_MAVLink/GCS_Common.cpp @@ -5151,7 +5151,11 @@ static int32_t convert_COMMAND_LONG_loc_param(float param, bool stores_location) } if (stores_location) { - return param *1e7; + float convertedValue = param *1e7; + if (convertedValue < INT32_MIN || convertedValue > INT32_MAX) { + return 0; + } + return convertedValue; } return param;