1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-22 18:50:08 +03:00

bug #4582: Better checks for IPv4 strings

This commit is contained in:
Ruben S. Montero 2016-06-18 00:29:47 +02:00
parent 42fb4ab94f
commit 7571dbdc1b

View File

@ -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;
}