From 7571dbdc1b732819d4afb5c63130fbe791f185e0 Mon Sep 17 00:00:00 2001 From: "Ruben S. Montero" Date: Sat, 18 Jun 2016 00:29:47 +0200 Subject: [PATCH] bug #4582: Better checks for IPv4 strings --- src/vnm/AddressRange.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/vnm/AddressRange.cc b/src/vnm/AddressRange.cc index ca0987e552..c3f3cfbf72 100644 --- a/src/vnm/AddressRange.cc +++ b/src/vnm/AddressRange.cc @@ -641,6 +641,11 @@ int AddressRange::ip_to_i(const string& _ip, unsigned int& i_ip) const return -1; } + if ( ip.find_first_not_of("0123456789 ") != std::string::npos ) + { + return -1; + } + iss.str(ip); i_ip = 0; @@ -649,7 +654,7 @@ int AddressRange::ip_to_i(const string& _ip, unsigned int& i_ip) const { iss >> dec >> tmp >> ws; - if ( tmp > 255 ) + if ( tmp > 255 || iss.fail() ) { return -1; }