[srvx-commits] CVS: services/src helpserv.c,1.14.2.5,1.14.2.6
Brought to you by:
entrope
|
From: Adrian D. <sai...@us...> - 2002-09-30 01:33:46
|
Update of /cvsroot/srvx/services/src
In directory usw-pr-cvs1:/tmp/cvs-serv27055
Modified Files:
Tag: rel-1_1-branch
helpserv.c
Log Message:
Remove a few other buffer overflows, and while I'm at it, remove all use of alloca() other than in allocating tables
Index: helpserv.c
===================================================================
RCS file: /cvsroot/srvx/services/src/helpserv.c,v
retrieving revision 1.14.2.5
retrieving revision 1.14.2.6
diff -C2 -r1.14.2.5 -r1.14.2.6
*** helpserv.c 30 Sep 2002 01:19:29 -0000 1.14.2.5
--- helpserv.c 30 Sep 2002 01:33:43 -0000 1.14.2.6
***************
*** 1782,1788 ****
if (IsNickName(argv[1])) {
! char *newnick = argv[1], *oldnick, *reason;
- oldnick = alloca(strlen(hs->helpserv->nick) + 1);
strcpy(oldnick, hs->helpserv->nick);
--- 1782,1787 ----
if (IsNickName(argv[1])) {
! char *newnick = argv[1], oldnick[NICKLEN], reason[MAXLEN];
strcpy(oldnick, hs->helpserv->nick);
***************
*** 1798,1803 ****
helpserv_notice(user, HSMSG_RENAMED, oldnick, newnick);
! reason = alloca(strlen(user->nick) + strlen(newnick) + strlen(hs->helpchan->name) + strlen(oldnick) + 30);
! sprintf(reason, "HelpServ bot %s (in %s) renamed to %s by %s.", oldnick, hs->helpchan->name, newnick, user->nick);
global_message(MESSAGE_RECIPIENT_OPERS, reason);
--- 1797,1801 ----
helpserv_notice(user, HSMSG_RENAMED, oldnick, newnick);
! snprintf(reason, MAXLEN, "HelpServ bot %s (in %s) renamed to %s by %s.", oldnick, hs->helpchan->name, newnick, user->nick);
global_message(MESSAGE_RECIPIENT_OPERS, reason);
***************
*** 1805,1812 ****
} else if (IsChannelName(argv[1])) {
struct chanNode *old_helpchan = hs->helpchan;
! char *newchan = argv[1], *oldchan, *reason;
struct helpserv_botlist *botlist;
- oldchan = alloca(strlen(hs->helpchan->name) + 1);
strcpy(oldchan, hs->helpchan->name);
--- 1803,1809 ----
} else if (IsChannelName(argv[1])) {
struct chanNode *old_helpchan = hs->helpchan;
! char *newchan = argv[1], oldchan[CHANNELLEN], reason[MAXLEN];
struct helpserv_botlist *botlist;
strcpy(oldchan, hs->helpchan->name);
***************
*** 1827,1834 ****
}
- reason = alloca(strlen(user->nick) + strlen(newchan) + strlen(oldchan) + strlen(hs->helpserv->nick) + 28);
hs->helpchan = NULL;
if (!helpserv_in_channel(hs, old_helpchan)) {
! sprintf(reason, "Moved to %s by %s.", newchan, user->nick);
DelChannelUser(hs->helpserv, old_helpchan, reason, 0);
}
--- 1824,1830 ----
}
hs->helpchan = NULL;
if (!helpserv_in_channel(hs, old_helpchan)) {
! snprintf(reason, MAXLEN, "Moved to %s by %s.", newchan, user->nick);
DelChannelUser(hs->helpserv, old_helpchan, reason, 0);
}
***************
*** 1848,1852 ****
helpserv_botlist_append(botlist, hs);
! sprintf(reason, "HelpServ %s (%s) moved to %s by %s.", hs->helpserv->nick, oldchan, newchan, user->nick);
global_message(MESSAGE_RECIPIENT_OPERS, reason);
--- 1844,1848 ----
helpserv_botlist_append(botlist, hs);
! snprintf(reason, MAXLEN, "HelpServ %s (%s) moved to %s by %s.", hs->helpserv->nick, oldchan, newchan, user->nick);
global_message(MESSAGE_RECIPIENT_OPERS, reason);
***************
*** 2232,2236 ****
static HELPSERV_FUNC(cmd_unregister) {
int len;
! char reason[MAXLEN], *channame, *botname;
struct helpserv_botlist *botlist;
--- 2228,2232 ----
static HELPSERV_FUNC(cmd_unregister) {
int len;
! char reason[MAXLEN], channame[CHANNELLEN], botname[NICKLEN];
struct helpserv_botlist *botlist;
***************
*** 2249,2264 ****
len = strlen(hs->helpserv->nick) + 1;
- botname = alloca(len);
safestrncpy(botname, hs->helpserv->nick, len);
len = strlen(hs->helpchan->name) + 1;
- channame = alloca(len);
safestrncpy(channame, hs->helpchan->name, len);
! sprintf(reason, "HelpServ unregistered by %s.", user->nick);
DelUser(hs->helpserv, NULL, 1, reason);
dict_remove(helpserv_bots_dict, botname);
! sprintf(reason, "HelpServ %s (%s) unregistered by %s.", botname, channame, user->nick);
global_message(MESSAGE_RECIPIENT_OPERS, reason);
return 1;
--- 2245,2258 ----
len = strlen(hs->helpserv->nick) + 1;
safestrncpy(botname, hs->helpserv->nick, len);
len = strlen(hs->helpchan->name) + 1;
safestrncpy(channame, hs->helpchan->name, len);
! snprintf(reason, MAXLEN, "HelpServ unregistered by %s.", user->nick);
DelUser(hs->helpserv, NULL, 1, reason);
dict_remove(helpserv_bots_dict, botname);
! snprintf(reason, MAXLEN, "HelpServ %s (%s) unregistered by %s.", botname, channame, user->nick);
global_message(MESSAGE_RECIPIENT_OPERS, reason);
return 1;
***************
*** 3098,3103 ****
if (hs->persist_types[PERSIST_T_HELPER] == PERSIST_PART) {
if (req->helper == hs_user) {
! char *reason;
! reason = alloca(8 + strlen(chan->name));
sprintf(reason, "parted %s", chan->name);
helpserv_page_helper_gone(hs, req, reason);
--- 3092,3096 ----
if (hs->persist_types[PERSIST_T_HELPER] == PERSIST_PART) {
if (req->helper == hs_user) {
! char reason[CHANNELLEN + 8];
sprintf(reason, "parted %s", chan->name);
helpserv_page_helper_gone(hs, req, reason);
|