From c07e8962e5967ccdb57cfb30eca3c97a02808a62 Mon Sep 17 00:00:00 2001 From: stskeeps Date: Wed, 26 Dec 2001 23:35:25 +0000 Subject: [PATCH] +- Small fix for #427583 mode bug --- Changes | 1 + src/channel.c | 33 ++++++++++++++++++++------------- 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/Changes b/Changes index 5e150b3ab..516f072d9 100644 --- a/Changes +++ b/Changes @@ -1037,3 +1037,4 @@ seen. gmtime warning still there - Fixed yet another Win32 editor bug affecting Windows 95/98/NT4, found by HA|Raptor - If host == null, don't set it (m_oper, was setting it to "eek.host.is.null.pointer") +- Small fix for #427583 mode bug diff --git a/src/channel.c b/src/channel.c index d12cb4e6b..dda75ea6d 100644 --- a/src/channel.c +++ b/src/channel.c @@ -84,7 +84,8 @@ static void set_mode PROTO((aChannel *, aClient *, int, char **, u_int *, char[MAXMODEPARAMS][MODEBUFLEN + 3], int)); static void make_mode_str PROTO((aChannel *, long, long, int, char[MAXMODEPARAMS][MODEBUFLEN + 3], char *, char *, char)); -static int do_mode_char PROTO((aChannel *, long, char, char *, u_int, aClient *, +static int do_mode_char PROTO((aChannel *, long, char, char *, + u_int, aClient *, u_int *, char[MAXMODEPARAMS][MODEBUFLEN + 3], char)); static void do_mode PROTO((aChannel *, aClient *, aClient *, int, char **, int, int)); @@ -1434,7 +1435,7 @@ void make_mode_str(aChannel *chptr, long oldm, long oldl, int pcount, aCtab *tab = &cFlagTab[0]; char *x = mode_buf; int what, cnt, z; - + char *m; what = 0; *tmpbuf = '\0'; @@ -1524,11 +1525,17 @@ void make_mode_str(aChannel *chptr, long oldm, long oldl, int pcount, } *x++ = *(pvar[cnt] + 1); tmpstr = &pvar[cnt][2]; - strncat(parabuf, tmpstr, MODEBUFLEN - 1); - parabuf[MODEBUFLEN - 1] = '\0'; - z = strlen(parabuf); - parabuf[z] = ' '; /* add a space */ - parabuf[z + 1] = '\0'; + z = MODEBUFLEN - 1 - strlen(parabuf); + m = parabuf; + while ((*m)) { m++; } + while ((*tmpstr) && ((m-parabuf) < z)) + { + *m = *tmpstr; + m++; + tmpstr++; + } + *m++ = ' '; + *m = '\0'; } if (bounce) chptr->mode.mode = oldm; @@ -1554,7 +1561,8 @@ void make_mode_str(aChannel *chptr, long oldm, long oldl, int pcount, * modified for Unreal by stskeeps.. */ -int do_mode_char(aChannel *chptr, long modetype, char modechar, char *param, u_int what, aClient *cptr, +int do_mode_char(aChannel *chptr, long modetype, char modechar, char *param, + u_int what, aClient *cptr, u_int *pcount, char pvar[MAXMODEPARAMS][MODEBUFLEN + 3], char bounce) { aCtab *tab = &cFlagTab[0]; @@ -1728,7 +1736,7 @@ int do_mode_char(aChannel *chptr, long modetype, char modechar, char *param, u_ default: xxx = "whatthefuckisthatmode?"; } - if (!param || *pcount >= MAXMODEPARAMS) + if (!param || *pcount >= MAXMODEPARAMS || ) { retval = 0; break; @@ -1791,7 +1799,7 @@ int do_mode_char(aChannel *chptr, long modetype, char modechar, char *param, u_ member->flags |= modetype; else member->flags &= ~modetype; - if (tmp == member->flags && (bounce || !IsULine(cptr))) + if ((tmp == member->flags) && (bounce || !IsULine(cptr))) break; /* It's easier to undo the mode here instead of later * when you call make_mode_str for a bounce string. @@ -1813,7 +1821,7 @@ int do_mode_char(aChannel *chptr, long modetype, char modechar, char *param, u_ membership->flags = member->flags; (void)ircsprintf(pvar[*pcount], "%c%c%s", what == MODE_ADD ? '+' : '-', tc, who->name); - + (*paramsz) += strlen(who->name); (*pcount)++; break; case MODE_LIMIT: @@ -2220,8 +2228,7 @@ void set_mode(aChannel *chptr, aClient *cptr, int parc, char *parv[], u_int *pco me.name, cptr->name, *curchr); break; } - if (parv[paracount] && - strlen(parv[paracount]) >= MODEBUFLEN) + if (parv[paracount] && ((strlen(parv[paracount]) >= MODEBUFLEN))) parv[paracount][MODEBUFLEN - 1] = '\0'; paracount += do_mode_char(chptr, modetype, *curchr,