]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/cidr.cpp
Convert the ISO 8859-2 nationalchars files to codepage configs.
[user/henk/code/inspircd.git] / src / cidr.cpp
index 8d199353db58d069a9e48ab628e5e6f21db756d7..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)
        {
@@ -53,8 +57,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
@@ -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);