[srvx-commits] CVS: services/src chanserv.c,1.374,1.375
Brought to you by:
entrope
From: Entrope <en...@us...> - 2003-08-05 18:13:11
|
Update of /cvsroot/srvx/services/src In directory sc8-pr-cvs1:/tmp/cvs-serv30251/src Modified Files: chanserv.c Log Message: send a global message every time a channel is unregistered do not allow merges of nodelete channels into other channels protect against possible read-after-free in cmd_deluser Index: chanserv.c =================================================================== RCS file: /cvsroot/srvx/services/src/chanserv.c,v retrieving revision 1.374 retrieving revision 1.375 diff -C2 -r1.374 -r1.375 *** chanserv.c 5 Aug 2003 01:31:16 -0000 1.374 --- chanserv.c 5 Aug 2003 18:13:08 -0000 1.375 *************** *** 151,154 **** --- 151,155 ---- #define CSMSG_MERGE_SUCCESS "Channel successfully merged into $b%s$b." #define CSMSG_MERGE_SELF "Merging cannot be performed if the source and target channels are the same." + #define CSMSG_MERGE_NODELETE "You may not merge a channel that is marked NoDelete." #define CSMSG_MERGE_SUSPENDED "Merging cannot be performed if the source or target channel is suspended." #define CSMSG_MERGE_NOTOWNER "You must be the owner of the target channel (or a helper) to merge into the channel." *************** *** 1288,1292 **** } ! static void unregister_channel(struct chanData *channel, const char *part_msg); void --- 1289,1293 ---- } ! static void unregister_channel(struct chanData *channel, const char *reason); void *************** *** 1312,1316 **** channel = user->channel; free(user); ! if(do_gc && !channel->users) unregister_channel(channel, "Channel lost all users."); } --- 1313,1320 ---- channel = user->channel; free(user); ! if(do_gc && !channel->users && !IsProtected(channel)) ! { ! unregister_channel(channel, "lost all users."); ! } } *************** *** 1422,1427 **** static void ! unregister_channel(struct chanData *channel, const char *part_msg) { /* After channel unregistration, the following must be cleaned up: --- 1426,1433 ---- static void ! unregister_channel(struct chanData *channel, const char *reason) { + char msgbuf[MAXLEN]; + /* After channel unregistration, the following must be cleaned up: *************** *** 1484,1488 **** if(channel->notes) dict_delete(channel->notes); ! if(!IsSuspended(channel)) DelChannelUser(chanserv, channel->channel, part_msg, 0); free(channel); --- 1490,1496 ---- if(channel->notes) dict_delete(channel->notes); ! sprintf(msgbuf, "%s %s", channel->channel->name, reason); ! if(!IsSuspended(channel)) DelChannelUser(chanserv, channel->channel, msgbuf, 0); ! global_message(MESSAGE_RECIPIENT_OPERS | MESSAGE_RECIPIENT_HELPERS, msgbuf); free(channel); *************** *** 1517,1521 **** /* Unregister the channel */ log_module(CS_LOG, LOG_INFO, "(%s) Channel registration expired.", channel->channel->name); ! unregister_channel(channel, reason); } --- 1525,1529 ---- /* Unregister the channel */ log_module(CS_LOG, LOG_INFO, "(%s) Channel registration expired.", channel->channel->name); ! unregister_channel(channel, "registration expired."); } *************** *** 1995,2004 **** } name = strdup(channel->name); - sprintf(reason, "Channel unregistered by %s.", user->handle_info->handle); unregister_channel(cData, reason); reply(CSMSG_UNREG_SUCCESS, name); - sprintf(reason, "%s unregistered by %s.", name, user->handle_info->handle); - global_message(MESSAGE_RECIPIENT_OPERS | MESSAGE_RECIPIENT_HELPERS, reason); free(name); return 1; --- 2003,2010 ---- } + sprintf(reason, "unregistered by %s.", user->handle_info->handle); name = strdup(channel->name); unregister_channel(cData, reason); reply(CSMSG_UNREG_SUCCESS, name); free(name); return 1; *************** *** 2124,2130 **** DelChannelUser(chanserv, channel, reason2, 0); } - global_message(MESSAGE_RECIPIENT_OPERS | MESSAGE_RECIPIENT_HELPERS, reason); - return 1; } --- 2130,2134 ---- *************** *** 2335,2339 **** struct userData *target_user; struct chanNode *target; ! char reason[MAXLEN], *oldname; REQUIRE_PARAMS(2); --- 2339,2343 ---- struct userData *target_user; struct chanNode *target; ! char reason[MAXLEN]; REQUIRE_PARAMS(2); *************** *** 2353,2356 **** --- 2357,2366 ---- } + if(IsProtected(channel->channel_info)) + { + chanserv_notice(user, CSMSG_MERGE_NODELETE); + return 0; + } + if(IsSuspended(target->channel_info)) { *************** *** 2374,2386 **** /* Merge the channel structures and associated data. */ merge_channel(channel->channel_info, target->channel_info); ! sprintf(reason, "Channel merged into %s by %s.", target->name, user->handle_info->handle); ! oldname = strdup(channel->name); unregister_channel(channel->channel_info, reason); chanserv_notice(user, CSMSG_MERGE_SUCCESS, target->name); - - sprintf(reason, "%s merged into %s by %s.", oldname, target->name, user->handle_info->handle); - global_message(MESSAGE_RECIPIENT_OPERS | MESSAGE_RECIPIENT_HELPERS, reason); - free(oldname); - return 1; } --- 2384,2390 ---- /* Merge the channel structures and associated data. */ merge_channel(channel->channel_info, target->channel_info); ! sprintf(reason, "merged into %s by %s.", target->name, user->handle_info->handle); unregister_channel(channel->channel_info, reason); chanserv_notice(user, CSMSG_MERGE_SUCCESS, target->name); return 1; } *************** *** 2521,2524 **** --- 2525,2529 ---- struct userData *actor; enum userLevel access = ulNone; + char *chan_name; REQUIRE_PARAMS(2); *************** *** 2564,2569 **** } del_channel_user(victim, 1); ! chanserv_notice(user, CSMSG_DELETED_USER, preposition(accessNames[access]), accessNames[access], handle->handle, channel->name); return 1; } --- 2569,2576 ---- } + chan_name = strdup(channel->name); del_channel_user(victim, 1); ! chanserv_notice(user, CSMSG_DELETED_USER, preposition(accessNames[access]), accessNames[access], handle->handle, chan_name); ! free(chan_name); return 1; } *************** *** 6873,6877 **** { log_module(CS_LOG, LOG_ERROR, "Channel %s had no users in database, unregistering it.", key); ! unregister_channel(cData, "Channel has empty user list."); return 0; } --- 6880,6884 ---- { log_module(CS_LOG, LOG_ERROR, "Channel %s had no users in database, unregistering it.", key); ! unregister_channel(cData, "has empty user list."); return 0; } *************** *** 7139,7143 **** chanserv_db_cleanup(void) { unreg_part_func(handle_part); ! while(channelList) unregister_channel(channelList, "Terminating."); dict_delete(handle_dnrs); dict_delete(plain_dnrs); --- 7146,7150 ---- chanserv_db_cleanup(void) { unreg_part_func(handle_part); ! while(channelList) unregister_channel(channelList, "terminating."); dict_delete(handle_dnrs); dict_delete(plain_dnrs); |