Thread: [srvx-commits] CVS: services/src helpserv.c,1.37,1.38
Brought to you by:
entrope
|
From: Adrian D. <sai...@us...> - 2002-09-30 01:44:01
|
Update of /cvsroot/srvx/services/src
In directory usw-pr-cvs1:/tmp/cvs-serv29373
Modified Files:
helpserv.c
Log Message:
Forward-port buffer overflow fixes and alloca() removal from 1.1
Index: helpserv.c
===================================================================
RCS file: /cvsroot/srvx/services/src/helpserv.c,v
retrieving revision 1.37
retrieving revision 1.38
diff -C2 -r1.37 -r1.38
*** helpserv.c 29 Sep 2002 00:06:00 -0000 1.37
--- helpserv.c 30 Sep 2002 01:43:56 -0000 1.38
***************
*** 1902,1908 ****
if (is_valid_nick(argv[1])) {
! char *newnick = argv[1], *oldnick, *reason;
- oldnick = alloca(strlen(hs->helpserv->nick) + 1);
strcpy(oldnick, hs->helpserv->nick);
--- 1902,1907 ----
if (is_valid_nick(argv[1])) {
! char *newnick = argv[1], oldnick[NICKLEN], reason[MAXLEN];
strcpy(oldnick, hs->helpserv->nick);
***************
*** 1918,1923 ****
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);
--- 1917,1921 ----
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);
***************
*** 1925,1932 ****
} 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);
--- 1923,1929 ----
} 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);
***************
*** 1947,1954 ****
}
- 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);
}
--- 1944,1950 ----
}
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);
}
***************
*** 1969,1973 ****
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);
--- 1965,1969 ----
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);
***************
*** 2299,2303 ****
static HELPSERV_FUNC(cmd_register) {
! char *nick, *helpchan, *reason;
struct handle_info *handle;
--- 2295,2299 ----
static HELPSERV_FUNC(cmd_register) {
! char *nick, *helpchan, reason[MAXLEN];
struct handle_info *handle;
***************
*** 2338,2343 ****
helpserv_notice(user, HSMSG_REG_SUCCESS, handle->handle, nick);
! reason = alloca(strlen(user->nick) + strlen(nick) + strlen(hs->helpchan->name) + 43);
! sprintf(reason, "HelpServ %s (%s) registered to %s by %s.", nick, hs->helpchan->name, handle->handle, user->nick);
/* Not sent to helpers, since they can't register HelpServ */
global_message(MESSAGE_RECIPIENT_OPERS, reason);
--- 2334,2338 ----
helpserv_notice(user, HSMSG_REG_SUCCESS, handle->handle, nick);
! snprintf(reason, MAXLEN, "HelpServ %s (%s) registered to %s by %s.", nick, hs->helpchan->name, handle->handle, user->nick);
/* Not sent to helpers, since they can't register HelpServ */
global_message(MESSAGE_RECIPIENT_OPERS, reason);
***************
*** 2369,2373 ****
static HELPSERV_FUNC(cmd_unregister) {
int len;
! char reason[MAXLEN], *channame, *botname;
struct helpserv_botlist *botlist;
--- 2364,2368 ----
static HELPSERV_FUNC(cmd_unregister) {
int len;
! char reason[MAXLEN], channame[CHANNELLEN], botname[NICKLEN];
struct helpserv_botlist *botlist;
***************
*** 2386,2401 ****
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;
--- 2381,2394 ----
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;
***************
*** 3200,3205 ****
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);
--- 3193,3197 ----
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);
|