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:
parent
42fb4ab94f
commit
7571dbdc1b
@ -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;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user