From 09cbfed4ac9e8041bd58fa2ed64dde9a0c1fbe40 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Sat, 24 Aug 2019 09:47:53 +0200 Subject: [PATCH] Fix string truncation --- src/algorithms/PVT/libs/rtcm.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/algorithms/PVT/libs/rtcm.h b/src/algorithms/PVT/libs/rtcm.h index b124203ba..2cccef89d 100644 --- a/src/algorithms/PVT/libs/rtcm.h +++ b/src/algorithms/PVT/libs/rtcm.h @@ -44,6 +44,7 @@ #include #include #include +#include // for min #include #include // for size_t #include @@ -593,7 +594,7 @@ private: inline void encode_header() { char header[header_length + 1] = ""; - std::snprintf(header, header_length, "GS%4d", static_cast(body_length_)); + std::snprintf(header, header_length + 1, "GS%4d", std::min(static_cast(body_length_), static_cast(max_body_length))); std::memcpy(data_, header, header_length); }