Cap the height and power so that the config message isn't corrupted.

This commit is contained in:
Jonathan Naylor 2016-11-24 10:18:28 +00:00 committed by GitHub
parent fee3cf561c
commit 7a57992275

View file

@ -522,8 +522,16 @@ bool CDMRNetwork::writeConfig()
char longitude[20U]; char longitude[20U];
::sprintf(longitude, "%09f", m_longitude); ::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(), ::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); m_description.c_str(), slots, m_url.c_str(), m_version, software);
return write((unsigned char*)buffer, 302U); return write((unsigned char*)buffer, 302U);