From a0defce6dc8a2d69d99fa05d33cdb6a6a5a4a4d9 Mon Sep 17 00:00:00 2001 From: brain Date: Fri, 2 Nov 2007 21:02:40 +0000 Subject: We cant return NULL if the first hit we get expires in MatchLine, there may be another *after* it which matches, meaning that user may escape retribution ;) (thanks for pointing that out, aquanight) git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@8471 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/xline.cpp | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/src/xline.cpp b/src/xline.cpp index ba1ed2249..c292cc170 100644 --- a/src/xline.cpp +++ b/src/xline.cpp @@ -218,19 +218,30 @@ XLine* XLineManager::MatchesLine(const std::string &type, User* user) const time_t current = ServerInstance->Time(); - for (LookupIter i = x->second.begin(); i != x->second.end(); i++) + LookupIter safei; + + for (LookupIter i = x->second.begin(); i != x->second.end(); ) { + safei = i; + safei++; + if (i->second->Matches(user)) { if (i->second->duration && current > i->second->expiry) { /* Expire the line, return nothing */ ExpireLine(x, i); - return NULL; + /* Continue, there may be another that matches + * (thanks aquanight) + */ + i = safei; + continue; } else return i->second; } + + i = safei; } return NULL; } @@ -244,19 +255,28 @@ XLine* XLineManager::MatchesLine(const std::string &type, const std::string &pat const time_t current = ServerInstance->Time(); - for (LookupIter i = x->second.begin(); i != x->second.end(); i++) + LookupIter safei; + + for (LookupIter i = x->second.begin(); i != x->second.end(); ) { + safei = i; + safei++; + if (i->second->Matches(pattern)) { if (i->second->duration && current > i->second->expiry) { /* Expire the line, return nothing */ ExpireLine(x, i); - return NULL; + /* See above */ + i = safei; + continue; } else return i->second; } + + i = safei; } return NULL; } -- cgit v1.2.3