Bladeren bron

* Using custom calloc/realloc functions now to check for failed allocations

svn: 1601
Bryan Drewery 21 jaren geleden
bovenliggende
commit
dc75f1e092

+ 0 - 1
doc/UPDATES

@@ -11,7 +11,6 @@ This is a summary of ChangeLog basically.
 * Fixed cmd_comment bug with changing comment on lower level users.
 * Bots now unban bans that match *linked* bots, +m bans besides this will not be unset auto.
 
-
 1.2
 * No longer displaying SALTS on ./bin -v
 * Wrote new 'response' code for misc stuff like kick reasons, and dcc responses...

+ 8 - 8
src/adns.c

@@ -208,7 +208,7 @@ static void answer_init(dns_answer_t *answer)
 
 static void answer_add(dns_answer_t *answer, const char *what)
 {
-	answer->list = (char **) realloc(answer->list, sizeof(*answer->list) * (answer->len+2));
+	answer->list = (char **) my_realloc(answer->list, sizeof(*answer->list) * (answer->len+2));
 	answer->list[answer->len] = strdup(what);
 	answer->len++;
 	answer->list[answer->len] = NULL;
@@ -223,7 +223,7 @@ static void answer_free(dns_answer_t *answer)
 
 static dns_query_t *alloc_query(void *client_data, dns_callback_t callback, const char *query)
 {
-	dns_query_t *q = (dns_query_t *) calloc(1, sizeof(*q));
+	dns_query_t *q = (dns_query_t *) my_calloc(1, sizeof(*q));
 
 	q->id = query_id;
 	query_id++;
@@ -457,12 +457,12 @@ int egg_dns_reverse(const char *ip, int timeout, dns_callback_t callback, void *
 		char temp[65];
 
 		socket_ipv6_to_dots(ip, temp);
-		reversed_ip = (char *) malloc(strlen(temp) + 10);
+		reversed_ip = (char *) my_calloc(1, strlen(temp) + 10);
 		reverse_ip(temp, reversed_ip);
 		strcat(reversed_ip, ".in6.arpa");
 	}
 	else {
-		reversed_ip = (char *) malloc(strlen(ip) + 14);
+		reversed_ip = (char *) my_calloc(1, strlen(ip) + 14);
 		reverse_ip(ip, reversed_ip);
 		strcat(reversed_ip, ".in-addr.arpa");
 	}
@@ -549,7 +549,7 @@ static const char *dns_next_server()
 
 static void add_server(char *ip)
 {
-	servers = (dns_server_t *) realloc(servers, (nservers+1)*sizeof(*servers));
+	servers = (dns_server_t *) my_realloc(servers, (nservers+1)*sizeof(*servers));
 	servers[nservers].ip = strdup(ip);
 	nservers++;
         sdprintf("Added NS: %s", ip);
@@ -557,7 +557,7 @@ static void add_server(char *ip)
 
 static void add_host(char *host, char *ip)
 {
-	hosts = (dns_host_t *) realloc(hosts, (nhosts+1)*sizeof(*hosts));
+	hosts = (dns_host_t *) my_realloc(hosts, (nhosts+1)*sizeof(*hosts));
 	hosts[nhosts].host = strdup(host);
 	hosts[nhosts].ip = strdup(ip);
 	nhosts++;
@@ -580,14 +580,14 @@ static void cache_del(int id)
 	if (id < ncache) egg_memcpy(&cache[id], &cache[ncache], sizeof(dns_cache_t));
 	else egg_bzero(&cache[id], sizeof(dns_cache_t));
 
-	cache = (dns_cache_t *) realloc(cache, (ncache+1)*sizeof(*cache));
+	cache = (dns_cache_t *) my_realloc(cache, (ncache+1)*sizeof(*cache));
 }
 
 static void cache_add(const char *query, dns_answer_t *answer)
 {
 	int i;
 
-	cache = (dns_cache_t *) realloc(cache, (ncache+1)*sizeof(*cache));
+	cache = (dns_cache_t *) my_realloc(cache, (ncache+1)*sizeof(*cache));
 	egg_bzero(&cache[ncache], sizeof(cache[ncache]));
 	cache[ncache].query = strdup(query);
 	answer_init(&cache[ncache].answer);

+ 2 - 2
src/auth.c

@@ -41,9 +41,9 @@ init_auth_max()
   if (max_auth < 1)
     max_auth = 1;
   if (auth)
-    auth = (struct auth_t *) realloc(auth, sizeof(struct auth_t) * max_auth);
+    auth = (struct auth_t *) my_realloc(auth, sizeof(struct auth_t) * max_auth);
   else
-    auth = (struct auth_t *) calloc(1, sizeof(struct auth_t) * max_auth);
+    auth = (struct auth_t *) my_calloc(1, sizeof(struct auth_t) * max_auth);
 }
 
 static void

+ 3 - 2
src/base64.c

@@ -4,6 +4,7 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include "base64.h"
+#include "src/compat/compat.h"
 
 static const char base64[65] = ".\\0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
 static const char base64r[256] = {
@@ -28,7 +29,7 @@ static const char base64r[256] = {
 char *
 b64enc(const unsigned char *data, size_t len)
 {
-  char *dest = (char *) calloc(1, (len << 2) / 3 + 4 + 1);
+  char *dest = (char *) my_calloc(1, (len << 2) / 3 + 4 + 1);
 
   b64enc_buf(data, len, dest);
   return (dest);
@@ -53,7 +54,7 @@ b64enc_buf(const unsigned char *data, size_t len, char *dest)
 char *
 b64dec(const unsigned char *data, size_t *len)
 {
-  char *dest = (char *) calloc(1, ((*len * 3) >> 2) + 6 + 1);
+  char *dest = (char *) my_calloc(1, ((*len * 3) >> 2) + 6 + 1);
 
   b64dec_buf(data, len, dest);
   return (dest);

+ 1 - 1
src/binary.c

@@ -72,7 +72,7 @@ bin_md5(const char *fname, int todo, MD5_CTX * ctx)
     size_t size = 0, i = 0;
 
     size = strlen(fname) + 2;
-    fname_bak = (char *) calloc(1, size);
+    fname_bak = (char *) my_calloc(1, size);
     egg_snprintf(fname_bak, size, "%s~", fname);
     size = 0;
 

+ 1 - 1
src/botcmd.c

@@ -1279,7 +1279,7 @@ static void bot_rsimr(char *botnick, char *code, char *msg)
     int idx = atoi(newsplit(&par));
     size_t size = strlen(botnick) + 4;
 
-    prefix = (char *) calloc(1, size);
+    prefix = (char *) my_calloc(1, size);
     egg_snprintf(prefix, size, "[%s] ", botnick);
     dumplots(idx, prefix, par);
     free(prefix);

+ 1 - 1
src/botmsg.c

@@ -175,7 +175,7 @@ static void send_tand_but(int x, char *buf, size_t len)
 void botnet_send_cmdpass(int idx, char *cmd, char *pass)
 {
   if (tands > 0) {
-    char *buf = (char *) calloc(1, strlen(cmd) + strlen(pass) + 5 + 1);
+    char *buf = (char *) my_calloc(1, strlen(cmd) + strlen(pass) + 5 + 1);
 
     sprintf(buf, "cp %s %s\n", cmd, pass);
     send_tand_but(idx, buf, strlen(buf));

+ 5 - 5
src/botnet.c

@@ -40,7 +40,7 @@ static int		share_unlinks = 1;		/* Allow remote unlinks of my
 
 void init_party()
 {
-  party = (party_t *) calloc(1, maxparty * sizeof(party_t));
+  party = (party_t *) my_calloc(1, maxparty * sizeof(party_t));
 }
 
 tand_t *findbot(char *who)
@@ -64,7 +64,7 @@ void addbot(char *who, char *from, char *next, char flag, int vlocalhub, time_t
       putlog(LOG_BOTS, "*", "!!! Duplicate botnet bot entry!!");
     ptr = &((*ptr)->next);
   }
-  ptr2 = (tand_t *) calloc(1, sizeof(tand_t));
+  ptr2 = (tand_t *) my_calloc(1, sizeof(tand_t));
   strncpy(ptr2->bot, who, HANDLEN);
   ptr2->bot[HANDLEN] = 0;
   ptr2->share = flag;
@@ -146,7 +146,7 @@ int addparty(char *bot, char *nick, int chan, char flag, int sock,
   /* New member */
   if (parties == maxparty) {
     maxparty += 50;
-    party = (party_t *) realloc((void *) party, maxparty * sizeof(party_t));
+    party = (party_t *) my_realloc((void *) party, maxparty * sizeof(party_t));
   }
   strncpy(party[parties].nick, nick, HANDLEN);
   party[parties].nick[HANDLEN] = 0;
@@ -1167,7 +1167,7 @@ void tandem_relay(int idx, char *nick, register int i)
 
   struct chat_info *ci = dcc[idx].u.chat;
 
-  dcc[idx].u.relay = (struct relay_info *) calloc(1, sizeof(struct relay_info));
+  dcc[idx].u.relay = (struct relay_info *) my_calloc(1, sizeof(struct relay_info));
   dcc[idx].u.relay->chat = ci;
   dcc[idx].u.relay->old_status = dcc[idx].status;
 
@@ -1230,7 +1230,7 @@ static void tandem_relay_dns_callback(int id, void *client_data, const char *hos
 
   dcc[i].addr = inet_addr(ips[0]);
 
-  dcc[i].u.relay->chat = (struct chat_info *) calloc(1, sizeof(struct chat_info));
+  dcc[i].u.relay->chat = (struct chat_info *) my_calloc(1, sizeof(struct chat_info));
   dcc[i].u.relay->sock = sock;
   dcc[i].u.relay->port = dcc[i].port;
   dcc[i].u.relay->chat->away = NULL;

+ 3 - 3
src/cfg.c

@@ -637,7 +637,7 @@ struct cfg_entry CFG_OPREQUESTS = {
 
 void add_cfg(struct cfg_entry *entry)
 {
-  cfg = (struct cfg_entry **) realloc(cfg, sizeof(void *) * (cfg_count + 1));
+  cfg = (struct cfg_entry **) my_realloc(cfg, sizeof(void *) * (cfg_count + 1));
   cfg[cfg_count] = entry;
   cfg_count++;
   entry->ldata = NULL;
@@ -706,7 +706,7 @@ void set_cfg_str(char *target, char *entryname, char *data)
         }
       }
     }
-    xk = (struct xtra_key *) calloc(1, sizeof(struct xtra_key));
+    xk = (struct xtra_key *) my_calloc(1, sizeof(struct xtra_key));
     xk->key = strdup(entry->name);
     if (data) {
       xk->data = strdup(data);
@@ -847,7 +847,7 @@ void set_cmd_pass(char *ln, int shareit)
       free(cp);
   } else if (ln[0]) {
     /* create */
-    cp = (struct cmd_pass *) calloc(1, sizeof(struct cmd_pass));
+    cp = (struct cmd_pass *) my_calloc(1, sizeof(struct cmd_pass));
     cp->next = cmdpass;
     cmdpass = cp;
     cp->name = strdup(cmd);

+ 7 - 7
src/chanprog.c

@@ -421,7 +421,7 @@ void load_internal_users()
         hublevel++;		/* We must increment this even if it is already added */
 	if (!get_user_by_handle(userlist, hand)) {
 	  userlist = adduser(userlist, hand, "none", "-", USER_OP, 1);
-	  bi = (struct bot_addr *) calloc(1, sizeof(struct bot_addr));
+	  bi = (struct bot_addr *) my_calloc(1, sizeof(struct bot_addr));
 
           bi->address = strdup(ip);
 	  bi->telnet_port = atoi(port) ? atoi(port) : 0;
@@ -431,7 +431,7 @@ void load_internal_users()
 	  if ((!bi->hublevel) && (!strcmp(hand, conf.bot->nick)))
 	    bi->hublevel = 99;
 #endif /* HUB */
-          bi->uplink = (char *) calloc(1, 1);
+          bi->uplink = (char *) my_calloc(1, 1);
 	  set_user(&USERENTRY_BOTADDR, get_user_by_handle(userlist, hand), bi);
 	  /* set_user(&USERENTRY_PASS, get_user_by_handle(userlist, hand), SALT2); */
 	}
@@ -543,7 +543,7 @@ void chanprog()
     /* I need to be on the userlist... doh. */
     userlist = adduser(userlist, conf.bot->nick, "none", "-", USER_OP, 1);
     conf.bot->u = get_user_by_handle(userlist, conf.bot->nick);
-    bi = (struct bot_addr *) calloc(1, sizeof(struct bot_addr));
+    bi = (struct bot_addr *) my_calloc(1, sizeof(struct bot_addr));
     if (conf.bot->ip)
       bi->address = strdup(conf.bot->ip);
     /* bi->telnet_port = atoi(buf) ? atoi(buf) : 3333; */
@@ -553,7 +553,7 @@ void chanprog()
 #else /* !HUB */
     bi->hublevel = 0;
 #endif /* HUB */
-    bi->uplink = (char *) calloc(1, 1);
+    bi->uplink = (char *) my_calloc(1, 1);
     set_user(&USERENTRY_BOTADDR, conf.bot->u, bi);
   } else {
     bi = (struct bot_addr *) get_user(&USERENTRY_BOTADDR, conf.bot->u);
@@ -674,7 +674,7 @@ chans_addbot(const char *bot, struct chanset_t *chan)
     char *buf = NULL;
    
     size = strlen(chans) + strlen(chan->dname) + 2;
-    buf = (char *) calloc(1, size);
+    buf = (char *) my_calloc(1, size);
     egg_snprintf(buf, size, "%s %s", chans, chan->dname);
     set_user(&USERENTRY_CHANS, u, buf);
     free(buf);
@@ -736,9 +736,9 @@ int do_chanset(char *result, struct chanset_t *chan, const char *options, int lo
     char *buf = NULL;
          /* malloc(options,chan,'cset ',' ',+ 1) */
     if (chan)
-      buf = (char *) calloc(1, strlen(options) + strlen(chan->dname) + 5 + 1 + 1);
+      buf = (char *) my_calloc(1, strlen(options) + strlen(chan->dname) + 5 + 1 + 1);
     else
-      buf = (char *) calloc(1, strlen(options) + 1 + 5 + 1 + 1);
+      buf = (char *) my_calloc(1, strlen(options) + 1 + 5 + 1 + 1);
 
     strcat(buf, "cset ");
     if (chan)

+ 26 - 26
src/cmds.c

@@ -256,7 +256,7 @@ static void cmd_config(int idx, char *par)
   if (!par[0]) {
     char *outbuf = NULL;
 
-    outbuf = (char *) calloc(1, 1);
+    outbuf = (char *) my_calloc(1, 1);
 
     dprintf(idx, "Usage: config [name [value|-]]\n");
     dprintf(idx, "Defined config entry names:\n");
@@ -264,10 +264,10 @@ static void cmd_config(int idx, char *par)
     for (i = 0; i < cfg_count; i++) {
       if ((cfg[i]->flags & CFGF_GLOBAL) && (cfg[i]->describe)) {
 	if (!cnt) {
-          outbuf = (char *) realloc(outbuf, 2 + 1);
+          outbuf = (char *) my_realloc(outbuf, 2 + 1);
 	  sprintf(outbuf, "  ");
         }
-        outbuf = (char *) realloc(outbuf, strlen(outbuf) + strlen(cfg[i]->name) + 1 + 1);
+        outbuf = (char *) my_realloc(outbuf, strlen(outbuf) + strlen(cfg[i]->name) + 1 + 1);
 	sprintf(outbuf, "%s%s ", outbuf, cfg[i]->name);
 	cnt++;
 	if (cnt == 10) {
@@ -524,7 +524,7 @@ static void cmd_motd(int idx, char *par)
     size_t size;
   
     size = strlen(par) + 1 + strlen(dcc[idx].nick) + 10 + 1 + 1;
-    s = (char *) calloc(1, size); /* +2: ' 'x2 */
+    s = (char *) my_calloc(1, size); /* +2: ' 'x2 */
 
     egg_snprintf(s, size, "%s %li %s", dcc[idx].nick, now, par);
     set_cfg_str(NULL, "motd", s);
@@ -595,13 +595,13 @@ static void cmd_addline(int idx, char *par)
   struct list_type *q = (struct list_type *) get_user(&USERENTRY_HOSTS, u);
   char *hostbuf = NULL, *outbuf = NULL;
   
-  hostbuf = (char *) calloc(1, 1);
+  hostbuf = (char *) my_calloc(1, 1);
   for (; q; q = q->next) {
-    hostbuf = (char *) realloc(hostbuf, strlen(hostbuf) + strlen(q->extra) + 2);
+    hostbuf = (char *) my_realloc(hostbuf, strlen(hostbuf) + strlen(q->extra) + 2);
     strcat(hostbuf, q->extra);
     strcat(hostbuf, " ");
   }
-  outbuf = (char *) calloc(1, strlen(hostbuf) + strlen(u->handle) + 20);
+  outbuf = (char *) my_calloc(1, strlen(hostbuf) + strlen(u->handle) + 20);
   sprintf(outbuf, "Addline: +user %s %s", u->handle, hostbuf);
   dumplots(idx, "", outbuf);
   free(hostbuf);
@@ -716,7 +716,7 @@ int my_cmp(const mycmds *c1, const mycmds *c2)
 
 static void cmd_nohelp(int idx, char *par)
 {
-  char *buf = (char *) calloc(1, 1);
+  char *buf = (char *) my_calloc(1, 1);
 
   qsort(cmdlist, cmdi, sizeof(mycmds), (int (*)(const void *, const void *)) &my_cmp);
   
@@ -726,7 +726,7 @@ static void cmd_nohelp(int idx, char *par)
     for (int o = 0; (help[o].cmd) && (help[o].desc); o++)
       if (!egg_strcasecmp(help[o].cmd, cmdlist[i].name)) found++;
     if (!found) {
-      buf = (char *) realloc(buf, strlen(buf) + 2 + strlen(cmdlist[i].name) + 1);
+      buf = (char *) my_realloc(buf, strlen(buf) + 2 + strlen(cmdlist[i].name) + 1);
       strcat(buf, cmdlist[i].name);
       strcat(buf, ", ");
     }
@@ -1526,7 +1526,7 @@ static void cmd_hublevel(int idx, char *par)
 
   dprintf(idx, "Changed bot's hublevel.\n");
   obi = (struct bot_addr *) get_user(&USERENTRY_BOTADDR, u1);
-  bi = (struct bot_addr *) calloc(1, sizeof(struct bot_addr));
+  bi = (struct bot_addr *) my_calloc(1, sizeof(struct bot_addr));
 
   bi->uplink = strdup(obi->uplink);
   bi->address = strdup(obi->address);
@@ -1567,7 +1567,7 @@ static void cmd_uplink(int idx, char *par)
   struct bot_addr *bi = NULL, *obi = NULL;
 
   obi = (struct bot_addr *) get_user(&USERENTRY_BOTADDR, u1);
-  bi = (struct bot_addr *) calloc(1, sizeof(struct bot_addr));
+  bi = (struct bot_addr *) my_calloc(1, sizeof(struct bot_addr));
 
   bi->uplink = strdup(uplink);
   bi->address = strdup(obi->address);
@@ -1623,7 +1623,7 @@ static void cmd_chaddr(int idx, char *par)
     relay_port = bi->relay_port;
   }
 
-  bi = (struct bot_addr *) calloc(1, sizeof(struct bot_addr));
+  bi = (struct bot_addr *) my_calloc(1, sizeof(struct bot_addr));
 
   bi->uplink = strdup(obi->uplink);
   bi->hublevel = obi->hublevel;
@@ -1643,13 +1643,13 @@ static void cmd_chaddr(int idx, char *par)
       addr++;					/* lose the '[' */
       r = strchr(addr, ']');			/* pointer to the ending ']' */
 
-      bi->address = (char *) calloc(1, r - addr + 1);	/* alloc and copy the addr */
+      bi->address = (char *) my_calloc(1, r - addr + 1);	/* alloc and copy the addr */
       strncpyz(bi->address, addr, r - addr + 1);
 
       q = r + 1;				/* set q to ':' at addr */
     } else {
 #endif /* !USE_IPV6 */
-      bi->address = (char *) calloc(1, q - addr + 1);
+      bi->address = (char *) my_calloc(1, q - addr + 1);
       strncpyz(bi->address, addr, q - addr + 1);
 #ifdef USE_IPV6
     }
@@ -1718,7 +1718,7 @@ static void cmd_randstring(int idx, char *par)
   if (len < 301) {
     char *randstring = NULL;
 
-    randstring = (char *) calloc(1, len + 1);
+    randstring = (char *) my_calloc(1, len + 1);
     make_rand_str(randstring, len);
     dprintf(idx, "string: %s\n", randstring);
     free(randstring);
@@ -2421,7 +2421,7 @@ static void cmd_chattr(int idx, char *par)
 	return;
       }
     } else if (arg && !strpbrk(chg, "&|")) {
-      tmpchg = (char *) calloc(1, strlen(chg) + 2);
+      tmpchg = (char *) my_calloc(1, strlen(chg) + 2);
       strcpy(tmpchg, "|");
       strcat(tmpchg, chg);
       chg = tmpchg;
@@ -2735,7 +2735,7 @@ static void cmd_ps(int idx, char *par) {
   }
 
   size_t size = strlen(par) + 9 + 1;
-  char *buf = (char *) calloc(1, size);
+  char *buf = (char *) my_calloc(1, size);
 
   egg_snprintf(buf, size, "ps %s", par);
   if (!exec_str(idx, buf))
@@ -3073,9 +3073,9 @@ static void cmd_su(int idx, char *par)
 	 */
 	if (dcc[idx].u.chat->away != NULL)
 	  free(dcc[idx].u.chat->away);
-        dcc[idx].u.chat->away = (char *) calloc(1, strlen(dcc[idx].nick) + 1);
+        dcc[idx].u.chat->away = (char *) my_calloc(1, strlen(dcc[idx].nick) + 1);
 	strcpy(dcc[idx].u.chat->away, dcc[idx].nick);
-        dcc[idx].u.chat->su_nick = (char *) calloc(1, strlen(dcc[idx].nick) + 1);
+        dcc[idx].u.chat->su_nick = (char *) my_calloc(1, strlen(dcc[idx].nick) + 1);
 	strcpy(dcc[idx].u.chat->su_nick, dcc[idx].nick);
 	dcc[idx].user = u;
 	strcpy(dcc[idx].nick, par);
@@ -3092,7 +3092,7 @@ static void cmd_su(int idx, char *par)
 	dprintf(idx, "Setting your username to %s.\n", par);
 	if (atr & USER_MASTER)
 	  dcc[idx].u.chat->con_flags = conmask;
-        dcc[idx].u.chat->su_nick = (char *) calloc(1, strlen(dcc[idx].nick) + 1);
+        dcc[idx].u.chat->su_nick = (char *) my_calloc(1, strlen(dcc[idx].nick) + 1);
 	strcpy(dcc[idx].u.chat->su_nick, dcc[idx].nick);
 	dcc[idx].user = u;
 	strcpy(dcc[idx].nick, par);
@@ -3178,13 +3178,13 @@ static void cmd_newleaf(int idx, char *par)
 
     userlist = adduser(userlist, handle, "none", "-", USER_OP, 1);
     u1 = get_user_by_handle(userlist, handle);
-    bi = (struct bot_addr *) calloc(1, sizeof(struct bot_addr));
+    bi = (struct bot_addr *) my_calloc(1, sizeof(struct bot_addr));
 
-    bi->uplink = (char *) calloc(1, strlen(conf.bot->nick) + 1); 
+    bi->uplink = (char *) my_calloc(1, strlen(conf.bot->nick) + 1); 
 /*      strcpy(bi->uplink, conf.bot->nick); */
     strcpy(bi->uplink, "");
 
-    bi->address = (char *) calloc(1, 1);
+    bi->address = (char *) my_calloc(1, 1);
     bi->telnet_port = 3333;
     bi->relay_port = 3333;
     bi->hublevel = 0;
@@ -3208,7 +3208,7 @@ static void cmd_nopass(int idx, char *par)
 {
   int cnt = 0;
   struct userrec *cu = NULL;
-  char *users = (char *) calloc(1, 1);
+  char *users = (char *) my_calloc(1, 1);
 
   putlog(LOG_CMDS, "*", "#%s# nopass %s", dcc[idx].nick, (par && par[0]) ? par : "");
 
@@ -3216,7 +3216,7 @@ static void cmd_nopass(int idx, char *par)
     if (!cu->bot) {
       if (u_pass_match(cu, "-")) {
         cnt++;
-        users = (char *) realloc(users, strlen(users) + strlen(cu->handle) + 1 + 1);
+        users = (char *) my_realloc(users, strlen(users) + strlen(cu->handle) + 1 + 1);
         strcat(users, cu->handle);
         strcat(users, " ");
       }
@@ -4127,7 +4127,7 @@ void gotremotereply (char *frombot, char *tohand, char *toidx, char *ln) {
   if ((idx >= 0) && (idx < dcc_total) && (dcc[idx].type == &DCC_CHAT) && (!strcmp(dcc[idx].nick, tohand))) {
     char *buf = NULL;
     
-    buf = (char *) calloc(1, strlen(frombot) + 2 + 1);
+    buf = (char *) my_calloc(1, strlen(frombot) + 2 + 1);
 
     sprintf(buf, "(%s)", frombot);
     dprintf(idx, "%-13s %s\n", buf, ln);

+ 22 - 2
src/compat/memutil.c

@@ -14,7 +14,7 @@ str_redup(char **str, const char *newstr)
                 return;
         }
         len = strlen(newstr) + 1;
-        *str = (char *) realloc(*str, len);
+        *str = (char *) my_realloc(*str, len);
         egg_memcpy(*str, newstr, len);
 }
 
@@ -22,8 +22,28 @@ char *
 strdup(const char *entry)
 {
   size_t len = strlen(entry) + 1;
-  char *target = (char *) calloc(1, len);
+  char *target = (char *) my_calloc(1, len);
   if (target == NULL) return NULL;
   return (char *) egg_memcpy(target, entry, len);
 }
 
+void *my_calloc(size_t nmemb, size_t size)
+{
+  void *ptr = calloc(nmemb, size);
+
+  if (ptr == NULL)
+    fatal("Cannot allocate memory", 0);
+  
+  return ptr;
+}
+
+void *my_realloc(void *ptr, size_t size)
+{
+  void *x = realloc(ptr, size);
+
+  if (x == NULL && size > 0)
+    fatal("Cannot allocate memory", 0);
+
+  return x;
+}
+

+ 5 - 0
src/compat/memutil.h

@@ -1,10 +1,15 @@
 #ifndef _MEMUTIL_H
 #define _MEMUTIL_H
 
+#include <sys/types.h>
+
 #undef str_redup
 #undef strdup
 
 void str_redup(char **, const char *);
 char * strdup(const char *);
 
+void *my_calloc(size_t, size_t);
+void *my_realloc(void *, size_t);
+
 #endif /* !_MEMUTIL_H */

+ 6 - 6
src/conf.c

@@ -87,7 +87,7 @@ spawnbots()
       }
 
       size = strlen(bot->nick) + strlen(binname) + 20;
-      run = (char *) calloc(1, size);
+      run = (char *) my_calloc(1, size);
       egg_snprintf(run, size, "%s -B %s", binname, bot->nick);
       sdprintf("Spawning '%s': %s", bot->nick, run);
       status = system(run);
@@ -182,7 +182,7 @@ confedit()
 
       setgid(getgid());
       setuid(getuid());
-      run = (char *) calloc(1, size);
+      run = (char *) my_calloc(1, size);
       /* child */
       egg_snprintf(run, size, "%s %s", editor, tmpconf.file);
       execlp("/bin/sh", "/bin/sh", "-c", run, NULL);
@@ -244,7 +244,7 @@ fatal:
 void
 init_conf()
 {
-  conffile.bots = (conf_bot *) calloc(1, sizeof(conf_bot));
+  conffile.bots = (conf_bot *) my_calloc(1, sizeof(conf_bot));
   conffile.bots->nick = NULL;
   conffile.bots->next = NULL;
   conffile.bot = NULL;
@@ -343,7 +343,7 @@ conf_addbot(char *nick, char *ip, char *host, char *ip6)
 
   for (bot = conffile.bots; bot && bot->nick; bot = bot->next) ;
 
-  bot->next = (conf_bot *) calloc(1, sizeof(conf_bot));
+  bot->next = (conf_bot *) my_calloc(1, sizeof(conf_bot));
   bot->next->next = NULL;
   bot->pid_file = NULL;
   bot->nick = strdup(nick);
@@ -500,7 +500,7 @@ readconf(char *fname, int bits)
     fatal("Cannot read config", 0);
 
   free_conf_bots();
-  inbuf = (char *) calloc(1, 201);
+  inbuf = (char *) my_calloc(1, 201);
   while (fgets(inbuf, 201, f) != NULL) {
     char *line = NULL, *temp_ptr = NULL;
 
@@ -782,7 +782,7 @@ fillconf(conf_t * inconf)
     werr(ERR_BADBOT);
 
   free(mynick);
-  inconf->bot = (conf_bot *) calloc(1, sizeof(conf_bot));
+  inconf->bot = (conf_bot *) my_calloc(1, sizeof(conf_bot));
   conf_bot_dup(inconf->bot, bot);
   inconf->localhub = conffile.localhub ? strdup(conffile.localhub) : NULL;
   inconf->binpath = conffile.binpath ? strdup(conffile.binpath) : NULL;

+ 6 - 6
src/crypt.c

@@ -31,7 +31,7 @@ encrypt_binary(const char *keydata, const unsigned char *in, size_t *inlen)
   if (len % CRYPT_BLOCKSIZE)             /* more than 1 block? */
     len += (CRYPT_BLOCKSIZE - (len % CRYPT_BLOCKSIZE));
 
-  out = (unsigned char *) calloc(1, len + 1);
+  out = (unsigned char *) my_calloc(1, len + 1);
   egg_memcpy(out, in, *inlen);
   *inlen = len;
 
@@ -59,7 +59,7 @@ decrypt_binary(const char *keydata, unsigned char *in, size_t len)
   unsigned char *out = NULL;
 
   len -= len % CRYPT_BLOCKSIZE;
-  out = (unsigned char *) calloc(1, len + 1);
+  out = (unsigned char *) my_calloc(1, len + 1);
   egg_memcpy(out, in, len);
 
   if (!keydata || !*keydata) {
@@ -108,7 +108,7 @@ char *decrypt_string(const char *keydata, char *in)
     free(buf);
     return res;
   } else {
-    res = (char *) calloc(1, len + 1);
+    res = (char *) my_calloc(1, len + 1);
     strcpy(res, in);
     return res;
   }
@@ -135,7 +135,7 @@ static char *passkey()
   if (key[0])
     return key;
 
-  char *tmp = calloc(1, 512);
+  char *tmp = my_calloc(1, 512);
 
   sprintf(tmp, "%s-%s.%s!%s", settings.salt1, settings.salt2, settings.packname, settings.bdhash);
   key = SHA1(tmp);
@@ -201,7 +201,7 @@ void Encrypt_File(char *infile, char *outfile)
     printf("----------------------------------START----------------------------------\n");
   }
 
-  char *buf = (char *) calloc(1, 1024);
+  char *buf = (char *) my_calloc(1, 1024);
   while (fgets(buf, 1024, f) != NULL) {
     remove_crlf(buf);
 
@@ -238,7 +238,7 @@ void Decrypt_File(char *infile, char *outfile)
     printf("----------------------------------START----------------------------------\n");
   }
 
-  char *buf = (char *) calloc(1, 2048);
+  char *buf = (char *) my_calloc(1, 2048);
   while (fgets(buf, 2048, f) != NULL) {
     char *temps = NULL;
 

+ 6 - 6
src/dcc.c

@@ -842,10 +842,10 @@ append_line(int idx, char *line)
     else
       for (q = c->buffer; q->next; q = q->next) ;
 
-    p = (struct msgq *) calloc(1, sizeof(struct msgq));
+    p = (struct msgq *) my_calloc(1, sizeof(struct msgq));
 
     p->len = l;
-    p->msg = (char *) calloc(1, l + 1);
+    p->msg = (char *) my_calloc(1, l + 1);
     p->next = NULL;
     strcpy(p->msg, line);
     if (q == NULL)
@@ -894,7 +894,7 @@ dcc_chat_pass(int idx, char *buf, int atr)
     if (!egg_strcasecmp(buf, "elinkdone")) {
       free(dcc[idx].u.chat);
       dcc[idx].type = &DCC_BOT_NEW;
-      dcc[idx].u.bot = (struct bot_info *) calloc(1, sizeof(struct bot_info));
+      dcc[idx].u.bot = (struct bot_info *) my_calloc(1, sizeof(struct bot_info));
       dcc[idx].status = STAT_CALLED;
       dprintf(idx, "goodbye!\n");
       greet_new_bot(idx);
@@ -1522,7 +1522,7 @@ dcc_telnet_id(int idx, char *buf, int atr)
       struct chat_info *ci = dcc[idx].u.chat;
 
       dcc[idx].type = &DCC_DUPWAIT;
-      dcc[idx].u.dupwait = (struct dupwait_info *) calloc(1, sizeof(struct dupwait_info));
+      dcc[idx].u.dupwait = (struct dupwait_info *) my_calloc(1, sizeof(struct dupwait_info));
       dcc[idx].u.dupwait->chat = ci;
       dcc[idx].u.dupwait->atr = atr;
       return;
@@ -1573,7 +1573,7 @@ dcc_telnet_pass(int idx, int atr)
   if (!ok) {
     struct chat_info *ci = dcc[idx].u.chat;
 
-    dcc[idx].u.file = (struct file_info *) calloc(1, sizeof(struct file_info));
+    dcc[idx].u.file = (struct file_info *) my_calloc(1, sizeof(struct file_info));
     dcc[idx].u.file->chat = ci;
   }
 
@@ -1862,7 +1862,7 @@ dcc_telnet_got_ident(int i, char *host)
   sockoptions(dcc[i].sock, EGG_OPTION_UNSET, SOCK_BUFFER);
 
   dcc[i].type = &DCC_TELNET_ID;
-  dcc[i].u.chat = (struct chat_info *) calloc(1, sizeof(struct chat_info));
+  dcc[i].u.chat = (struct chat_info *) my_calloc(1, sizeof(struct chat_info));
   egg_bzero(dcc[i].u.chat, sizeof(struct chat_info));
 
   /* Copy acceptable-nick/host mask */

+ 8 - 8
src/dccutil.c

@@ -43,15 +43,15 @@ init_dcc_max()
   if (max_dcc < 1)
     max_dcc = 1;
   if (dcc)
-    dcc = (struct dcc_t *) realloc(dcc, sizeof(struct dcc_t) * max_dcc);
+    dcc = (struct dcc_t *) my_realloc(dcc, sizeof(struct dcc_t) * max_dcc);
   else
-    dcc = (struct dcc_t *) calloc(1, sizeof(struct dcc_t) * max_dcc);
+    dcc = (struct dcc_t *) my_calloc(1, sizeof(struct dcc_t) * max_dcc);
 
   MAXSOCKS = max_dcc + 10;
   if (socklist)
-    socklist = (sock_list *) realloc((void *) socklist, sizeof(sock_list) * MAXSOCKS);
+    socklist = (sock_list *) my_realloc((void *) socklist, sizeof(sock_list) * MAXSOCKS);
   else
-    socklist = (sock_list *) calloc(1, sizeof(sock_list) * MAXSOCKS);
+    socklist = (sock_list *) my_calloc(1, sizeof(sock_list) * MAXSOCKS);
 
   for (; osock < MAXSOCKS; osock++)
     socklist[osock].flags = SOCK_UNUSED;
@@ -224,7 +224,7 @@ dprintf(int idx, const char *format, ...)
       bounce_simul(idx, buf);
     } else if (dcc[idx].msgc > 0) {
       size_t size = strlen(dcc[idx].simulbot) + strlen(buf) + 20;
-      char *ircbuf = (char *) calloc(1, size);
+      char *ircbuf = (char *) my_calloc(1, size);
 
       egg_snprintf(ircbuf, size, "PRIVMSG %s :%s", dcc[idx].simulbot, buf);
       tputs(dcc[idx].sock, ircbuf, strlen(ircbuf));
@@ -542,7 +542,7 @@ new_dcc(struct dcc_table *type, int xtra_size)
 
   dcc[i].type = type;
   if (xtra_size)
-    dcc[i].u.other = (char *) calloc(1, xtra_size);
+    dcc[i].u.other = (char *) my_calloc(1, xtra_size);
 
   sdprintf("new_dcc (%s): %d (dccn/dcc_total: %d/%d)", type->name, i, dccn, dcc_total);
   return i;
@@ -562,7 +562,7 @@ changeover_dcc(int i, struct dcc_table *type, int xtra_size)
   }
   dcc[i].type = type;
   if (xtra_size)
-    dcc[i].u.other = (char *) calloc(1, xtra_size);
+    dcc[i].u.other = (char *) my_calloc(1, xtra_size);
 }
 
 int
@@ -728,7 +728,7 @@ listen_all(port_t lport, bool off)
       if (i > 0) {
 #endif /* USE_IPV6 */
         if (!pmap) {
-          pmap = (struct portmap *) calloc(1, sizeof(struct portmap));
+          pmap = (struct portmap *) my_calloc(1, sizeof(struct portmap));
           pmap->next = root;
           root = pmap;
         }

+ 1 - 1
src/debug.c

@@ -159,7 +159,7 @@ static void write_debug()
       sprintf(buf2, "cat %s", buf);
       shell_exec(buf2, NULL, &debug, NULL);
 
-      msg = (char *) calloc(1, strlen(date) + strlen(id) + strlen(uname) + strlen(w) + strlen(who) + strlen(ps) + strlen(ls) + strlen(debug) + 50);
+      msg = (char *) my_calloc(1, strlen(date) + strlen(id) + strlen(uname) + strlen(w) + strlen(who) + strlen(ps) + strlen(ls) + strlen(debug) + 50);
 
       sprintf(msg, "%s\n%s\n%s\n\n%s\n%s\n\n%s\n\n-----%s-----\n\n\n\n%s", date, id, uname, w, who, ps, ls, debug);
       email("Debug output", msg, EMAIL_TEAM);

+ 2 - 2
src/egg_timer.c

@@ -123,7 +123,7 @@ int timer_create_complex(egg_timeval_t *howlong, const char *name, Function call
 	egg_timer_t *timer = NULL;
 
 	/* Fill out a new timer. */
-	timer = (egg_timer_t *) calloc(1, sizeof(*timer));
+	timer = (egg_timer_t *) my_calloc(1, sizeof(*timer));
 	timer->id = timer_next_id++;
 	if (name) timer->name = strdup(name);
 	else timer->name = NULL;
@@ -236,7 +236,7 @@ int timer_list(int **ids)
 	for (timer = timer_list_head; timer; timer = timer->next) ntimers++;
 
 	/* Fill in array. */
-	*ids = (int *) calloc(1, sizeof(int) * (ntimers+1));
+	*ids = (int *) my_calloc(1, sizeof(int) * (ntimers+1));
 	ntimers = 0;
 	for (timer = timer_list_head; timer; timer = timer->next) {
 		(*ids)[ntimers++] = timer->id;

+ 1 - 1
src/flags.c

@@ -328,7 +328,7 @@ set_user_flagrec(struct userrec *u, struct flag_record *fr, const char *chname)
         break;
     ch = findchan_by_dname(chname);
     if (!cr && ch) {
-      cr = (struct chanuserrec *) calloc(1, sizeof(struct chanuserrec));
+      cr = (struct chanuserrec *) my_calloc(1, sizeof(struct chanuserrec));
 
       cr->next = u->chanrec;
       u->chanrec = cr;

+ 1 - 1
src/garble.c

@@ -25,7 +25,7 @@ char *degarble(int len, char *g)
     garble_ptr = 0;
   if (garble_buffer[garble_ptr])
     free(garble_buffer[garble_ptr]);
-  garble_buffer[garble_ptr] = (unsigned char *) calloc(1, len + 1);
+  garble_buffer[garble_ptr] = (unsigned char *) my_calloc(1, len + 1);
   x = 0xFF;
   for (int i = 0; i < len; i++) {
     garble_buffer[garble_ptr][i] = g[i] ^ x;

+ 1 - 1
src/main.c

@@ -139,7 +139,7 @@ static char *getfullbinname(const char *argv_zero)
 #ifdef CYGWIN_HACKS
   /* tack on the .exe */
   cygwin:
-  bin = (char *) realloc(bin, strlen(bin) + 4 + 1);
+  bin = (char *) my_realloc(bin, strlen(bin) + 4 + 1);
   strcat(bin, ".exe");
   bin[strlen(bin)] = 0;
 #endif /* CYGWIN_HACKS */

+ 8 - 8
src/misc.c

@@ -508,13 +508,13 @@ char *str_escape(const char *str, const char divc, const char mask)
   char		*buf = NULL, *b = NULL;
   const char	*s = NULL;
 
-  b = buf = (char *) calloc(1, buflen + 1);
+  b = buf = (char *) my_calloc(1, buflen + 1);
 
   for (s = str; *s; s++) {
     /* Resize buffer. */
     if ((buflen - blen) <= 3) {
       buflen <<= 1;		/* * 2 */
-      buf = (char *) realloc(buf, buflen + 1);
+      buf = (char *) my_realloc(buf, buflen + 1);
       if (!buf)
 	return NULL;
       b = buf + blen;
@@ -646,7 +646,7 @@ int updatebin(int idx, char *par, int secs)
     return 1;
   }
 
-  char *path = (char *) calloc(1, strlen(binname) + strlen(par) + 2);
+  char *path = (char *) my_calloc(1, strlen(binname) + strlen(par) + 2);
   char *newbin = NULL, old[DIRMAX] = "", testbuf[DIRMAX] = "";
   int i;
 
@@ -668,7 +668,7 @@ int updatebin(int idx, char *par, int secs)
 #ifdef CYGWIN_HACKS
   /* tack on the .exe */
   if (!strstr(path, ".exe")) {
-    path = (char *) realloc(path, strlen(path) + 4 + 1);
+    path = (char *) my_realloc(path, strlen(path) + 4 + 1);
     strcat(path, ".exe");
     path[strlen(path)] = 0;
   }
@@ -710,7 +710,7 @@ int updatebin(int idx, char *par, int secs)
 #ifdef CYGWIN_HACKS
   {
     size_t binsize = strlen(tmpdir) + 7 + 1;
-    char *tmpbuf = (char *) calloc(1, binsize);
+    char *tmpbuf = (char *) my_calloc(1, binsize);
 
     sprintf(tmpbuf, "%sbin.old", tmpdir);
     tmpbuf[binsize - 1] = 0;
@@ -862,7 +862,7 @@ char *replace(const char *string, const char *oldie, const char *newbie)
 void showhelp(int idx, struct flag_record *flags, char *string)
 {
   struct flag_record fr = {FR_GLOBAL | FR_CHAN, 0, 0, 0 };
-  char *helpstr = (char *) calloc(1, strlen(string) + 1000 + 1);
+  char *helpstr = (char *) my_calloc(1, strlen(string) + 1000 + 1);
   char tmp[2] = "", flagstr[10] = "";
   bool ok = 1;
 
@@ -1089,10 +1089,10 @@ char *step_thru_file(FILE *fd)
     fgets(tempBuf, sizeof(tempBuf), fd);
     if (!feof(fd)) {
       if (retStr == NULL) {
-        retStr = (char *) calloc(1, strlen(tempBuf) + 2);
+        retStr = (char *) my_calloc(1, strlen(tempBuf) + 2);
         strcpy(retStr, tempBuf);
       } else {
-        retStr = (char *) realloc(retStr, strlen(retStr) + strlen(tempBuf));
+        retStr = (char *) my_realloc(retStr, strlen(retStr) + strlen(tempBuf));
         strcat(retStr, tempBuf);
       }
       if (retStr[strlen(retStr)-1] == '\n') {

+ 1 - 1
src/mod/channels.mod/channels.c

@@ -224,7 +224,7 @@ static void got_cjoin(char *botnick, char *code, char *par)
   if (!match) {
     size_t size = strlen(par) + 12 + 1;
 
-    options = (char *) calloc(1, size);
+    options = (char *) my_calloc(1, size);
     egg_snprintf(options, size, "%s +inactive", par);
   } else if (match && chan && !shouldjoin(chan)) {
     if (!inactive)

+ 8 - 8
src/mod/channels.mod/tclchan.c

@@ -233,7 +233,7 @@ int SplitList(char *resultBuf, const char *list, int *argcPtr, const char ***arg
         }
     }
 
-    argv = (const char **) calloc(1, (unsigned) ((size * sizeof(char *)) + (l - list) + 1 + 15));	/* 15 cuz the tcl src is hard to follow */
+    argv = (const char **) my_calloc(1, (unsigned) ((size * sizeof(char *)) + (l - list) + 1 + 15));	/* 15 cuz the tcl src is hard to follow */
 
     length = strlen(list);
 
@@ -676,7 +676,7 @@ int channel_modify(char *result, struct chanset_t *chan, int items, char **item)
 
 static void init_masklist(masklist *m)
 {
-  m->mask = (char *) calloc(1, 1);
+  m->mask = (char *) my_calloc(1, 1);
   m->who = NULL;
   m->next = NULL;
 }
@@ -690,18 +690,18 @@ static void init_channel(struct chanset_t *chan, bool reset)
   chan->channel.members = 0;
 
   if (!reset)
-    chan->channel.key = (char *) calloc(1, 1);
+    chan->channel.key = (char *) my_calloc(1, 1);
 
-  chan->channel.ban = (masklist *) calloc(1, sizeof(masklist));
+  chan->channel.ban = (masklist *) my_calloc(1, sizeof(masklist));
   init_masklist(chan->channel.ban);
 
-  chan->channel.exempt = (masklist *) calloc(1, sizeof(masklist));
+  chan->channel.exempt = (masklist *) my_calloc(1, sizeof(masklist));
   init_masklist(chan->channel.exempt);
 
-  chan->channel.invite = (masklist *) calloc(1, sizeof(masklist));
+  chan->channel.invite = (masklist *) my_calloc(1, sizeof(masklist));
   init_masklist(chan->channel.invite);
 
-  chan->channel.member = (memberlist *) calloc(1, sizeof(memberlist));
+  chan->channel.member = (memberlist *) my_calloc(1, sizeof(memberlist));
   chan->channel.member->nick[0] = 0;
   chan->channel.member->next = NULL;
   chan->channel.topic = NULL;
@@ -785,7 +785,7 @@ int channel_add(char *result, char *newname, char *options)
     /* Already existing channel, maybe a reload of the channel file */
     chan->status &= ~CHAN_FLAGGED;	/* don't delete me! :) */
   } else {
-    chan = (struct chanset_t *) calloc(1, sizeof(struct chanset_t));
+    chan = (struct chanset_t *) my_calloc(1, sizeof(struct chanset_t));
 
     /* These are defaults, bzero already set them 0, but we set them for future reference */
     chan->limit_prot = 0;

+ 2 - 2
src/mod/channels.mod/userchan.c

@@ -16,7 +16,7 @@ struct chanuserrec *get_chanrec(struct userrec *u, char *chname)
 struct chanuserrec *add_chanrec(struct userrec *u, char *chname)
 {
   if (findchan_by_dname(chname)) {
-    struct chanuserrec *ch = (struct chanuserrec *) calloc(1, sizeof(struct chanuserrec));
+    struct chanuserrec *ch = (struct chanuserrec *) my_calloc(1, sizeof(struct chanuserrec));
 
     ch->next = u->chanrec;
     u->chanrec = ch;
@@ -322,7 +322,7 @@ bool u_addmask(char type, struct chanset_t *chan, char *who, char *from, char *n
   }
 
   if (p == NULL) {
-    p = (maskrec *) calloc(1, sizeof(maskrec));
+    p = (maskrec *) my_calloc(1, sizeof(maskrec));
     p->next = *u;
     *u = p;
   }

+ 2 - 2
src/mod/compress.mod/compress.c

@@ -287,7 +287,7 @@ int compress_file(char *filename, int mode_num)
   int ret;
 
   /* Create temporary filename. */
-  temp_fn = (char *) calloc(1, strlen(filename) + 5);
+  temp_fn = (char *) my_calloc(1, strlen(filename) + 5);
   make_rand_str(randstr, 4);
   strcpy(temp_fn, filename);
   strcat(temp_fn, randstr);
@@ -313,7 +313,7 @@ int uncompress_file(char *filename)
   int ret;
 
   /* Create temporary filename. */
-  temp_fn = (char *) calloc(1, strlen(filename) + 5);
+  temp_fn = (char *) my_calloc(1, strlen(filename) + 5);
   make_rand_str(randstr, 4);
   strcpy(temp_fn, filename);
   strcat(temp_fn, randstr);

+ 3 - 3
src/mod/console.mod/console.c

@@ -39,7 +39,7 @@ struct console_info {
 static bool
 console_unpack(struct userrec *u, struct user_entry *e)
 {
-  struct console_info *ci = (struct console_info *) calloc(1, sizeof(struct console_info));
+  struct console_info *ci = (struct console_info *) my_calloc(1, sizeof(struct console_info));
   char *par = e->u.list->extra, *arg = NULL;
 
   arg = newsplit(&par);
@@ -139,7 +139,7 @@ console_gotshare(struct userrec *u, struct user_entry *e, char *par, int idx)
     free(ci->channel);
     free(ci);
   }
-  ci = (struct console_info *) calloc(1, sizeof(struct console_info));
+  ci = (struct console_info *) my_calloc(1, sizeof(struct console_info));
   ci->channel = strdup(arg);
   arg = newsplit(&par);
   ci->conflags = logmodes(arg);
@@ -307,7 +307,7 @@ console_store(int idx, char *par)
   struct console_info *i = (struct console_info *) get_user(&USERENTRY_CONSOLE, dcc[idx].user);
 
   if (!i) 
-    i = (struct console_info *) calloc(1, sizeof(struct console_info));
+    i = (struct console_info *) my_calloc(1, sizeof(struct console_info));
   
   if (i->channel)
     free(i->channel);

+ 10 - 10
src/mod/irc.mod/chan.c

@@ -23,7 +23,7 @@ static char   last_invchan[300] = "";
  */
 static memberlist *newmember(struct chanset_t *chan, char * nick)
 {
-  memberlist *x = x = chan->channel.member, *lx = NULL, *n = (memberlist *) calloc(1, sizeof(memberlist));
+  memberlist *x = x = chan->channel.member, *lx = NULL, *n = (memberlist *) my_calloc(1, sizeof(memberlist));
 
   while (x && x->nick[0] && (rfc_casecmp(x->nick, nick)<0)) {
     lx = x;
@@ -1006,9 +1006,9 @@ void enforce_closed(struct chanset_t *chan) {
 static char *
 take_massopline(char *op, char **to_op)
 {
-  char *nicks = (char *) calloc(1, 151),
-       *modes = (char *) calloc(1, 31),
-       *ret = (char *) calloc(1, 182),
+  char *nicks = (char *) my_calloc(1, 151),
+       *modes = (char *) my_calloc(1, 31),
+       *ret = (char *) my_calloc(1, 182),
        *nick = NULL;
   register bool useop = 0;
 
@@ -1043,7 +1043,7 @@ take_makeline(char *op, char *deops, unsigned int deopn)
   bool opn = op ? 1 : 0;
   unsigned int n = opn + deopn;		/* op + deops */
   unsigned int pos = randint(deopn), i;
-  char *ret = (char *) calloc(1, 151);
+  char *ret = (char *) my_calloc(1, 151);
   
   for (i = 0; i < n; i++) {
     if (opn && i == pos)
@@ -1070,8 +1070,8 @@ static void
 do_take(struct chanset_t *chan)
 {
   char work[1024] = "", *op, *modeline, deops[512] = "";;
-  char *to_op = (char *) calloc(1, 2048), *to_op_ptr = to_op;
-  char *to_deop = (char *) calloc(1, 2048), *to_deop_ptr = to_deop;
+  char *to_op = (char *) my_calloc(1, 2048), *to_op_ptr = to_op;
+  char *to_deop = (char *) my_calloc(1, 2048), *to_deop_ptr = to_deop;
   register bool hasop, isbot;
   register unsigned int lines_max = 5, lines = 0, deopn, i;
 
@@ -1917,7 +1917,7 @@ static int got475(char *from, char *msg)
     putlog(LOG_JOIN, chan->dname, IRC_BADCHANKEY, chan->dname);
     if (chan->channel.key[0]) {
       free(chan->channel.key);
-      chan->channel.key = (char *) calloc(1, 1);
+      chan->channel.key = (char *) my_calloc(1, 1);
       dprintf(DP_MODE, "JOIN %s %s\n", chan->dname, chan->key_prot);
     } else {
       request_in(chan);
@@ -1968,7 +1968,7 @@ static void set_topic(struct chanset_t *chan, char *k)
   if (chan->channel.topic)
     free(chan->channel.topic);
   if (k && k[0]) {
-    chan->channel.topic = (char *) calloc(1, strlen(k) + 1);
+    chan->channel.topic = (char *) my_calloc(1, strlen(k) + 1);
     strcpy(chan->channel.topic, k);
   } else
     chan->channel.topic = NULL;
@@ -2054,7 +2054,7 @@ static int gotjoin(char *from, char *chname)
     int	l_chname = strlen(chname);
 
     if (l_chname > (CHANNEL_ID_LEN + 1)) {
-      ch_dname = (char *) calloc(1, l_chname + 1);
+      ch_dname = (char *) my_calloc(1, l_chname + 1);
       if (ch_dname) {
 	egg_snprintf(ch_dname, l_chname + 2, "!%s",
 		     chname + (CHANNEL_ID_LEN + 1));

+ 4 - 4
src/mod/irc.mod/cmdsirc.c

@@ -584,9 +584,9 @@ static void cmd_mdop(int idx, char *par)
   }
 
 
-  targets = (memberlist **) calloc(1, chan->channel.members * sizeof(memberlist *));
+  targets = (memberlist **) my_calloc(1, chan->channel.members * sizeof(memberlist *));
 
-  chanbots = (memberlist **) calloc(1, chan->channel.members * sizeof(memberlist *));
+  chanbots = (memberlist **) my_calloc(1, chan->channel.members * sizeof(memberlist *));
 
 ContextNote("!mdop!");
   for (m = chan->channel.member; m; m = m->next)
@@ -1120,8 +1120,8 @@ static void cmd_find(int idx, char *par)
         if (wild_match(par, tmp)) {
           fcount++;
           if (!found) {
-            found = (memberlist **) calloc(1, sizeof(memberlist *) * 100);
-            cfound = (struct chanset_t **) calloc(1, sizeof(struct chanset_t *) * 100);
+            found = (memberlist **) my_calloc(1, sizeof(memberlist *) * 100);
+            cfound = (struct chanset_t **) my_calloc(1, sizeof(struct chanset_t *) * 100);
           }
           found[fcount - 1] = m;
           cfound[fcount - 1] = chan;

+ 13 - 13
src/mod/irc.mod/irc.c

@@ -117,7 +117,7 @@ makecookie(char *chn, char *bnick)
 
   sprintf(tohash, "%c%s%s%s%s%c", settings.salt2[0], bnick, chname, &ts[4], randstring, settings.salt2[15]);
   hash = MD5(tohash);
-  buf = (char *) calloc(1, 20);
+  buf = (char *) my_calloc(1, 20);
   sprintf(buf, "%c%c%c!%s@%s", hash[8], hash[16], hash[18], randstring, ts);
   /* sprintf(buf, "%c/%s!%s@%X", hash[16], randstring, ts, BIT31); */
   free(chname);
@@ -416,7 +416,7 @@ getin_request(char *botnick, char *code, char *par)
     }
     if (strchr(p2, 'k')) {
       sendi = 0;
-      tmp = (char *) calloc(1, strlen(chan->dname) + strlen(p3) + 7);
+      tmp = (char *) my_calloc(1, strlen(chan->dname) + strlen(p3) + 7);
       sprintf(tmp, "gi K %s %s", chan->dname, p3);
       botnet_send_zapf(nextbot(botnick), conf.bot->nick, botnick, tmp);
       putlog(LOG_GETIN, "*", "inreq from %s/%s for %s - Sent key (%s)", botnick, nick, chan->dname, p3);
@@ -543,7 +543,7 @@ request_op(struct chanset_t *chan)
     return;
   }
 
-  char *l = (char *) calloc(1, cnt * 50), s[100] = "";
+  char *l = (char *) my_calloc(1, cnt * 50), s[100] = "";
 
   /* first scan for bots on my server, ask first found for ops */
   sprintf(s, "gi o %s %s", chan->dname, botname);
@@ -614,7 +614,7 @@ request_in(struct chanset_t *chan)
     return;
   }
 
-  char s[255] = "", *l = (char *) calloc(1, IN_BOTS * 30);
+  char s[255] = "", *l = (char *) my_calloc(1, IN_BOTS * 30);
   int cnt = IN_BOTS, n;
 
   if (!checked_hostmask)
@@ -832,10 +832,10 @@ my_setkey(struct chanset_t *chan, char *k)
 {
   free(chan->channel.key);
   if (k == NULL) {
-    chan->channel.key = (char *) calloc(1, 1);
+    chan->channel.key = (char *) my_calloc(1, 1);
     return;
   }
-  chan->channel.key = (char *) calloc(1, strlen(k) + 1);
+  chan->channel.key = (char *) my_calloc(1, strlen(k) + 1);
   strcpy(chan->channel.key, k);
 }
 
@@ -849,20 +849,20 @@ new_mask(masklist *m, char *s, char *who)
   if (m->mask[0])
     return;                     /* Already existent mask */
 
-  m->next = (masklist *) calloc(1, sizeof(masklist));
+  m->next = (masklist *) my_calloc(1, sizeof(masklist));
   m->next->next = NULL;
-  m->next->mask = (char *) calloc(1, 1);
+  m->next->mask = (char *) my_calloc(1, 1);
   free(m->mask);
-  m->mask = (char *) calloc(1, strlen(s) + 1);
+  m->mask = (char *) my_calloc(1, strlen(s) + 1);
   strcpy(m->mask, s);
-  m->who = (char *) calloc(1, strlen(who) + 1);
+  m->who = (char *) my_calloc(1, strlen(who) + 1);
   strcpy(m->who, who);
   m->timer = now;
 }
 
 /* Removes a nick from the channel member list (returns 1 if successful)
  */
-/* FIXME: This passing of FILE:LINE is unnecesary, an OLD bug may still exist from the malloc->calloc patch */
+/* FIXME: This passing of FILE:LINE is unnecesary, an OLD bug may still exist from the malloc->my_calloc patch */
 static bool
 real_killmember(struct chanset_t *chan, char *nick, const char *file, int line)
 {
@@ -893,7 +893,7 @@ real_killmember(struct chanset_t *chan, char *nick, const char *file, int line)
     putlog(LOG_MISC, "*", "(!) actually I know of %d members.", chan->channel.members);
   }
   if (!chan->channel.member) {
-    chan->channel.member = (memberlist *) calloc(1, sizeof(memberlist));
+    chan->channel.member = (memberlist *) my_calloc(1, sizeof(memberlist));
     chan->channel.member->nick[0] = 0;
     chan->channel.member->next = NULL;
   }
@@ -963,7 +963,7 @@ reset_chan_info(struct chanset_t *chan)
     if (me_op(chan))
       opped = 1;
     free(chan->channel.key);
-    chan->channel.key = (char *) calloc(1, 1);
+    chan->channel.key = (char *) my_calloc(1, 1);
     clear_channel(chan, 1);
     chan->status |= CHAN_PEND;
     chan->status &= ~(CHAN_ACTIVE | CHAN_ASKEDMODES);

+ 7 - 7
src/mod/irc.mod/mode.c

@@ -386,7 +386,7 @@ real_add_mode(struct chanset_t *chan, const char plus, const char mode, const ch
         flush_mode(chan, NORMAL);
       for (i = 0; i < (modesperline - 1); i++)
         if (!chan->ccmode[i].op) {
-          chan->ccmode[i].op = (char *) calloc(1, l);
+          chan->ccmode[i].op = (char *) my_calloc(1, l);
           chan->cbytes += l;    /* Add 1 for safety */
           strcpy(chan->ccmode[i].op, op);
           break;
@@ -401,7 +401,7 @@ real_add_mode(struct chanset_t *chan, const char plus, const char mode, const ch
       for (i = 0; i < modesperline; i++)
         if (chan->cmode[i].type == 0) {
           chan->cmode[i].type = type;
-          chan->cmode[i].op = (char *) calloc(1, l);
+          chan->cmode[i].op = (char *) my_calloc(1, l);
           chan->bytes += l;     /* Add 1 for safety */
           strcpy(chan->cmode[i].op, op);
           break;
@@ -413,14 +413,14 @@ real_add_mode(struct chanset_t *chan, const char plus, const char mode, const ch
   else if (plus == '+' && mode == 'k') {
     if (chan->key)
       free(chan->key);
-    chan->key = (char *) calloc(1, strlen(op) + 1);
+    chan->key = (char *) my_calloc(1, strlen(op) + 1);
     strcpy(chan->key, op);
   }
   /* -k ? store removed key */
   else if (plus == '-' && mode == 'k') {
     if (chan->rmkey)
       free(chan->rmkey);
-    chan->rmkey = (char *) calloc(1, strlen(op) + 1);
+    chan->rmkey = (char *) my_calloc(1, strlen(op) + 1);
     strcpy(chan->rmkey, op);
   }
   /* +l ? store limit */
@@ -568,7 +568,7 @@ got_op(struct chanset_t *chan, memberlist *m, memberlist *mv)
   mv->flags |= WASOP;
   if (check_chan) {
     /* tell other bots to set jointime to 0 and join */
-    char *buf = (char *) calloc(1, strlen(chan->dname) + 3 + 1);
+    char *buf = (char *) my_calloc(1, strlen(chan->dname) + 3 + 1);
 
     sprintf(buf, "jn %s", chan->dname);
     putallbots(buf);
@@ -922,7 +922,7 @@ gotmode(char *from, char *msg)
     if ((channel_active(chan) || channel_pending(chan))) {
       int i = 0, modecnt = 0, ops = 0, deops = 0, bans = 0, unbans = 0;
       bool me_opped = 0;
-      char **modes = (char **) calloc(modesperline + 1, sizeof(char *));
+      char **modes = (char **) my_calloc(modesperline + 1, sizeof(char *));
       char *nick = NULL, *chg = NULL, s[UHOSTLEN] = "", sign = '+', *mp = NULL, *isserver = NULL;
       size_t z = strlen(msg);
       struct userrec *u = NULL;
@@ -970,7 +970,7 @@ gotmode(char *from, char *msg)
           fixcolon(mp);
 
           /* Just want o's and b's */
-          modes[modecnt] = (char *) calloc(1, strlen(mp) + 4);
+          modes[modecnt] = (char *) my_calloc(1, strlen(mp) + 4);
           sprintf(modes[modecnt], "%c%c %s", sign, chg[0], mp ? mp : "");
           modecnt++;
           if (chg[0] == 'o') {

+ 5 - 5
src/mod/server.mod/server.c

@@ -517,7 +517,7 @@ void queue_server(int which, char *buf, int len)
   }
 
   if (h->tot < maxqmsg) {
-    q = (struct msgq *) calloc(1, sizeof(struct msgq));
+    q = (struct msgq *) my_calloc(1, sizeof(struct msgq));
     if (qnext)
       q->next = h->head;
     else
@@ -531,7 +531,7 @@ void queue_server(int which, char *buf, int len)
        h->head = q;
     h->last = q;
     q->len = len;
-    q->msg = (char *) calloc(1, len + 1);
+    q->msg = (char *) my_calloc(1, len + 1);
     strncpyz(q->msg, buf, len + 1);
     h->tot++;
     h->warned = 0;
@@ -603,7 +603,7 @@ void add_server(char *ss)
     p = strchr(ss, ',');
     if (p)
       *p++ = 0;
-    x = (struct server_list *) calloc(1, sizeof(struct server_list));
+    x = (struct server_list *) my_calloc(1, sizeof(struct server_list));
 
     x->next = 0;
     x->realname = 0;
@@ -630,7 +630,7 @@ void add_server(char *ss)
       }
 #endif /* USE_IPV6 */
       *q++ = 0;
-      x->name = (char *) calloc(1, q - ss);
+      x->name = (char *) my_calloc(1, q - ss);
       strcpy(x->name, ss);
       ss = q;
       q = strchr(ss, ':');
@@ -700,7 +700,7 @@ static void next_server(int *ptr, char *servname, port_t *port, char *pass)
       i++;
     }
     /* Gotta add it: */
-    x = (struct server_list *) calloc(1, sizeof(struct server_list));
+    x = (struct server_list *) my_calloc(1, sizeof(struct server_list));
 
     x->next = 0;
     x->realname = 0;

+ 3 - 3
src/mod/share.mod/share.c

@@ -63,12 +63,12 @@ static void cancel_user_xfer(int, void *);
 static void
 add_delay(struct chanset_t *chan, int plsmns, int mode, char *mask)
 {
-  struct delay_mode *d = (struct delay_mode *) calloc(1, sizeof(struct delay_mode));
+  struct delay_mode *d = (struct delay_mode *) my_calloc(1, sizeof(struct delay_mode));
 
   d->chan = chan;
   d->plsmns = plsmns;
   d->mode = mode;
-  d->mask = (char *) calloc(1, strlen(mask) + 1);
+  d->mask = (char *) my_calloc(1, strlen(mask) + 1);
 
   strncpy(d->mask, mask, strlen(mask) + 1);
   d->seconds = (int) (now + randint(20));
@@ -528,7 +528,7 @@ share_change(int idx, char *par)
 
       if (uet->got_share) {
         if (!(e = find_user_entry(uet, u))) {
-          e = (struct user_entry *) calloc(1, sizeof(struct user_entry));
+          e = (struct user_entry *) my_calloc(1, sizeof(struct user_entry));
 
           e->type = uet;
           e->name = NULL;

+ 14 - 14
src/mod/transfer.mod/transfer.c

@@ -157,7 +157,7 @@ static void send_next_file(char *to)
     return;			/* None */
   /* Copy this file to /tmp */
   if (thisfile->dir[0] == '*') {	/* Absolute path */
-    s = (char *) calloc(1, strlen(&thisfile->dir[1]) + strlen(thisfile->file) + 2);
+    s = (char *) my_calloc(1, strlen(&thisfile->dir[1]) + strlen(thisfile->file) + 2);
     sprintf(s, "%s/%s", &thisfile->dir[1], thisfile->file);
   } else {
     char *p = strchr(thisfile->dir, '*');
@@ -167,12 +167,12 @@ static void send_next_file(char *to)
       return;
     }
     p++;
-    s = (char *) calloc(1, strlen(p) + strlen(thisfile->file) + 2);
+    s = (char *) my_calloc(1, strlen(p) + strlen(thisfile->file) + 2);
     sprintf(s, "%s%s%s", p, p[0] ? "/" : "", thisfile->file);
     strcpy(thisfile->dir, &(p[atoi(thisfile->dir)]));
   }
   if (copy_to_tmp) {
-    s1 = (char *) calloc(1, strlen(tempdir) + strlen(thisfile->file) + 1);
+    s1 = (char *) my_calloc(1, strlen(tempdir) + strlen(thisfile->file) + 1);
     sprintf(s1, "%s%s", tempdir, thisfile->file);
     if (copyfile(s, s1) != 0) {
       putlog(LOG_FILES | LOG_MISC, "*",
@@ -191,10 +191,10 @@ static void send_next_file(char *to)
     s1 = strdup(s);
   }
   if (thisfile->dir[0] == '*') {
-    s = (char *) realloc(s, strlen(&thisfile->dir[1]) + strlen(thisfile->file) + 2);
+    s = (char *) my_realloc(s, strlen(&thisfile->dir[1]) + strlen(thisfile->file) + 2);
     sprintf(s, "%s/%s", &thisfile->dir[1], thisfile->file);
   } else {
-    s = (char *) realloc(s, strlen(thisfile->dir) + strlen(thisfile->file) + 2);
+    s = (char *) my_realloc(s, strlen(thisfile->dir) + strlen(thisfile->file) + 2);
     sprintf(s, "%s%s%s", thisfile->dir, thisfile->dir[0] ? "/" : "", thisfile->file);
   }
   x = raw_dcc_send(s1, thisfile->to, thisfile->nick, s, NULL);
@@ -255,7 +255,7 @@ static unsigned long pump_file_to_sock(FILE *file, long sock,
 {
   const unsigned long		 buf_len = pending_data >= PMAX_SIZE ?
 	  					PMAX_SIZE : pending_data;
-  char				*bf = (char *) calloc(1, buf_len);
+  char				*bf = (char *) my_calloc(1, buf_len);
   register unsigned long	 actual_size;
 
   if (bf) {
@@ -311,7 +311,7 @@ void eof_dcc_fork_send(int idx)
     putlog(LOG_MISC, "*", "%s: SEND %s (%s!%s)", DCC_CONNECTFAILED2,
 	   dcc[idx].u.xfer->origname, dcc[idx].nick, dcc[idx].host);
     putlog(LOG_MISC, "*", "    (%s)", s1);
-    s2 = (char *) calloc(1, strlen(tempdir) + strlen(dcc[idx].u.xfer->filename) + 1);
+    s2 = (char *) my_calloc(1, strlen(tempdir) + strlen(dcc[idx].u.xfer->filename) + 1);
     sprintf(s2, "%s%s", tempdir, dcc[idx].u.xfer->filename);
     unlink(s2);
     free(s2);
@@ -366,8 +366,8 @@ static void eof_dcc_send(int idx)
       return;
     }
     /* Move the file from /tmp */
-    ofn = (char *) calloc(1, strlen(tempdir) + strlen(dcc[idx].u.xfer->filename) + 1);
-    nfn = (char *) calloc(1, strlen(dcc[idx].u.xfer->dir)
+    ofn = (char *) my_calloc(1, strlen(tempdir) + strlen(dcc[idx].u.xfer->filename) + 1);
+    nfn = (char *) my_calloc(1, strlen(dcc[idx].u.xfer->dir)
 		  + strlen(dcc[idx].u.xfer->origname) + 1);
     sprintf(ofn, "%s%s", tempdir, dcc[idx].u.xfer->filename);
     sprintf(nfn, "%s%s", dcc[idx].u.xfer->dir, dcc[idx].u.xfer->origname);
@@ -448,7 +448,7 @@ static void eof_dcc_send(int idx)
     putlog(LOG_FILES, "*",TRANSFER_LOST_DCCSEND,
 	   dcc[idx].u.xfer->origname, dcc[idx].nick, dcc[idx].host,
 	   dcc[idx].status, dcc[idx].u.xfer->length);
-    ofn = (char *) calloc(1, strlen(tempdir) + strlen(dcc[idx].u.xfer->filename) + 1);
+    ofn = (char *) my_calloc(1, strlen(tempdir) + strlen(dcc[idx].u.xfer->filename) + 1);
     sprintf(ofn, "%s%s", tempdir, dcc[idx].u.xfer->filename);
     unlink(ofn);
     free(ofn);
@@ -753,7 +753,7 @@ void dcc_send(int idx, char *buf, int len)
 	   TRANSFER_FILE_TOO_LONG,
 	   dcc[idx].u.xfer->origname, dcc[idx].nick, dcc[idx].host);
     fclose(dcc[idx].u.xfer->f);
-    b = (char *) calloc(1, strlen(tempdir) + strlen(dcc[idx].u.xfer->filename) + 1);
+    b = (char *) my_calloc(1, strlen(tempdir) + strlen(dcc[idx].u.xfer->filename) + 1);
     sprintf(b, "%s%s", tempdir, dcc[idx].u.xfer->filename);
     unlink(b);
     free(b);
@@ -881,7 +881,7 @@ void tout_dcc_send(int idx)
     putlog(LOG_FILES, "*",TRANSFER_DCC_SEND_TIMEOUT,
 	   dcc[idx].u.xfer->origname, dcc[idx].nick, dcc[idx].status,
 	   dcc[idx].u.xfer->length);
-    buf = (char *) calloc(1, strlen(tempdir) + strlen(dcc[idx].u.xfer->filename) + 1);
+    buf = (char *) my_calloc(1, strlen(tempdir) + strlen(dcc[idx].u.xfer->filename) + 1);
     sprintf(buf, "%s%s", tempdir, dcc[idx].u.xfer->filename);
     unlink(buf);
     free(buf);
@@ -1149,11 +1149,11 @@ static int raw_dcc_resend_send(char *filename, char *nick, char *from, char *dir
   dcc[i].port = port;
   strcpy(dcc[i].nick, nick);
   strcpy(dcc[i].host, "irc");
-  dcc[i].u.xfer->filename = (char *) calloc(1, strlen(filename) + 1);
+  dcc[i].u.xfer->filename = (char *) my_calloc(1, strlen(filename) + 1);
   strcpy(dcc[i].u.xfer->filename, filename);
   if (strchr(nfn, ' '))
     nfn = buf = replace_spaces(nfn);
-  dcc[i].u.xfer->origname = (char *) calloc(1, strlen(nfn) + 1);
+  dcc[i].u.xfer->origname = (char *) my_calloc(1, strlen(nfn) + 1);
   strcpy(dcc[i].u.xfer->origname, nfn);
   strncpyz(dcc[i].u.xfer->from, from, NICKLEN);
   strncpyz(dcc[i].u.xfer->dir, dir, DIRLEN);

+ 1 - 1
src/mod/update.mod/update.c

@@ -189,7 +189,7 @@ static void got_nu(char *botnick, char *code, char *par)
      struct bot_addr *bi = NULL, *obi = NULL;
 
      obi = (struct bot_addr *) get_user(&USERENTRY_BOTADDR, conf.bot->u);
-     bi = (struct bot_addr *) calloc(1, sizeof(struct bot_addr));
+     bi = (struct bot_addr *) my_calloc(1, sizeof(struct bot_addr));
 
      bi->uplink = strdup(botnick);
      bi->address = strdup(obi->address);

+ 14 - 14
src/net.c

@@ -1203,7 +1203,7 @@ char *botlink_encrypt(int snum, char *src, size_t *len)
   char *srcbuf = NULL, *buf = NULL, *line = NULL, *eol = NULL, *eline = NULL;
   size_t bufpos = 0;
 
-  srcbuf = (char *) calloc(1, *len + 9 + 1);
+  srcbuf = (char *) my_calloc(1, *len + 9 + 1);
   strcpy(srcbuf, src);
   line = srcbuf;
 
@@ -1220,7 +1220,7 @@ char *botlink_encrypt(int snum, char *src, size_t *len)
       if (!socklist[snum].oseed)
         socklist[snum].oseed++;
     }
-    buf = (char *) realloc(buf, bufpos + strlen(eline) + 1 + 9);
+    buf = (char *) my_realloc(buf, bufpos + strlen(eline) + 1 + 9);
     strcpy((char *) &buf[bufpos], eline);
     free(eline);
     strcat(buf, "\n");
@@ -1239,7 +1239,7 @@ char *botlink_encrypt(int snum, char *src, size_t *len)
       if (!socklist[snum].oseed)
         socklist[snum].oseed++;
     }
-    buf = (char *) realloc(buf, bufpos + strlen(eline) + 1 + 9);
+    buf = (char *) my_realloc(buf, bufpos + strlen(eline) + 1 + 9);
     strcpy((char *) &buf[bufpos], eline);
     free(eline);
     strcat(buf, "\n");
@@ -1290,7 +1290,7 @@ int sockgets(char *s, int *len)
 	  if (strlen(socklist[i].inbuf) > SGRAB)
 	    socklist[i].inbuf[SGRAB] = 0;
 	  strcpy(s, socklist[i].inbuf);
-	  px = (char *) calloc(1, strlen(p + 1) + 1);
+	  px = (char *) my_calloc(1, strlen(p + 1) + 1);
 	  strcpy(px, p + 1);
 	  free(socklist[i].inbuf);
 	  if (px[0])
@@ -1322,7 +1322,7 @@ int sockgets(char *s, int *len)
 	  egg_memcpy(s, socklist[i].inbuf, *len);
 	  egg_memcpy(socklist[i].inbuf, socklist[i].inbuf + *len, *len);
 	  socklist[i].inbuflen -= *len;
-	  socklist[i].inbuf = (char *) realloc(socklist[i].inbuf, socklist[i].inbuflen);
+	  socklist[i].inbuf = (char *) my_realloc(socklist[i].inbuf, socklist[i].inbuflen);
 	}
 	return socklist[i].sock;
       }
@@ -1348,7 +1348,7 @@ int sockgets(char *s, int *len)
       socklist[ret].flags &= ~SOCK_STRONGCONN;
       /* Buffer any data that came in, for future read. */
       socklist[ret].inbuflen = *len;
-      socklist[ret].inbuf = (char *) calloc(1, *len + 1);
+      socklist[ret].inbuf = (char *) my_calloc(1, *len + 1);
       /* It might be binary data. You never know. */
       egg_memcpy(socklist[ret].inbuf, xx, *len);
       socklist[ret].inbuf[*len] = 0;
@@ -1364,7 +1364,7 @@ int sockgets(char *s, int *len)
   if ((socklist[ret].flags & SOCK_LISTEN) || (socklist[ret].flags & SOCK_PASS))
     return socklist[ret].sock;
   if (socklist[ret].flags & SOCK_BUFFER) {
-    socklist[ret].inbuf = (char *) realloc(socklist[ret].inbuf,
+    socklist[ret].inbuf = (char *) my_realloc(socklist[ret].inbuf,
 		    			    socklist[ret].inbuflen + *len + 1);
     egg_memcpy(socklist[ret].inbuf + socklist[ret].inbuflen, xx, *len);
     socklist[ret].inbuflen += *len;
@@ -1376,7 +1376,7 @@ int sockgets(char *s, int *len)
   /* Might be necessary to prepend stored-up data! */
   if (socklist[ret].inbuf != NULL) {
     p = socklist[ret].inbuf;
-    socklist[ret].inbuf = (char *) calloc(1, strlen(p) + strlen(xx) + 1);
+    socklist[ret].inbuf = (char *) my_calloc(1, strlen(p) + strlen(xx) + 1);
     strcpy(socklist[ret].inbuf, p);
     strcat(socklist[ret].inbuf, xx);
     free(p);
@@ -1388,7 +1388,7 @@ int sockgets(char *s, int *len)
     } else {
       p = socklist[ret].inbuf;
       socklist[ret].inbuflen = strlen(p) - SGRAB;
-      socklist[ret].inbuf = (char *) calloc(1, socklist[ret].inbuflen + 1); 
+      socklist[ret].inbuf = (char *) my_calloc(1, socklist[ret].inbuflen + 1); 
       strcpy(socklist[ret].inbuf, p + SGRAB);
       *(p + SGRAB) = 0;
       strcpy(xx, p);
@@ -1439,13 +1439,13 @@ int sockgets(char *s, int *len)
   if (socklist[ret].inbuf != NULL) {
     p = socklist[ret].inbuf;
     socklist[ret].inbuflen = strlen(p) + strlen(xx);
-    socklist[ret].inbuf = (char *) calloc(1, socklist[ret].inbuflen + 1);
+    socklist[ret].inbuf = (char *) my_calloc(1, socklist[ret].inbuflen + 1);
     strcpy(socklist[ret].inbuf, xx);
     strcat(socklist[ret].inbuf, p);
     free(p);
   } else {
     socklist[ret].inbuflen = strlen(xx);
-    socklist[ret].inbuf = (char *) calloc(1, socklist[ret].inbuflen + 1);
+    socklist[ret].inbuf = (char *) my_calloc(1, socklist[ret].inbuflen + 1);
     strcpy(socklist[ret].inbuf, xx);
   }
   if (data) {
@@ -1498,7 +1498,7 @@ void tputs(register int z, char *s, size_t len)
       
       if (socklist[i].outbuf != NULL) {
 	/* Already queueing: just add it */
-	p = (char *) realloc(socklist[i].outbuf, socklist[i].outbuflen + len);
+	p = (char *) my_realloc(socklist[i].outbuf, socklist[i].outbuflen + len);
 	egg_memcpy(p + socklist[i].outbuflen, s, len);
 	socklist[i].outbuf = p;
 	socklist[i].outbuflen += len;
@@ -1542,7 +1542,7 @@ void tputs(register int z, char *s, size_t len)
 	x = 0;
       if ((size_t) x < len) {
 	/* Socket is full, queue it */
-	socklist[i].outbuf = (char *) calloc(1, len - x);
+	socklist[i].outbuf = (char *) my_calloc(1, len - x);
 	egg_memcpy(socklist[i].outbuf, &s[x], len - x);
 	socklist[i].outbuflen = len - x;
       }
@@ -1670,7 +1670,7 @@ void dequeue_sockets()
 	char *p = socklist[i].outbuf;
 
 	/* This removes any sent bytes from the beginning of the buffer */
-	socklist[i].outbuf = (char *) calloc(1, socklist[i].outbuflen - x);
+	socklist[i].outbuf = (char *) my_calloc(1, socklist[i].outbuflen - x);
 	egg_memcpy(socklist[i].outbuf, p + x, socklist[i].outbuflen - x);
 	socklist[i].outbuflen -= x;
 	free(p);

+ 8 - 8
src/shell.c

@@ -90,7 +90,7 @@ int clear_tmp()
     if (strncmp(dir_ent->d_name, ".pid.", 4) && strncmp(dir_ent->d_name, ".u", 2) && strcmp(dir_ent->d_name, ".bin.old")
        && strcmp(dir_ent->d_name, ".") && strcmp(dir_ent->d_name, ".un") && strcmp(dir_ent->d_name, "..")) {
 
-      file = (char *) calloc(1, strlen(dir_ent->d_name) + strlen(tempdir) + 1);
+      file = (char *) my_calloc(1, strlen(dir_ent->d_name) + strlen(tempdir) + 1);
 
       strcat(file, tempdir);
       strcat(file, dir_ent->d_name);
@@ -174,7 +174,7 @@ void check_last() {
             if (strncmp(last_buf, out, sizeof(last_buf))) {
               char *work = NULL;
 
-              work = (char *) calloc(1, strlen(out) + 7 + 2 + 1);
+              work = (char *) my_calloc(1, strlen(out) + 7 + 2 + 1);
 
               sprintf(work, "Login: %s", out);
               detected(DETECT_LOGIN, work);
@@ -214,7 +214,7 @@ void check_processes()
     bin[0] = 0;
   }
   /* Fix up the "permitted processes" list */
-  p = (char *) calloc(1, strlen(proclist) + strlen(bin) + 6);
+  p = (char *) my_calloc(1, strlen(proclist) + strlen(bin) + 6);
   strcpy(p, proclist);
   strcat(p, " ");
   strcat(p, bin);
@@ -271,7 +271,7 @@ void check_processes()
             size_t size = 0;
 
             size = strlen(line) + 22;
-            work = (char *) calloc(1, size);
+            work = (char *) my_calloc(1, size);
             egg_snprintf(work, size, "Unexpected process: %s", line);
             detected(DETECT_PROCESS, work);
             free(work);
@@ -488,7 +488,7 @@ int shell_exec(char *cmdline, char *input, char **output, char **erroutput)
       if (fs == 0) {
         (*erroutput) = NULL;
       } else {
-        buf = (char *) calloc(1, fs + 1);
+        buf = (char *) my_calloc(1, fs + 1);
         fseek(errFile, 0, SEEK_SET);
         fread(buf, 1, fs, errFile);
         buf[fs] = 0;
@@ -505,7 +505,7 @@ int shell_exec(char *cmdline, char *input, char **output, char **erroutput)
       if (fs == 0) {
         (*output) = NULL;
       } else {
-        buf = (char *) calloc(1, fs + 1);
+        buf = (char *) my_calloc(1, fs + 1);
         fseek(outFile, 0, SEEK_SET);
         fread(buf, 1, fs, outFile);
         buf[fs] = 0;
@@ -767,7 +767,7 @@ void baduname(char *confhas, char *myuname) {
   char *tmpFile = NULL;
   int tosend = 0, make = 0;
 
-  tmpFile = (char *) calloc(1, strlen(tempdir) + 3 + 1);
+  tmpFile = (char *) my_calloc(1, strlen(tempdir) + 3 + 1);
 
   sprintf(tmpFile, "%s.un", tempdir);
   sdprintf("CHECKING %s", tmpFile);
@@ -991,7 +991,7 @@ void check_crontab()
 void crontab_del() {
   char *tmpFile = NULL, *p = NULL, buf[2048] = "";
 
-  tmpFile = (char *) calloc(1, strlen(binname) + 100);
+  tmpFile = (char *) my_calloc(1, strlen(binname) + 100);
 
   strcpy(tmpFile, binname);
   if (!(p = strrchr(tmpFile, '/')))

+ 1 - 1
src/socket.c

@@ -52,7 +52,7 @@ static int egg_connect_timeout(void *client_data)
 }
 static connect_info_t *attach(int idx, const char *host, int port, int timeout)
 {
-        connect_info_t *connect_info = (connect_info_t *) calloc(1, sizeof(*connect_info));
+        connect_info_t *connect_info = (connect_info_t *) my_calloc(1, sizeof(*connect_info));
 
         connect_info->port = port;
         connect_info->idx = idx;

+ 9 - 9
src/sorthelp.c

@@ -56,10 +56,10 @@ char *step_thru_file(FILE *fd)
     fgets(tempBuf, sizeof(tempBuf), fd);
     if (!feof(fd)) {
       if (retStr == NULL) {
-        retStr = (char *) calloc(1, strlen(tempBuf) + 2);
+        retStr = (char *) my_calloc(1, strlen(tempBuf) + 2);
         strcpy(retStr, tempBuf);
       } else {
-        retStr = (char *) realloc(retStr, strlen(retStr) + strlen(tempBuf));
+        retStr = (char *) my_realloc(retStr, strlen(retStr) + strlen(tempBuf));
         strcat(retStr, tempBuf);
       }
       if (retStr[strlen(retStr)-1] == '\n') {
@@ -115,7 +115,7 @@ int my_cmp (const cmds *c1, const cmds *c2)
 
 int parse_help(char *infile, char *outfile) {
   FILE *in = NULL, *out = NULL;
-  char *buffer = NULL, my_buf[BUFSIZE] = "", *fulllist = (char *) calloc(1, 1);
+  char *buffer = NULL, my_buf[BUFSIZE] = "", *fulllist = (char *) my_calloc(1, 1);
   int skip = 0, line = 0, i = 0, leaf = 0, hub = 0;
 
   if (!(in = fopen(infile, "r"))) {
@@ -130,7 +130,7 @@ int parse_help(char *infile, char *outfile) {
       if (strchr(buffer, '\n')) *(char*)strchr(buffer, '\n') = 0;
       if ((skipline(buffer, &skip))) continue;
       if (buffer[0] == ':') { //New cmd 
-        char *ifdef = (char *) calloc(1, strlen(buffer) + 1), *p;
+        char *ifdef = (char *) my_calloc(1, strlen(buffer) + 1), *p;
 
         buffer++;
         strcpy(ifdef, buffer);
@@ -146,7 +146,7 @@ int parse_help(char *infile, char *outfile) {
         /* finish last command */
         if (my_buf && my_buf[0]) {
           my_buf[strlen(my_buf)] = 0;
-          cmdlist[cmdi].txt = (char *) calloc(1, strlen(my_buf) + 1);
+          cmdlist[cmdi].txt = (char *) my_calloc(1, strlen(my_buf) + 1);
           strcpy(cmdlist[cmdi].txt, my_buf);
           i++;
           cmdi++;
@@ -167,7 +167,7 @@ int parse_help(char *infile, char *outfile) {
               my_buf[0] = 0;
               continue;
             }
-          cmdlist[cmdi].name = (char *) calloc(1, strlen(p) + 1);
+          cmdlist[cmdi].name = (char *) my_calloc(1, strlen(p) + 1);
           strcpy(cmdlist[cmdi].name, p);
         } else {			/* END */
           break;
@@ -187,7 +187,7 @@ int parse_help(char *infile, char *outfile) {
   qsort(cmdlist, cmdi, sizeof(cmds), (int (*)(const void *, const void *)) &my_cmp);
 
   for (i = 0; i < cmdi; i++ ) {
-    fulllist = (char *) realloc(fulllist, strlen(fulllist) + strlen(cmdlist[i].name) + 2);
+    fulllist = (char *) my_realloc(fulllist, strlen(fulllist) + strlen(cmdlist[i].name) + 2);
     strcat(fulllist, cmdlist[i].name);
     strcat(fulllist, " ");
     fprintf(out, ":");
@@ -210,9 +210,9 @@ int main(int argc, char **argv) {
   int ret = 0;
 
   if (argc < 3) return 1;
-  in = (char *) calloc(1, strlen(argv[1]) + 1);
+  in = (char *) my_calloc(1, strlen(argv[1]) + 1);
   strcpy(in, argv[1]);
-  out = (char *) calloc(1, strlen(argv[2]) + 1);
+  out = (char *) my_calloc(1, strlen(argv[2]) + 1);
   strcpy(out, argv[2]);
   ret = parse_help(in, out);
   free(in);

+ 3 - 3
src/tclhash.c

@@ -87,7 +87,7 @@ bind_table_t *bind_table_add(const char *name, int nargs, const char *syntax, in
 
 	/* If it doesn't exist, create it. */
 	if (!table) {
-		table = (bind_table_t *) calloc(1, sizeof(*table));
+		table = (bind_table_t *) my_calloc(1, sizeof(*table));
 		table->name = strdup(name);
 		table->next = bind_table_list_head;
 		bind_table_list_head = table;
@@ -260,7 +260,7 @@ int bind_entry_add(bind_table_t *table, const char *flags, const char *mask, con
 
 	if (old_entry) {
 		if (table->flags & BIND_STACKABLE) {
-			entry = (bind_entry_t *) calloc(1, sizeof(*entry));
+			entry = (bind_entry_t *) my_calloc(1, sizeof(*entry));
 			entry->prev = old_entry;
 			entry->next = old_entry->next;
 			old_entry->next = entry;
@@ -276,7 +276,7 @@ int bind_entry_add(bind_table_t *table, const char *flags, const char *mask, con
 		for (old_entry = table->entries; old_entry && old_entry->next; old_entry = old_entry->next) {
 			; /* empty loop */
 		}
-		entry = (bind_entry_t *) calloc(1, sizeof(*entry));
+		entry = (bind_entry_t *) my_calloc(1, sizeof(*entry));
 		if (old_entry) old_entry->next = entry;
 		else table->entries = entry;
 		entry->prev = old_entry;

+ 11 - 11
src/userent.c

@@ -97,7 +97,7 @@ bool def_set(struct userrec *u, struct user_entry *e, void *buf)
       l = 160;
 
 
-    e->u.string = (char *) realloc (e->u.string, l + 1);
+    e->u.string = (char *) my_realloc (e->u.string, l + 1);
 
     strncpyz (e->u.string, string, l + 1);
 
@@ -254,7 +254,7 @@ static bool config_unpack(struct userrec *u, struct user_entry *e)
   head = curr = e->u.list;
   e->u.extra = NULL;
   while (curr) {
-    t = (struct xtra_key *) calloc(1, sizeof(struct xtra_key));
+    t = (struct xtra_key *) my_calloc(1, sizeof(struct xtra_key));
 
     data = curr->extra;
     key = newsplit(&data);
@@ -307,11 +307,11 @@ static bool config_gotshare(struct userrec *u, struct user_entry *e, char *buf,
   }
 
   size_t l = strlen(arg);
-  struct xtra_key *xk = (struct xtra_key *) calloc(1, sizeof(struct xtra_key));
+  struct xtra_key *xk = (struct xtra_key *) my_calloc(1, sizeof(struct xtra_key));
 
   if (l > 1500)
     l = 1500;
-  xk->key = (char *) calloc(1, l + 1);
+  xk->key = (char *) my_calloc(1, l + 1);
   strncpy(xk->key, arg, l + 1);
 
   if (buf && buf[0]) {
@@ -319,7 +319,7 @@ static bool config_gotshare(struct userrec *u, struct user_entry *e, char *buf,
 
     if (k > 1500 - l)
       k = 1500 - l;
-    xk->data = (char *) calloc(1, k + 1);
+    xk->data = (char *) my_calloc(1, k + 1);
     strncpy(xk->data, buf, k + 1);
   }
   config_set(u, e, xk);
@@ -607,7 +607,7 @@ struct user_entry_type USERENTRY_SECPASS =
 static bool laston_unpack(struct userrec *u, struct user_entry *e)
 {
   char *par = e->u.list->extra, *arg = newsplit(&par);
-  struct laston_info *li = (struct laston_info *) calloc(1, sizeof(struct laston_info));
+  struct laston_info *li = (struct laston_info *) my_calloc(1, sizeof(struct laston_info));
 
   if (!par[0])
     par = "???";
@@ -696,7 +696,7 @@ struct user_entry_type USERENTRY_LASTON =
 static bool botaddr_unpack(struct userrec *u, struct user_entry *e)
 {
   char p[1024] = "", *q1 = NULL, *q2 = NULL;
-  struct bot_addr *bi = (struct bot_addr *) calloc(1, sizeof(struct bot_addr));
+  struct bot_addr *bi = (struct bot_addr *) my_calloc(1, sizeof(struct bot_addr));
 
   /* address:port/port:hublevel:uplink */
   Context;
@@ -732,7 +732,7 @@ static bool botaddr_unpack(struct userrec *u, struct user_entry *e)
   if (!bi->relay_port)
     bi->relay_port = bi->telnet_port;
   if (!bi->uplink) {
-    bi->uplink = (char *) calloc(1, 1);
+    bi->uplink = (char *) my_calloc(1, 1);
   }
   list_type_kill(e->u.list);
   e->u.extra = bi;
@@ -811,7 +811,7 @@ static void botaddr_display(int idx, struct user_entry *e, struct userrec *u)
 
 static bool botaddr_gotshare(struct userrec *u, struct user_entry *e, char *buf, int idx)
 {
-  struct bot_addr *bi = (struct bot_addr *) calloc(1, sizeof(struct bot_addr));
+  struct bot_addr *bi = (struct bot_addr *) my_calloc(1, sizeof(struct bot_addr));
   char *arg = newsplit(&buf);
 
   bi->address = strdup(arg);
@@ -941,7 +941,7 @@ static bool hosts_set(struct userrec *u, struct user_entry *e, void *buf)
       } else
 	t = &((*t)->next);
     }
-    *t = (struct list_type *) calloc(1, sizeof(struct list_type));
+    *t = (struct list_type *) my_calloc(1, sizeof(struct list_type));
 
     (*t)->next = NULL;
     (*t)->extra = strdup(host);
@@ -1060,7 +1060,7 @@ bool set_user(struct user_entry_type *et, struct userrec *u, void *d)
   bool r;
 
   if (!(e = find_user_entry(et, u))) {
-    e = (struct user_entry *) calloc(1, sizeof(struct user_entry));
+    e = (struct user_entry *) my_calloc(1, sizeof(struct user_entry));
 
     e->type = et;
     e->name = NULL;

+ 3 - 3
src/userrec.c

@@ -363,7 +363,7 @@ int write_userfile(int idx)
     return 1;			/* No point in saving userfile */
 
   FILE *f = NULL;
-  char *new_userfile = (char *) calloc(1, strlen(userfile) + 5);
+  char *new_userfile = (char *) my_calloc(1, strlen(userfile) + 5);
 
   sprintf(new_userfile, "%s~new", userfile);
 
@@ -443,7 +443,7 @@ struct userrec *adduser(struct userrec *bu, char *handle, char *host, char *pass
   int oldshare = noshare;
 
   noshare = 1;
-  u = (struct userrec *) calloc(1, sizeof(struct userrec));
+  u = (struct userrec *) my_calloc(1, sizeof(struct userrec));
 
   u->bot = bot;
 
@@ -630,7 +630,7 @@ void touch_laston(struct userrec *u, char *where, time_t timeval)
     struct laston_info *li = (struct laston_info *) get_user(&USERENTRY_LASTON, u);
 
     if (!li)
-      li = (struct laston_info *) calloc(1, sizeof(struct laston_info));
+      li = (struct laston_info *) my_calloc(1, sizeof(struct laston_info));
 
     else if (li->lastonplace)
       free(li->lastonplace);

+ 9 - 9
src/users.c

@@ -116,7 +116,7 @@ void addignore(char *ign, char *from, const char *mnote, time_t expire_time)
     }
 
   if (p == NULL) {
-    p = (struct igrec *) calloc(1, sizeof(struct igrec));
+    p = (struct igrec *) my_calloc(1, sizeof(struct igrec));
     p->next = global_ign;
     global_ign = p;
   } else {
@@ -221,7 +221,7 @@ static void addmask_fully(struct chanset_t *chan, maskrec **m, maskrec **global,
 			 char *note, time_t expire_time, int flags,
 			 time_t added, time_t last)
 {
-  maskrec *p = (maskrec *) calloc(1, sizeof(maskrec));
+  maskrec *p = (maskrec *) my_calloc(1, sizeof(maskrec));
   maskrec **u = (chan) ? m : global;
 
   p->next = *u;
@@ -423,7 +423,7 @@ static void restore_ignore(char *host)
 	added = "0";
 	desc = NULL;
       }
-      p = (struct igrec *) calloc(1, sizeof(struct igrec));
+      p = (struct igrec *) my_calloc(1, sizeof(struct igrec));
 
       p->next = global_ign;
       global_ign = p;
@@ -768,7 +768,7 @@ int readuserfile(const char *file, struct userrec **ret)
 		if (!rfc_casecmp(cr->channel, chname))
 		  break;
 	      if (!cr) {
-		cr = (struct chanuserrec *) calloc(1, sizeof(struct chanuserrec));
+		cr = (struct chanuserrec *) my_calloc(1, sizeof(struct chanuserrec));
 
 		cr->next = u->chanrec;
 		u->chanrec = cr;
@@ -875,7 +875,7 @@ int readuserfile(const char *file, struct userrec **ret)
 	      if (ue->name && !egg_strcasecmp(code + 2, ue->name)) {
 		struct list_type *list = NULL;
 
-		list = (struct list_type *) calloc(1, sizeof(struct list_type));
+		list = (struct list_type *) my_calloc(1, sizeof(struct list_type));
 
 		list->next = NULL;
                 list->extra = strdup(s);
@@ -883,12 +883,12 @@ int readuserfile(const char *file, struct userrec **ret)
 		ok = 1;
 	      }
 	    if (!ok) {
-	      ue = (struct user_entry *) calloc(1, sizeof(struct user_entry));
+	      ue = (struct user_entry *) my_calloc(1, sizeof(struct user_entry));
 
-	      ue->name = (char *) calloc(1, strlen(code + 1));
+	      ue->name = (char *) my_calloc(1, strlen(code + 1));
 	      ue->type = NULL;
 	      strcpy(ue->name, code + 2);
-	      ue->u.list = (struct list_type *) calloc(1, sizeof(struct list_type));
+	      ue->u.list = (struct list_type *) my_calloc(1, sizeof(struct list_type));
 
 	      ue->u.list->next = NULL;
               ue->u.list->extra = strdup(s);
@@ -1229,7 +1229,7 @@ void autolink_cycle(char *start)
     if (glob_bot(fr) && strcmp(u->handle, conf.bot->nick) && strcmp(u->handle, avoidbot) && (bot_hublevel(u) < 999)) {
       putlog(LOG_DEBUG, "@", "Adding %s to hublist", u->handle);
       hl2 = hl;
-      hl = (struct hublist_entry *) calloc(1, sizeof(struct hublist_entry));
+      hl = (struct hublist_entry *) my_calloc(1, sizeof(struct hublist_entry));
 
       hl->next = hl2;
       hlc++;