1
0
mirror of https://github.com/anope/anope.git synced 2026-07-04 14:53:12 +02:00

Fix str_is_ip() and str_is_cidr(), bug found by Cronus.

This commit is contained in:
Naram Qashat
2010-08-03 07:26:43 -04:00
parent 44387a2587
commit a659f82814
+2 -2
View File
@@ -1210,7 +1210,7 @@ uint32 str_is_ip(const Anope::string &str)
for (int i = 0; i < 4; ++i)
{
octets[i] = convertTo<int>(s, s, false);
octets[i] = s.empty() || !s.is_number_only() ? -1 : convertTo<int>(s, s, false);
/* Bail out if the octet is invalid or wrongly terminated */
if (octets[i] < 0 || octets[i] > 255 || (i < 3 && s[0] != '.'))
return 0;
@@ -1243,7 +1243,7 @@ bool str_is_cidr(const Anope::string &str, uint32 &ip, uint32 &mask, Anope::stri
for (int i = 0; i < 4; ++i)
{
octets[i] = convertTo<int>(s, s, false);
octets[i] = s.empty() || !s.is_number_only() ? -1 : convertTo<int>(s, s, false);
/* Bail out if the octet is invalid or wrongly terminated */
if (octets[i] < 0 || octets[i] > 255 || (i < 3 && s[0] != '.'))
return false;