From 0163b62500178ce1b2e2b5ee1f4ab3849b153368 Mon Sep 17 00:00:00 2001 From: pk910 Date: Sat, 2 Jul 2011 15:22:42 +0200 Subject: [PATCH] multiple bugfixes for last 2 commits --- ircd/channel.c | 40 ++++++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/ircd/channel.c b/ircd/channel.c index a467750..ee7365d 100644 --- a/ircd/channel.c +++ b/ircd/channel.c @@ -2732,7 +2732,9 @@ mode_parse_noflood(struct ParseState *state, ulong64 *flag_p) struct Membership *member; for(member = state->chptr->members; member; member = member->next_member) { struct MemberFlood *floodnode; - for(floodnode = member->flood; floodnode; floodnode = floodnode->next_memberflood) {} //simply walk to the end + for(floodnode = member->flood;; floodnode = floodnode->next_memberflood) { + if(floodnode->next_memberflood == NULL) break; + } //simply walk to the end floodnode->next_memberflood = free_MemberFlood; free_MemberFlood = floodnode; member->flood = NULL; @@ -4324,49 +4326,50 @@ int ext_amsg_block(struct Client *cptr, struct Channel *chptr, const char *msg) strcpy(stripped_message, msg); char p = stripped_message[0]; int p_pos = 0; - int is_visible = 1, is_ccode = 0; j = 0; + int is_visible = 1, is_ccode = 0, i = 0, j = 0; char codes[5]; - for(int i = 0; p != '\n'; p = stripped_message[++i]) { - if(c == 3) { + for(i = 0; p != '\n'; p = stripped_message[++i]) { + if(p == 3) { j = 0; is_ccode = 1; } else if(is_ccode) { - if((c >= 48 && c <= 57) || c == 44) { - if(ccode == 1) { - if(c == 44) { - ccode = 2; + if((p >= 48 && p <= 57) || p == 44) { + if(is_ccode == 1) { + if(p == 44) { + is_ccode = 2; codes[j++] = 0; j = 0; } else - codes[j++] = c; + codes[j++] = p; } else { //compare - if(c != codes[j++]) { - ccode = 3; + if(p != codes[j++]) { + is_ccode = 3; } } } else { //END of color code... is_ccode = 0; - if(ccode != 1 && codes[j] != 0) ccode = 3; - if(ccode == 1) { + if(is_ccode != 1 && codes[j] != 0) is_ccode = 3; + if(is_ccode == 1) { codes[j] = 0; - for(int k = 0; k < j-1; k++) { + int k; + for(k = 0; k < j-1; k++) { if(codes[k] != 48) { is_visible = 1; goto normalchar; } } is_visible = 0; - } else if(ccode == 2) { + } else if(is_ccode == 2) { is_visible = 0; - } else if(ccode == 3) { + } else if(is_ccode == 3) { is_visible = 1; goto normalchar; } } } else { - :normalchar + normalchar: if(is_visible) stripped_message[p_pos++] = p; } @@ -4406,13 +4409,14 @@ int ext_amsg_block(struct Client *cptr, struct Channel *chptr, const char *msg) * --pk910 2011/7/1 */ int ext_noflood_block(struct Client *cptr, struct Channel *chptr) { - if(!chptr->mode.noflood) return 0; + if(chptr->mode.noflood == NULL || !chptr->mode.noflood) return 0; struct Membership *member = find_member_link(chptr, cptr); if(!member) return 0; //TODO: we've no check for -n channels implemented, yet //check if this user is really affected by +f unsigned int flags = (chptr->mode.noflood_value & 0x00000007); //0000 0000 0000 0000 0000 0000 0000 0111 = 0x00000007 >> 0 unsigned int count = (chptr->mode.noflood_value & 0x00001ff8) >> 3; //0000 0000 0000 0000 0001 1111 1111 1000 = 0x00001ff8 >> 3 int time = (chptr->mode.noflood_value & 0x07ffe000) >> 13; //0000 0111 1111 1111 1110 0000 0000 0000 = 0x07ffe000 >> 13 + if(count == 0 || time == 0) return 0; if(!(flags & FLFL_NOFLOOD) && HasPriv(cptr, PRIV_FLOOD)) return 0; if(!(flags & FLFL_CHANOP) && (member->status & CHFL_CHANOP)) -- 2.20.1