From 77b933f6ecddbffd0db5a0c8fc444b4c8bfbfb11 Mon Sep 17 00:00:00 2001 From: brain Date: Sat, 29 Mar 2008 15:02:06 +0000 Subject: We also need to re-order to make sure the length comprison comes BEFORE the append: different items may have different lengths and otherwise we'd be comparing length of the LAST item not the current git-svn-id: http://svn.inspircd.org/repository/branches/1_1_stable@9203 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/channels.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'src/channels.cpp') diff --git a/src/channels.cpp b/src/channels.cpp index 7b268e3b3..16053aee5 100644 --- a/src/channels.cpp +++ b/src/channels.cpp @@ -880,16 +880,11 @@ void chanrec::UserList(userrec *user, CUList *ulist) if (i->first->Visibility && !i->first->Visibility->VisibleTo(user)) continue; - size_t ptrlen = snprintf(ptr, MAXBUF, "%s%s ", this->GetPrefixChar(i->first), i->second.c_str()); - - curlen += ptrlen; - ptr += ptrlen; - - numusers++; + size_t ptrlen = 0; /* Fix for bug #506 reported by Skip, often seen by w00t :p */ if (curlen > (480-i->second.length())) - { + { /* list overflowed into multiple numerics */ user->WriteServ(std::string(list)); @@ -901,6 +896,13 @@ void chanrec::UserList(userrec *user, CUList *ulist) numusers = 0; } + ptrlen = snprintf(ptr, MAXBUF, "%s%s ", this->GetPrefixChar(i->first), i->second.c_str()); + + curlen += ptrlen; + ptr += ptrlen; + + numusers++; + /* OnUserList can change this - reset it back to normal */ i->second = i->first->nick; } -- cgit v1.3.1-10-gc9f91