From: Remi Gacogne Date: Tue, 19 Mar 2019 15:42:25 +0000 (+0100) Subject: rec: Handle invalid numeric values from the control channel X-Git-Tag: dnsdist-1.4.0-alpha1~41^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fpull%2F7574%2Fhead;p=thirdparty%2Fpdns.git rec: Handle invalid numeric values from the control channel --- diff --git a/pdns/rec_channel_rec.cc b/pdns/rec_channel_rec.cc index 75bdc2e5a0..bb5bfba56b 100644 --- a/pdns/rec_channel_rec.cc +++ b/pdns/rec_channel_rec.cc @@ -696,8 +696,13 @@ static string setMinimumTTL(T begin, T end) { if(end-begin != 1) return "Need to supply new minimum TTL number\n"; - SyncRes::s_minimumTTL = pdns_stou(*begin); - return "New minimum TTL: " + std::to_string(SyncRes::s_minimumTTL) + "\n"; + try { + SyncRes::s_minimumTTL = pdns_stou(*begin); + return "New minimum TTL: " + std::to_string(SyncRes::s_minimumTTL) + "\n"; + } + catch (const std::exception& e) { + return "Error parsing the new minimum TTL number: " + std::string(e.what()) + "\n"; + } } template @@ -705,8 +710,13 @@ static string setMinimumECSTTL(T begin, T end) { if(end-begin != 1) return "Need to supply new ECS minimum TTL number\n"; - SyncRes::s_minimumECSTTL = pdns_stou(*begin); - return "New minimum ECS TTL: " + std::to_string(SyncRes::s_minimumECSTTL) + "\n"; + try { + SyncRes::s_minimumECSTTL = pdns_stou(*begin); + return "New minimum ECS TTL: " + std::to_string(SyncRes::s_minimumECSTTL) + "\n"; + } + catch (const std::exception& e) { + return "Error parsing the new ECS minimum TTL number: " + std::string(e.what()) + "\n"; + } } template @@ -714,8 +724,13 @@ static string setMaxCacheEntries(T begin, T end) { if(end-begin != 1) return "Need to supply new cache size\n"; - g_maxCacheEntries = pdns_stou(*begin); - return "New max cache entries: " + std::to_string(g_maxCacheEntries) + "\n"; + try { + g_maxCacheEntries = pdns_stou(*begin); + return "New max cache entries: " + std::to_string(g_maxCacheEntries) + "\n"; + } + catch (const std::exception& e) { + return "Error parsing the new cache size: " + std::string(e.what()) + "\n"; + } } template @@ -723,8 +738,13 @@ static string setMaxPacketCacheEntries(T begin, T end) { if(end-begin != 1) return "Need to supply new packet cache size\n"; - g_maxPacketCacheEntries = pdns_stou(*begin); - return "New max packetcache entries: " + std::to_string(g_maxPacketCacheEntries) + "\n"; + try { + g_maxPacketCacheEntries = pdns_stou(*begin); + return "New max packetcache entries: " + std::to_string(g_maxPacketCacheEntries) + "\n"; + } + catch (const std::exception& e) { + return "Error parsing the new packet cache size: " + std::string(e.what()) + "\n"; + } }