fix compiler warnings about exception polymorhism; enforce some fixed mode rules for hotspots; fix potential buffer overflow;

pull/12/head
Bryan Biedenkapp 4 years ago
parent fefd4ce4ad
commit 0058e1ab54

@ -145,7 +145,7 @@ int Host::run()
::fatal("cannot read the configuration file, %s\n", m_confFile.c_str());
}
}
catch (yaml::OperationException e) {
catch (yaml::OperationException const& e) {
::fatal("cannot read the configuration file, %s", e.message());
}
@ -544,6 +544,20 @@ int Host::run()
g_killed = true;
}
// check if the modem is a hotspot
if (m_modem->isHotspot()) {
if (m_dmrEnabled && m_p25Enabled) {
::LogError(LOG_HOST, "Dual-mode (DMR and P25) is not supported for hotspots!");
g_killed = true;
}
else {
if (!m_fixedMode) {
::LogInfoEx(LOG_HOST, "Host is running on a hotspot modem! Fixed mode is forced.");
m_fixedMode = true;
}
}
}
if (!g_killed) {
// fixed more or P25 control channel will force a state change
if (m_fixedMode || m_p25CtrlChannel) {

@ -873,6 +873,15 @@ bool Modem::hasP25Space() const
return space > 1U;
}
/// <summary>
/// Helper to test if the modem is a hotspot.
/// </summary>
/// <returns>True, if the modem is a hotspot, otherwise false.</returns>
bool Modem::isHotspot() const
{
return m_isHotspot;
}
/// <summary>
/// Flag indicating whether or not the air interface modem is transmitting.
/// </summary>

@ -235,6 +235,9 @@ namespace modem
bool hasDMRSpace2() const;
/// <summary>Helper to test if the P25 ring buffer has free space.</summary>
bool hasP25Space() const;
/// <summary>Helper to test if the modem is a hotspot.</summary>
bool isHotspot() const;
/// <summary>Flag indicating whether or not the air interface modem is transmitting.</summary>
bool hasTX() const;

@ -493,7 +493,7 @@ bool Network::writeAuthorisation()
bool Network::writeConfig()
{
const char* software = "DVM_DMR_P25";
char buffer[168U];
char buffer[176U];
::memcpy(buffer + 0U, TAG_REPEATER_CONFIG, 4U);
__SET_UINT32(m_id, buffer, 4U);
@ -532,9 +532,9 @@ bool Network::writeConfig()
"", m_rconPassword.c_str(), m_rconPort);
if (m_debug)
Utils::dump(1U, "Network Transmitted, Configuration", (uint8_t*)buffer, 168U);
Utils::dump(1U, "Network Transmitted, Configuration", (uint8_t*)buffer, 176U);
return write((uint8_t*)buffer, 168U);
return write((uint8_t*)buffer, 176U);
}
/// <summary>

@ -1597,7 +1597,7 @@ namespace yaml
postProcessLines();
parseRoot(root);
}
catch (Exception e)
catch (Exception const& e)
{
root.clear();
throw;
@ -2269,7 +2269,7 @@ namespace yaml
delete pImp;
return true;
}
catch (const Exception e)
catch (Exception const& e)
{
delete pImp;
return false;

Loading…
Cancel
Save

Powered by TurnKey Linux.