From a4346b186222fe306fd4d9681b3dce220e306570 Mon Sep 17 00:00:00 2001 From: Michael Poole Date: Fri, 23 Sep 2005 01:15:51 +0000 Subject: [PATCH] Fix bug #1298149 and a similar desynch for channel keys. git-svn-id: file:///home/klmitch/undernet-ircu/undernet-ircu-svn/ircu2/trunk@1494 c9e4aea6-c8fd-4c43-8297-357d70d61c8c --- ChangeLog | 7 +++++++ ircd/channel.c | 22 +++++++++++++++------- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index a06a9df..549e60b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2005-09-22 Michael Poole + + * ircd/channel.c (mode_parse_key): Only accept the new key when + the current one is empty or "greater" than the new one. + (mode_parse_upass): Likewise, for upass. + (mode_parse_apass): Likewise, for apass. + 2005-09-22 Michael Poole * ircd/gline.c (gline_checkmask): Add missing digit in mask length diff --git a/ircd/channel.c b/ircd/channel.c index d4b3835..01ec91a 100644 --- a/ircd/channel.c +++ b/ircd/channel.c @@ -2326,10 +2326,11 @@ mode_parse_key(struct ParseState *state, int *flag_p) modebuf_mode_string(state->mbuf, state->dir | flag_p[0], t_str, 0); if (state->flags & MODE_PARSE_SET) { - if (state->dir == MODE_ADD) /* set the new key */ - ircd_strncpy(state->chptr->mode.key, t_str, KEYLEN); - else /* remove the old key */ + if (state->dir == MODE_DEL) /* remove the old key */ *state->chptr->mode.key = '\0'; + else if (!state->chptr->mode.key[0] + || ircd_strcmp(t_str, state->chptr->mode.key) < 0) + ircd_strncpy(state->chptr->mode.key, t_str, KEYLEN); } } @@ -2430,10 +2431,11 @@ mode_parse_upass(struct ParseState *state, int *flag_p) modebuf_mode_string(state->mbuf, state->dir | flag_p[0], t_str, 0); if (state->flags & MODE_PARSE_SET) { - if (state->dir == MODE_ADD) /* set the new upass */ - ircd_strncpy(state->chptr->mode.upass, t_str, KEYLEN); - else /* remove the old upass */ + if (state->dir == MODE_DEL) /* remove the old upass */ *state->chptr->mode.upass = '\0'; + else if (state->chptr->mode.upass[0] == '\0' + || ircd_strcmp(t_str, state->chptr->mode.upass) < 0) + ircd_strncpy(state->chptr->mode.upass, t_str, KEYLEN); } } @@ -2538,8 +2540,14 @@ mode_parse_apass(struct ParseState *state, int *flag_p) if (state->flags & MODE_PARSE_SET) { if (state->dir == MODE_ADD) { /* set the new apass */ + /* Only accept the new apass if there is no current apass + * (e.g. when a user sets it) or the new one is "less" than the + * old (for resolving conflicts during burst). + */ + if (state->chptr->mode.apass[0] == '\0' + || ircd_strcmp(t_str, state->chptr->mode.apass) < 0) + ircd_strncpy(state->chptr->mode.apass, t_str, KEYLEN); /* Make it VERY clear to the user that this is a one-time password */ - ircd_strncpy(state->chptr->mode.apass, t_str, KEYLEN); if (MyUser(state->sptr)) { send_reply(state->sptr, RPL_APASSWARN_SET, state->chptr->mode.apass); send_reply(state->sptr, RPL_APASSWARN_SECRET, state->chptr->chname, -- 2.20.1