*
* $Id$
*/
+#include "config.h"
+
#include "channel.h"
#include "client.h"
#include "hash.h"
#include "ircd_defs.h"
#include "ircd_features.h"
#include "ircd_log.h"
+#include "ircd_policy.h"
#include "ircd_reply.h"
#include "ircd_snprintf.h"
#include "ircd_string.h"
#include "s_misc.h"
#include "s_user.h"
#include "send.h"
-#include "sprintf_irc.h"
#include "struct.h"
#include "support.h"
#include "sys.h"
const char *host)
{
static char namebuf[NICKLEN + USERLEN + HOSTLEN + 3];
- sprintf_irc(namebuf, "%s!%s@%s", nick, name, host);
+ ircd_snprintf(0, namebuf, sizeof(namebuf), "%s!%s@%s", nick, name, host);
return namebuf;
}
static char *make_nick_user_ip(char *nick, char *name, struct in_addr ip)
{
static char ipbuf[NICKLEN + USERLEN + 16 + 3];
- sprintf_irc(ipbuf, "%s!%s@%s", nick, name, ircd_ntoa((const char*) &ip));
+ ircd_snprintf(0, ipbuf, sizeof(ipbuf), "%s!%s@%s", nick, name,
+ ircd_ntoa((const char*) &ip));
return ipbuf;
}
len -= strlen(tmp->value.ban.banstr);
}
*banp = tmp->next;
-#if 0
- /* Silently remove overlapping bans */
- MyFree(tmp->value.ban.banstr);
- MyFree(tmp->value.ban.who);
- free_link(tmp);
- tmp = 0;
-#else
/* These will be sent to the user later as -b */
tmp->next = removed_bans_list;
removed_bans_list = tmp;
removed_bans = 1;
-#endif
}
else if (!(tmp->flags & CHFL_BURST_BAN_WIPEOUT))
{
assert(0 != ban->value.ban.banstr);
strcpy(ban->value.ban.banstr, banid);
- ban->value.ban.who = (char*) MyMalloc(strlen(cli_name(cptr)) + 1);
+#ifdef HEAD_IN_SAND_BANWHO
+ if (IsServer(cptr))
+ DupString(ban->value.ban.who, cli_name(&me));
+ else
+#endif
+ DupString(ban->value.ban.who, cli_name(cptr));
assert(0 != ban->value.ban.who);
- strcpy(ban->value.ban.who, cli_name(cptr));
ban->value.ban.when = TStime();
ban->flags = CHFL_BAN; /* This bit is never used I think... */
*mbuf++ = 'n';
if (chptr->mode.limit) {
*mbuf++ = 'l';
- sprintf_irc(pbuf, "%d", chptr->mode.limit);
+ ircd_snprintf(0, pbuf, sizeof(pbuf), "%d", chptr->mode.limit);
}
if (*chptr->mode.key) {
*mbuf++ = 'k';
+ if (chptr->mode.limit)
+ strcat(pbuf, " ");
if (is_chan_op(cptr, chptr) || IsServer(cptr)) {
- if (chptr->mode.limit)
- strcat(pbuf, " ");
strcat(pbuf, chptr->mode.key);
- }
+ } else
+ strcat(pbuf, "*");
}
*mbuf = '\0';
}
(cli_listing(cptr))->chptr = chptr;
chptr->mode.mode |= MODE_LISTED;
}
+
+ update_write(cptr);
}
/*
/* Ok, if we were given the OPMODE flag, hide the source if its a user */
if (mbuf->mb_dest & MODEBUF_DEST_OPMODE && !IsServer(mbuf->mb_source))
- app_source = (cli_user(mbuf->mb_source))->server;
+ app_source = &me;
else
app_source = mbuf->mb_source;
}
} else if (MB_TYPE(mbuf, i) & MODE_LIMIT) {
/* if it's a limit, we also format the number */
- sprintf_irc(limitbuf, "%d", MB_UINT(mbuf, i));
+ ircd_snprintf(0, limitbuf, sizeof(limitbuf), "%d", MB_UINT(mbuf, i));
tmp = strlen(limitbuf);
/* send the messages off to their destination */
if (mbuf->mb_dest & MODEBUF_DEST_HACK2) {
sendto_opmask_butone(0, SNO_HACK2, "HACK(2): %s MODE %s %s%s%s%s%s%s "
- "[%Tu]", cli_name(app_source),
+ "[%Tu]",
+#ifdef HEAD_IN_SAND_SNOTICES
+ cli_name(mbuf->mb_source),
+#else
+ cli_name(app_source),
+#endif
mbuf->mb_channel->chname,
rembuf_i ? "-" : "", rembuf, addbuf_i ? "+" : "",
addbuf, remstr, addstr,
mbuf->mb_channel->creationtime);
sendcmdto_serv_butone(&me, CMD_DESYNCH, mbuf->mb_connect,
":HACK: %s MODE %s %s%s%s%s%s%s [%Tu]",
- cli_name(app_source), mbuf->mb_channel->chname,
+#ifdef HEAD_IN_SAND_SNOTICES
+ cli_name(mbuf->mb_source),
+#else
+ cli_name(app_source),
+#endif
+ mbuf->mb_channel->chname,
rembuf_i ? "-" : "", rembuf,
addbuf_i ? "+" : "", addbuf, remstr, addstr,
mbuf->mb_channel->creationtime);
if (mbuf->mb_dest & MODEBUF_DEST_HACK3)
sendto_opmask_butone(0, SNO_HACK3, "BOUNCE or HACK(3): %s MODE %s "
- "%s%s%s%s%s%s [%Tu]", cli_name(app_source),
+ "%s%s%s%s%s%s [%Tu]",
+#ifdef HEAD_IN_SAND_SNOTICES
+ cli_name(mbuf->mb_source),
+#else
+ cli_name(app_source),
+#endif
mbuf->mb_channel->chname, rembuf_i ? "-" : "",
rembuf, addbuf_i ? "+" : "", addbuf, remstr, addstr,
mbuf->mb_channel->creationtime);
if (mbuf->mb_dest & MODEBUF_DEST_HACK4)
sendto_opmask_butone(0, SNO_HACK4, "HACK(4): %s MODE %s %s%s%s%s%s%s "
- "[%Tu]", cli_name(app_source),
+ "[%Tu]",
+#ifdef HEAD_IN_SAND_SNOTICES
+ cli_name(mbuf->mb_source),
+#else
+ cli_name(app_source),
+#endif
mbuf->mb_channel->chname,
rembuf_i ? "-" : "", rembuf, addbuf_i ? "+" : "",
addbuf, remstr, addstr,
} else if (state->dir == MODE_ADD) {
/* if the ban already exists, don't worry about it */
if (!ircd_strcmp(ban->value.ban.banstr, t_str)) {
+ newban->flags &= ~MODE_ADD; /* don't add ban at all */
+ MyFree(newban->value.ban.banstr); /* stopper a leak */
+ state->numbans--; /* deallocate last ban */
if (state->done & DONE_BANCLEAN) /* If we're cleaning, finish */
break;
- continue;
} else if (!mmatch(ban->value.ban.banstr, t_str)) {
if (!(ban->flags & MODE_DEL))
newban->flags |= CHFL_BAN_OVERLAPPED; /* our ban overlaps */
} else if (!mmatch(t_str, ban->value.ban.banstr))
ban->flags |= MODE_DEL; /* mark ban for deletion: overlapping */
- if (!ban->next) {
+ if (!ban->next && (newban->flags & MODE_ADD)) {
ban->next = newban; /* add our ban with its flags */
break; /* get out of loop */
}