From de32b9d4f1ce5452935401196a60799afc3882f2 Mon Sep 17 00:00:00 2001 From: Michael Poole Date: Fri, 6 Oct 2006 23:18:58 +0000 Subject: [PATCH] Fix sending P10 bursts with many bans. src/proto-p10.c (irc_burst): Only send modes and user list once. git-archimport-id: srvx@srvx.net--2006/srvx--devo--1.3--patch-57 --- ChangeLog | 13 +++++++++++++ src/proto-p10.c | 39 ++++++++++++++++++++++----------------- 2 files changed, 35 insertions(+), 17 deletions(-) diff --git a/ChangeLog b/ChangeLog index 102e794..8131210 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,19 @@ # arch-tag: automatic-ChangeLog--srvx@srvx.net--2006/srvx--devo--1.3 # +2006-10-06 23:18:58 GMT Michael Poole patch-57 + + Summary: + Fix sending P10 bursts with many bans. + Revision: + srvx--devo--1.3--patch-57 + + src/proto-p10.c (irc_burst): Only send modes and user list once. + + modified files: + ChangeLog src/proto-p10.c + + 2006-10-06 23:16:58 GMT Michael Poole patch-56 Summary: diff --git a/src/proto-p10.c b/src/proto-p10.c index eab4ac6..4d64e83 100644 --- a/src/proto-p10.c +++ b/src/proto-p10.c @@ -689,13 +689,14 @@ irc_burst(struct chanNode *chan) struct modeNode *mn; struct banNode *bn; long last_mode=-1; + unsigned int first_ban; unsigned int n; base_len = sprintf(burst_line, "%s " P10_BURST " %s " FMT_TIME_T " ", self->numeric, chan->name, chan->timestamp); len = irc_make_chanmode(chan, burst_line+base_len); pos = base_len + len; - if (len) + if (len > 0 && chan->members.used > 0) burst_line[pos++] = ' '; /* dump the users */ @@ -720,32 +721,36 @@ irc_burst(struct chanNode *chan) if ((n+1)members.used) burst_line[pos++] = ','; } + + /* dump the bans */ if (chan->banlist.used) { - /* dump the bans */ - if (pos+2+strlen(chan->banlist.list[0]->ban) > 505) { - burst_line[pos-1] = 0; - putsock("%s", burst_line); - pos = base_len; - } else { + first_ban = 1; + + if (chan->members.used > 0) burst_line[pos++] = ' '; - } - burst_line[pos++] = ':'; - burst_line[pos++] = '%'; - base_len = pos; - for (n=0; nbanlist.used; n++) { + for (n=0; nbanlist.used; ) { + if (first_ban && (pos < 500)) { + burst_line[pos++] = ':'; + burst_line[pos++] = '%'; + } bn = chan->banlist.list[n]; len = strlen(bn->ban); - if (pos+len+1 > 510) { - burst_line[pos-1] = 0; /* -1 to back up over the space or comma */ + if (pos + 2 + len < 505) { + memcpy(burst_line + pos, bn->ban, len); + pos += len; + burst_line[pos++] = ' '; + first_ban = 0; + n++; + } else { + burst_line[pos-1] = 0; putsock("%s", burst_line); pos = base_len; + first_ban = 1; } - memcpy(burst_line+pos, bn->ban, len); - pos += len; - burst_line[pos++] = ' '; } } + /* print the last line */ burst_line[pos] = 0; putsock("%s", burst_line); -- 2.20.1