X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fcidr.cpp;h=b245a15527e7a25077f855ceae2df3c0be33e52c;hb=68211809ee3111bdc9609fbd46dc3c875fbb5ea6;hp=050a3549da281111ea4ada286058db1f09268032;hpb=a85188c02bbcb37c0aae5048173a43e052e4eb7d;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/cidr.cpp b/src/cidr.cpp index 050a3549d..b245a1552 100644 --- a/src/cidr.cpp +++ b/src/cidr.cpp @@ -65,8 +65,14 @@ bool irc::sockets::MatchCIDR(const std::string &address, const std::string &cidr cidr_copy.assign(cidr_mask); } - if (cidr_copy.find('/') == std::string::npos) + const std::string::size_type per_pos = cidr_copy.rfind('/'); + if ((per_pos == std::string::npos) || (per_pos == cidr_copy.length()-1) + || (cidr_copy.find_first_not_of("0123456789", per_pos+1) != std::string::npos) + || (cidr_copy.find_first_not_of("0123456789abcdefABCDEF.:") < per_pos)) + { + // The CIDR mask is invalid return false; + } irc::sockets::sockaddrs addr; irc::sockets::aptosa(address_copy, 0, addr);