]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/cidr.cpp
Add support for blocking tag messages with the deaf mode.
[user/henk/code/inspircd.git] / src / cidr.cpp
index 250ad9c69b0d716dc6cee3b2758fec1bede6b6e7..f45c63b98d6d0461f43efd9a8c4c99f3f4dbf843 100644 (file)
@@ -1,9 +1,13 @@
 /*
  * InspIRCd -- Internet Relay Chat Daemon
  *
- *   Copyright (C) 2009 Daniel De Graaf <danieldg@inspircd.org>
- *   Copyright (C) 2008 Craig Edwards <craigedwards@brainbox.cc>
+ *   Copyright (C) 2019 Sadie Powell <sadie@witchery.services>
+ *   Copyright (C) 2014-2015 Attila Molnar <attilamolnar@hush.com>
+ *   Copyright (C) 2012 Robby <robby@chatbelgie.be>
+ *   Copyright (C) 2009-2010 Daniel De Graaf <danieldg@inspircd.org>
+ *   Copyright (C) 2009 Uli Schlachter <psychon@inspircd.org>
  *   Copyright (C) 2008 Robin Burchell <robin+git@viroteck.net>
+ *   Copyright (C) 2008 Craig Edwards <brain@inspircd.org>
  *
  * This file is part of InspIRCd.  InspIRCd is free software: you can
  * redistribute it and/or modify it under the terms of the GNU General Public
@@ -33,7 +37,7 @@ bool irc::sockets::MatchCIDR(const std::string &address, const std::string &cidr
 
        /* The caller is trying to match ident@<mask>/bits.
         * Chop off the ident@ portion, use match() on it
-        * seperately.
+        * separately.
         */
        if (match_with_username)
        {
@@ -73,7 +77,11 @@ 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);