From 7a57992275ab3b1ead10527aeb2aa8d65e1e60c1 Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Thu, 24 Nov 2016 10:18:28 +0000 Subject: [PATCH] Cap the height and power so that the config message isn't corrupted. --- DMRNetwork.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/DMRNetwork.cpp b/DMRNetwork.cpp index f902d2f..1bd016a 100644 --- a/DMRNetwork.cpp +++ b/DMRNetwork.cpp @@ -522,8 +522,16 @@ bool CDMRNetwork::writeConfig() char longitude[20U]; ::sprintf(longitude, "%09f", m_longitude); + unsigned int power = m_power; + if (power > 99U) + power = 99U; + + int height = m_height; + if (height > 999U) + height = 99U; + ::sprintf(buffer + 8U, "%-8.8s%09u%09u%02u%02u%8.8s%9.9s%03d%-20.20s%-19.19s%c%-124.124s%-40.40s%-40.40s", m_callsign.c_str(), - m_rxFrequency, m_txFrequency, m_power, m_colorCode, latitude, longitude, m_height, m_location.c_str(), + m_rxFrequency, m_txFrequency, power, m_colorCode, latitude, longitude, height, m_location.c_str(), m_description.c_str(), slots, m_url.c_str(), m_version, software); return write((unsigned char*)buffer, 302U);