diff options
author | Naram Qashat <cyberbotx@cyberbotx.com> | 2010-08-03 07:26:43 -0400 |
---|---|---|
committer | Naram Qashat <cyberbotx@cyberbotx.com> | 2010-08-03 07:26:43 -0400 |
commit | a659f8281411dd285f3ade10e6042a7ce676de56 (patch) | |
tree | 4151ad2dc91108e3237237f7baab11a1559d3579 /src/misc.cpp | |
parent | 44387a2587f30a03d7a1ac5bc4d8b94ce91e31d6 (diff) |
Fix str_is_ip() and str_is_cidr(), bug found by Cronus.
Diffstat (limited to 'src/misc.cpp')
-rw-r--r-- | src/misc.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/misc.cpp b/src/misc.cpp index b8689f888..66123701e 100644 --- a/src/misc.cpp +++ b/src/misc.cpp @@ -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; |