Some cleanups in quit message handling. Fixed a bug where a quit from a user
that isn't in a channel with the client (god knows how *that* happens, but someone reported the bug...) could crash the client, because a NULL pointer is passed to logmsg(). The bug didn't show under glibc because it handles the NULL pointer OK. git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@58 13b04d17-f746-0410-82c6-800466cd88b0
This commit is contained in:
@@ -1,5 +1,8 @@
|
|||||||
[Changes 1.2c01 ]
|
[Changes 1.2c01 ]
|
||||||
|
|
||||||
|
* Some cleanups in quit message handling, fixed a bug where a quit from an
|
||||||
|
unexpected source could crash the client. (caf)
|
||||||
|
|
||||||
* Cleaned up the handling of channel mode changes a little, including fixing
|
* Cleaned up the handling of channel mode changes a little, including fixing
|
||||||
buggy handling of certain key and limit mode changes. (caf)
|
buggy handling of certain key and limit mode changes. (caf)
|
||||||
|
|
||||||
|
|||||||
@@ -67,8 +67,8 @@ extern LastMsg last_sent_ctcp[2];
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void update_stats (int, char *, NickList *, ChannelList *, int);
|
void update_stats (int, NickList *, ChannelList *, int);
|
||||||
int check_split (char *, char *, char *);
|
int check_split (char *, char *);
|
||||||
void BX_userage (char *, char *);
|
void BX_userage (char *, char *);
|
||||||
void stats_k_grep_end (void);
|
void stats_k_grep_end (void);
|
||||||
char *stripansicodes (const unsigned char *);
|
char *stripansicodes (const unsigned char *);
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ void list_channels (void);
|
|||||||
void reconnect_all_channels (int);
|
void reconnect_all_channels (int);
|
||||||
void switch_channels (char, char *);
|
void switch_channels (char, char *);
|
||||||
char *what_channel (char *, int);
|
char *what_channel (char *, int);
|
||||||
char *walk_channels (char *, int, int);
|
ChannelList *walk_channels (char *, int, int);
|
||||||
char *real_channel (void);
|
char *real_channel (void);
|
||||||
void BX_rename_nick (char *, char *, int);
|
void BX_rename_nick (char *, char *, int);
|
||||||
void update_channel_mode (char *, char *, int, char *, ChannelList *);
|
void update_channel_mode (char *, char *, int, char *, ChannelList *);
|
||||||
|
|||||||
@@ -4008,7 +4008,7 @@ struct target_type target[4] =
|
|||||||
if ((chan = lookup_channel(channel, from_server, 0)))
|
if ((chan = lookup_channel(channel, from_server, 0)))
|
||||||
{
|
{
|
||||||
nick = find_nicklist_in_channellist(get_server_nickname(from_server), chan, 0);
|
nick = find_nicklist_in_channellist(get_server_nickname(from_server), chan, 0);
|
||||||
update_stats((i == 1) ?PUBLIC_LIST : NOTICE_LIST, channel, nick, chan, 0);
|
update_stats((i == 1) ?PUBLIC_LIST : NOTICE_LIST, nick, chan, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -702,7 +702,7 @@ put_it("%s", convert_output_format(" %CIdle user check is %K[%R$0-%K]", "%s", n
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void update_stats(int what, char *channel, NickList *nick, ChannelList *chan, int splitter)
|
void update_stats(int what, NickList *nick, ChannelList *chan, int splitter)
|
||||||
{
|
{
|
||||||
time_t this_time = now;
|
time_t this_time = now;
|
||||||
int t = 0;
|
int t = 0;
|
||||||
@@ -1073,7 +1073,7 @@ unsigned char *newline;
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int check_split(char *nick, char *reason, char *chan)
|
int check_split(char *nick, char *reason)
|
||||||
{
|
{
|
||||||
char *bogus = get_string_var(FAKE_SPLIT_PATS_VAR);
|
char *bogus = get_string_var(FAKE_SPLIT_PATS_VAR);
|
||||||
char *Reason;
|
char *Reason;
|
||||||
|
|||||||
@@ -398,7 +398,7 @@ ChannelList *BX_add_to_channel(char *channel, char *nick, int server, int oper,
|
|||||||
if (server1)
|
if (server1)
|
||||||
malloc_strcpy(&new->server, server1);
|
malloc_strcpy(&new->server, server1);
|
||||||
add_nicklist_to_channellist(new, chan);
|
add_nicklist_to_channellist(new, chan);
|
||||||
update_stats(JOINLIST, chan->channel, new, chan, serv_split);
|
update_stats(JOINLIST, new, chan, serv_split);
|
||||||
}
|
}
|
||||||
malloc_strcpy(&new->host, userhost);
|
malloc_strcpy(&new->host, userhost);
|
||||||
if (ischop > 0)
|
if (ischop > 0)
|
||||||
@@ -961,7 +961,7 @@ static void apply_channel_modes(char *from, char *mode_str,
|
|||||||
ThisNick->flags &= ~NICK_HALFOP;
|
ThisNick->flags &= ~NICK_HALFOP;
|
||||||
}
|
}
|
||||||
ThisNick = find_nicklist_in_channellist(from, channel, 0);
|
ThisNick = find_nicklist_in_channellist(from, channel, 0);
|
||||||
update_stats(add ? MODEHOPLIST: MODEDEHOPLIST, channel->channel, ThisNick, channel, splitter);
|
update_stats(add ? MODEHOPLIST: MODEDEHOPLIST, ThisNick, channel, splitter);
|
||||||
break;
|
break;
|
||||||
case 'o':
|
case 'o':
|
||||||
{
|
{
|
||||||
@@ -975,7 +975,7 @@ static void apply_channel_modes(char *from, char *mode_str,
|
|||||||
do_hook(CHANOP_LIST, "%s", channel->channel);
|
do_hook(CHANOP_LIST, "%s", channel->channel);
|
||||||
}
|
}
|
||||||
ThisNick = find_nicklist_in_channellist(from, channel, 0);
|
ThisNick = find_nicklist_in_channellist(from, channel, 0);
|
||||||
update_stats(add ? MODEOPLIST: MODEDEOPLIST, channel->channel, ThisNick, channel, splitter);
|
update_stats(add ? MODEOPLIST: MODEDEOPLIST, ThisNick, channel, splitter);
|
||||||
if ((ThisNick = find_nicklist_in_channellist(person, channel, 0)))
|
if ((ThisNick = find_nicklist_in_channellist(person, channel, 0)))
|
||||||
{
|
{
|
||||||
if (add)
|
if (add)
|
||||||
@@ -1055,7 +1055,7 @@ static void apply_channel_modes(char *from, char *mode_str,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
ThisNick = find_nicklist_in_channellist(from, channel, 0);
|
ThisNick = find_nicklist_in_channellist(from, channel, 0);
|
||||||
update_stats(add?MODEBANLIST:MODEUNBANLIST, channel->channel, ThisNick, channel, splitter);
|
update_stats(add?MODEBANLIST:MODEUNBANLIST, ThisNick, channel, splitter);
|
||||||
if (add)
|
if (add)
|
||||||
{
|
{
|
||||||
ThisNick = find_nicklist_in_channellist(person, channel, 0);
|
ThisNick = find_nicklist_in_channellist(person, channel, 0);
|
||||||
@@ -1089,7 +1089,7 @@ static void apply_channel_modes(char *from, char *mode_str,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
ThisNick = find_nicklist_in_channellist(from, channel, 0);
|
ThisNick = find_nicklist_in_channellist(from, channel, 0);
|
||||||
update_stats(add?MODEEBANLIST:MODEUNEBANLIST, channel->channel, ThisNick, channel, splitter);
|
update_stats(add?MODEEBANLIST:MODEUNEBANLIST, ThisNick, channel, splitter);
|
||||||
if (add)
|
if (add)
|
||||||
{
|
{
|
||||||
ThisNick = find_nicklist_in_channellist(person, channel, 0);
|
ThisNick = find_nicklist_in_channellist(person, channel, 0);
|
||||||
@@ -1687,20 +1687,19 @@ char *what_channel(char *nick, int server)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *walk_channels(char *nick, int init, int server)
|
ChannelList *walk_channels(char *nick, int init, int server)
|
||||||
{
|
{
|
||||||
static ChannelList *tmp = NULL;
|
static ChannelList *tmp = NULL;
|
||||||
|
|
||||||
|
|
||||||
if (init)
|
if (init)
|
||||||
tmp = get_server_channels(server);
|
tmp = get_server_channels(server);
|
||||||
else if (tmp)
|
else if (tmp)
|
||||||
tmp = tmp->next;
|
tmp = tmp->next;
|
||||||
|
|
||||||
for (;tmp ; tmp = tmp->next)
|
for (;tmp ; tmp = tmp->next)
|
||||||
{
|
{
|
||||||
if ((tmp->server == from_server) &&
|
if (find_nicklist_in_channellist(nick, tmp, 0))
|
||||||
(find_nicklist_in_channellist(nick, tmp, 0)))
|
return tmp;
|
||||||
return (tmp->channel);
|
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -713,7 +713,7 @@ void parse_notice(char *from, char **Args)
|
|||||||
type = NOTICE_LIST;
|
type = NOTICE_LIST;
|
||||||
}
|
}
|
||||||
|
|
||||||
update_stats(NOTICELIST, to, nick, tmpc, 0);
|
update_stats(NOTICELIST, nick, tmpc, 0);
|
||||||
|
|
||||||
set_display_target(target, LOG_NOTICE);
|
set_display_target(target, LOG_NOTICE);
|
||||||
doing_notice = 1;
|
doing_notice = 1;
|
||||||
|
|||||||
@@ -354,7 +354,7 @@ ChannelList *tmp;
|
|||||||
{ fake(); return; }
|
{ fake(); return; }
|
||||||
if ((tmp = lookup_channel(ArgList[0], from_server, CHAN_NOUNLINK)))
|
if ((tmp = lookup_channel(ArgList[0], from_server, CHAN_NOUNLINK)))
|
||||||
{
|
{
|
||||||
update_stats(TOPICLIST, tmp->channel, find_nicklist_in_channellist(from, tmp, 0), tmp, 0);
|
update_stats(TOPICLIST, find_nicklist_in_channellist(from, tmp, 0), tmp, 0);
|
||||||
if (tmp->topic_lock)
|
if (tmp->topic_lock)
|
||||||
{
|
{
|
||||||
if (my_stricmp(from, get_server_nickname(from_server)))
|
if (my_stricmp(from, get_server_nickname(from_server)))
|
||||||
@@ -561,7 +561,7 @@ static void p_privmsg(char *from, char **Args)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
update_stats(PUBLICLIST, to, tmpnick, channel, 0);
|
update_stats(PUBLICLIST, tmpnick, channel, 0);
|
||||||
|
|
||||||
level = set_lastlog_msg_level(log_type);
|
level = set_lastlog_msg_level(log_type);
|
||||||
com_do_log = 0;
|
com_do_log = 0;
|
||||||
@@ -708,67 +708,77 @@ static void p_privmsg(char *from, char **Args)
|
|||||||
static void p_quit(char *from, char **ArgList)
|
static void p_quit(char *from, char **ArgList)
|
||||||
{
|
{
|
||||||
int one_prints = 0;
|
int one_prints = 0;
|
||||||
char *chan = NULL;
|
char *reason;
|
||||||
char *Reason;
|
char *chanlist = NULL;
|
||||||
char *tmp = NULL;
|
ChannelList *chan;
|
||||||
ChannelList *tmpc;
|
|
||||||
int netsplit = 0;
|
int netsplit = 0;
|
||||||
int ignore;
|
int ignore;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
PasteArgs(ArgList, 0);
|
PasteArgs(ArgList, 0);
|
||||||
if (ArgList[0])
|
if (ArgList[0])
|
||||||
{
|
{
|
||||||
Reason = ArgList[0];
|
reason = ArgList[0];
|
||||||
netsplit = check_split(from, Reason, chan);
|
netsplit = check_split(from, reason);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
Reason = "?";
|
reason = "?";
|
||||||
|
|
||||||
for (chan = walk_channels(from, 1, from_server); chan; chan = walk_channels(from, 0, -1))
|
for (chan = walk_channels(from, 1, from_server); chan;
|
||||||
|
chan = walk_channels(from, 0, -1))
|
||||||
{
|
{
|
||||||
ignore = check_ignore(from, FromUserHost, chan, (netsplit?IGNORE_SPLITS:IGNORE_QUITS), NULL);
|
update_stats(CHANNELSIGNOFFLIST,
|
||||||
if ((tmpc = lookup_channel(chan, from_server, CHAN_NOUNLINK)))
|
find_nicklist_in_channellist(from, chan, 0), chan, netsplit);
|
||||||
{
|
|
||||||
update_stats(CHANNELSIGNOFFLIST, chan, find_nicklist_in_channellist(from, tmpc, 0), tmpc, netsplit);
|
|
||||||
#ifdef WANT_TCL
|
#ifdef WANT_TCL
|
||||||
if (netsplit)
|
if (netsplit)
|
||||||
check_tcl_split(from, FromUserHost, from, chan);
|
check_tcl_split(from, FromUserHost, from, chan->channel);
|
||||||
else
|
else
|
||||||
check_tcl_sign(from, FromUserHost, from, chan, Reason);
|
check_tcl_sign(from, FromUserHost, from, chan->channel, reason);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!netsplit)
|
if (!netsplit)
|
||||||
{
|
{
|
||||||
do_logchannel(LOG_PART, tmpc, "%s %s %s %s", from, FromUserHost, chan, Reason?Reason:empty_string);
|
do_logchannel(LOG_PART, chan, "%s %s %s %s", from, FromUserHost,
|
||||||
check_channel_limit(tmpc);
|
chan->channel, reason);
|
||||||
|
check_channel_limit(chan);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (tmp)
|
if (chanlist)
|
||||||
m_3cat(&tmp, ",", chan);
|
m_3cat(&chanlist, ",", chan->channel);
|
||||||
else
|
else
|
||||||
malloc_strcpy(&tmp, chan);
|
malloc_strcpy(&chanlist, chan->channel);
|
||||||
|
|
||||||
|
ignore = check_ignore(from, FromUserHost, chan->channel,
|
||||||
|
(netsplit?IGNORE_SPLITS:IGNORE_QUITS), NULL);
|
||||||
if (ignore != IGNORED)
|
if (ignore != IGNORED)
|
||||||
{
|
{
|
||||||
set_display_target(chan, LOG_CRAP);
|
set_display_target(chan->channel, LOG_CRAP);
|
||||||
if (do_hook(CHANNEL_SIGNOFF_LIST, "%s %s %s", chan, from, Reason))
|
if (do_hook(CHANNEL_SIGNOFF_LIST, "%s %s %s", chan->channel,
|
||||||
|
from, reason))
|
||||||
one_prints = 1;
|
one_prints = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (one_prints)
|
if (one_prints)
|
||||||
{
|
{
|
||||||
chan = what_channel(from, from_server);
|
char *channel = what_channel(from, from_server);
|
||||||
ignore = check_ignore(from, FromUserHost, chan, (netsplit?IGNORE_SPLITS:IGNORE_QUITS), NULL);
|
ignore = check_ignore(from, FromUserHost, channel,
|
||||||
set_display_target(chan, LOG_CRAP);
|
(netsplit?IGNORE_SPLITS:IGNORE_QUITS), NULL);
|
||||||
if ((ignore != IGNORED) && do_hook(SIGNOFF_LIST, "%s %s", from, Reason) && !netsplit)
|
set_display_target(channel, LOG_CRAP);
|
||||||
put_it("%s",convert_output_format(fget_string_var(FORMAT_CHANNEL_SIGNOFF_FSET), "%s %s %s %s %s",update_clock(GET_TIME), from, FromUserHost, tmp, Reason));
|
if ((ignore != IGNORED) && do_hook(SIGNOFF_LIST, "%s %s", from, reason)
|
||||||
|
&& !netsplit)
|
||||||
|
put_it("%s", convert_output_format(
|
||||||
|
fget_string_var(FORMAT_CHANNEL_SIGNOFF_FSET),
|
||||||
|
"%s %s %s %s %s", update_clock(GET_TIME), from, FromUserHost,
|
||||||
|
chanlist, reason));
|
||||||
}
|
}
|
||||||
logmsg(LOG_PART, from, 0, "%s %s", tmp, Reason?Reason:empty_string);
|
|
||||||
|
logmsg(LOG_PART, from, 0, "%s %s", chanlist ? chanlist : "<NONE>", reason);
|
||||||
check_orig_nick(from);
|
check_orig_nick(from);
|
||||||
notify_mark(from, FromUserHost, 0, 0);
|
notify_mark(from, FromUserHost, 0, 0);
|
||||||
remove_from_channel(NULL, from, from_server, netsplit, Reason);
|
remove_from_channel(NULL, from, from_server, netsplit, reason);
|
||||||
update_all_status(current_window, NULL, 0);
|
update_all_status(current_window, NULL, 0);
|
||||||
new_free(&tmp);
|
new_free(&chanlist);
|
||||||
reset_display_target();
|
reset_display_target();
|
||||||
#ifdef GUI
|
#ifdef GUI
|
||||||
gui_update_nicklist(NULL);
|
gui_update_nicklist(NULL);
|
||||||
@@ -1583,7 +1593,7 @@ static void p_kick(char *from, char **ArgList)
|
|||||||
set_display_target(channel, LOG_CRAP);
|
set_display_target(channel, LOG_CRAP);
|
||||||
if (channel && who && chan)
|
if (channel && who && chan)
|
||||||
{
|
{
|
||||||
update_stats(KICKLIST, channel, tmpnick, chan, 0);
|
update_stats(KICKLIST, tmpnick, chan, 0);
|
||||||
#ifdef WANT_TCL
|
#ifdef WANT_TCL
|
||||||
check_tcl_kick(from, FromUserHost, from, channel, who, comment);
|
check_tcl_kick(from, FromUserHost, from, channel, who, comment);
|
||||||
#endif
|
#endif
|
||||||
@@ -1692,7 +1702,7 @@ static void p_part(char *from, char **ArgList)
|
|||||||
set_display_target(channel, LOG_CRAP);
|
set_display_target(channel, LOG_CRAP);
|
||||||
|
|
||||||
if ((tmpc = lookup_channel(channel, from_server, CHAN_NOUNLINK)))
|
if ((tmpc = lookup_channel(channel, from_server, CHAN_NOUNLINK)))
|
||||||
update_stats(LEAVELIST, channel, find_nicklist_in_channellist(from, tmpc, 0), tmpc, 0);
|
update_stats(LEAVELIST, find_nicklist_in_channellist(from, tmpc, 0), tmpc, 0);
|
||||||
|
|
||||||
if ((check_ignore(from, FromUserHost, channel, IGNORE_PARTS, NULL) != IGNORED) &&
|
if ((check_ignore(from, FromUserHost, channel, IGNORE_PARTS, NULL) != IGNORED) &&
|
||||||
do_hook(LEAVE_LIST, "%s %s %s %s", from, channel, FromUserHost, ArgList[1]?ArgList[1]:empty_string))
|
do_hook(LEAVE_LIST, "%s %s %s %s", from, channel, FromUserHost, ArgList[1]?ArgList[1]:empty_string))
|
||||||
|
|||||||
Reference in New Issue
Block a user