From 4ee9021adbb10140c30d6027a97e4748cb2f5903 Mon Sep 17 00:00:00 2001 From: Adam Date: Fri, 1 Nov 2013 04:58:38 -0400 Subject: Compare access entries created with the levels access system by access level and not by privilege set, as two entries can have the same privset but different levels, but still represent two different levels of access. This prevented users from adding other users at a lower access level when that level had the same privset as them. Spotted by TSG. --- src/access.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/access.cpp b/src/access.cpp index 2533f4415..f4b97c21e 100644 --- a/src/access.cpp +++ b/src/access.cpp @@ -363,12 +363,11 @@ bool AccessGroup::HasPriv(const Anope::string &name) const const ChanAccess *AccessGroup::Highest() const { - const std::vector &privs = PrivilegeManager::GetPrivileges(); - for (unsigned i = privs.size(); i > 0; --i) - for (unsigned j = this->size(); j > 0; --j) - if (this->at(j - 1)->HasPriv(privs[i - 1].name)) - return this->at(j - 1); - return NULL; + ChanAccess *highest = NULL; + for (unsigned i = 0; i < this->size(); ++i) + if (highest == NULL || *this->at(i) > *highest) + highest = this->at(i); + return highest; } bool AccessGroup::operator>(const AccessGroup &other) const -- cgit