From 30d2f048838a551f3364090efe8ba344f88e541c Mon Sep 17 00:00:00 2001 From: Michael Poole Date: Sat, 25 Mar 2006 03:46:56 +0000 Subject: [PATCH] Resolve bug #1457429. git-svn-id: file:///home/klmitch/undernet-ircu/undernet-ircu-svn/ircu2/branches/u2_10_12_branch@1633 c9e4aea6-c8fd-4c43-8297-357d70d61c8c --- ChangeLog | 13 +++++++++++++ ircd/ircd_signal.c | 1 + ircd/jupe.c | 1 + ircd/list.c | 1 + ircd/whowas.c | 29 +++++++++++++---------------- 5 files changed, 29 insertions(+), 16 deletions(-) diff --git a/ChangeLog b/ChangeLog index c362d69..9de1843 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2006-03-24 Michael Poole + + * ircd/ircd_signal.c (alloc_crec): Zero-fill returned + ChildRecord structs. + + * ircd/jupe.c (make_jupe): Zero-fill newly allocated jupes. + + * ircd/list.c (make_link): Zero-fill returned SLink structs. + + * ircd/whowas.c (whowas_init): Delete function. + (whowas_alloc): Rewrite to follow the more common pattern and to + zero-fill returned Whowas structs. + 2006-03-23 Kevin L. Mitchell * ircd/s_auth.c: rewrite iauth_read(), spliting out the parsing diff --git a/ircd/ircd_signal.c b/ircd/ircd_signal.c index 89a05c4..650102e 100644 --- a/ircd/ircd_signal.c +++ b/ircd/ircd_signal.c @@ -134,6 +134,7 @@ static struct ChildRecord *alloc_crec(void) crec = MyCalloc(1, sizeof(*crec)); } + memset(crec, 0, sizeof(*crec)); crec->next = NULL; return crec; } diff --git a/ircd/jupe.c b/ircd/jupe.c index 8cdaa9e..243ae62 100644 --- a/ircd/jupe.c +++ b/ircd/jupe.c @@ -65,6 +65,7 @@ make_jupe(char *server, char *reason, time_t expire, time_t lastmod, ajupe = (struct Jupe*) MyMalloc(sizeof(struct Jupe)); /* alloc memory */ assert(0 != ajupe); + memset(ajupe, 0, sizeof(*ajupe)); DupString(ajupe->ju_server, server); /* copy vital information */ DupString(ajupe->ju_reason, reason); ajupe->ju_expire = expire; diff --git a/ircd/list.c b/ircd/list.c index cbf98c5..f485ec0 100644 --- a/ircd/list.c +++ b/ircd/list.c @@ -436,6 +436,7 @@ struct SLink* make_link(void) } assert(0 != lp); links.inuse++; + memset(lp, 0, sizeof(*lp)); return lp; } diff --git a/ircd/whowas.c b/ircd/whowas.c index 1392027..fed3fff 100644 --- a/ircd/whowas.c +++ b/ircd/whowas.c @@ -209,18 +209,6 @@ whowas_free(struct Whowas *ww) wwList.ww_alloc--; } -/** Initialize a whowas record. - * @param[in,out] ww Whowas record to initialize. - * @return The pointer \a ww. - */ -static struct Whowas * -whowas_init(struct Whowas *ww) -{ - if (ww) - memset(ww, 0, sizeof(*ww)); - return ww; -} - /** Return a fresh Whowas record. * If the total number of records is smaller than determined by * FEAT_NICKNAMEHISTORYLENGTH, allocate a new one. Otherwise, @@ -230,11 +218,20 @@ whowas_init(struct Whowas *ww) static struct Whowas * whowas_alloc(void) { - if (wwList.ww_alloc >= feature_int(FEAT_NICKNAMEHISTORYLENGTH)) - return whowas_init(whowas_clean(wwList.ww_tail)); + struct Whowas *ww; - wwList.ww_alloc++; /* going to allocate a new one... */ - return whowas_init((struct Whowas *) MyMalloc(sizeof(struct Whowas))); + if (wwList.ww_alloc >= feature_int(FEAT_NICKNAMEHISTORYLENGTH)) { + /* reclaim the oldest whowas entry */ + ww = whowas_clean(wwList.ww_tail); + } else { + /* allocate a new one */ + wwList.ww_alloc++; + ww = (struct Whowas *) MyMalloc(sizeof(struct Whowas)); + } + + assert(ww != NULL); + memset(ww, 0, sizeof(*ww)); + return ww; } /** If necessary, trim the whowas list. -- 2.20.1