From 4f1682c3c87b450b89d5b793f8dbea019a0c11a9 Mon Sep 17 00:00:00 2001 From: RomanBapst Date: Thu, 21 Sep 2023 14:06:41 +0300 Subject: [PATCH] UTM_GLOBAL_POSITION: prevent uint16 overflow Signed-off-by: RomanBapst --- src/modules/mavlink/streams/UTM_GLOBAL_POSITION.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/modules/mavlink/streams/UTM_GLOBAL_POSITION.hpp b/src/modules/mavlink/streams/UTM_GLOBAL_POSITION.hpp index 2cf17b69f2..b58852dbaf 100644 --- a/src/modules/mavlink/streams/UTM_GLOBAL_POSITION.hpp +++ b/src/modules/mavlink/streams/UTM_GLOBAL_POSITION.hpp @@ -101,8 +101,8 @@ private: msg.lon = global_pos.lon * 1e7; msg.alt = global_pos.alt_ellipsoid * 1000.f; - msg.h_acc = global_pos.eph * 1000.f; - msg.v_acc = global_pos.epv * 1000.f; + msg.h_acc = math::min(global_pos.eph * 1000.0f, (float)UINT16_MAX); + msg.v_acc = math::min(global_pos.epv * 1000.0f, (float)UINT16_MAX); msg.flags |= UTM_DATA_AVAIL_FLAGS_POSITION_AVAILABLE; msg.flags |= UTM_DATA_AVAIL_FLAGS_ALTITUDE_AVAILABLE;