summaryrefslogtreecommitdiff
path: root/src/cidr.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/cidr.cpp')
-rw-r--r--src/cidr.cpp14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/cidr.cpp b/src/cidr.cpp
index b245a1552..377611437 100644
--- a/src/cidr.cpp
+++ b/src/cidr.cpp
@@ -19,8 +19,6 @@
*/
-/* $Core */
-
#include "inspircd.h"
/* Match CIDR strings, e.g. 127.0.0.1 to 127.0.0.0/8 or 3ffe:1:5:6::8 to 3ffe:1::0/32
@@ -55,8 +53,8 @@ bool irc::sockets::MatchCIDR(const std::string &address, const std::string &cidr
}
else
{
- address_copy = address.substr(username_addr_pos + 1);
- cidr_copy = cidr_mask.substr(username_mask_pos + 1);
+ address_copy.assign(address, username_addr_pos + 1, std::string::npos);
+ cidr_copy.assign(cidr_mask, username_mask_pos + 1, std::string::npos);
}
}
else
@@ -75,12 +73,14 @@ bool irc::sockets::MatchCIDR(const std::string &address, const std::string &cidr
}
irc::sockets::sockaddrs addr;
- irc::sockets::aptosa(address_copy, 0, addr);
+ if (!irc::sockets::aptosa(address_copy, 0, addr))
+ {
+ // The address could not be parsed.
+ return false;
+ }
irc::sockets::cidr_mask mask(cidr_copy);
irc::sockets::cidr_mask mask2(addr, mask.length);
return mask == mask2;
}
-
-