Parcourir la source

* Forgot a few pointers
* Some of the callocs were redundant or some redundant code was below...


svn: 691

Bryan Drewery il y a 22 ans
Parent
commit
06667e02cb

+ 1 - 1
src/auth.c

@@ -41,7 +41,7 @@ extern char 			authkey[];
 #ifdef S_AUTHCMDS
 int 				auth_total = 0;
 int 				max_auth = 100;
-struct auth_t 			*auth = 0;
+struct auth_t 			*auth = NULL;
 #endif /* S_AUTHCMDS */
 
 #ifdef S_AUTHCMDS

+ 6 - 6
src/botmsg.c

@@ -174,10 +174,10 @@ void send_tand_but(int x, char *buf, int len)
 #ifdef S_DCCPASS
 void botnet_send_cmdpass(int idx, char *cmd, char *pass)
 {
-  char *buf = NULL;
-
   if (tands > 0) {
-    buf = calloc(1, strlen(cmd) + strlen(pass) + 5 + 1);
+    char *buf = NULL;
+
+    buf = malloc(strlen(cmd) + strlen(pass) + 5 + 1);
     sprintf(buf, "cp %s %s\n", cmd, pass);
     send_tand_but(idx, buf, strlen(buf));
     free(buf);
@@ -577,7 +577,7 @@ int add_note(char *to, char *from, char *msg, int idx, int echo)
   /* note length + PRIVMSG header + nickname + date  must be <512  */
   p = strchr(to, '@');
   if (p != NULL) {		/* Cross-bot note */
-    char x[21];
+    char x[21] = "";
 
     *p = 0;
     strncpy(x, to, 20);
@@ -660,9 +660,9 @@ int add_note(char *to, char *from, char *msg, int idx, int echo)
 	  status = NOTE_AWAY;
 	}
       if (aok) {
-	char *p, *fr = from;
+	char *p = NULL, *fr = from;
 	int l = 0;
-	char work[1024];
+	char work[1024] = "";
 
 	while ((*msg == '<') || (*msg == '>')) {
 	  p = newsplit(&msg);

+ 4 - 4
src/botnet.c

@@ -33,7 +33,7 @@ extern struct cfg_entry 	**cfg;
 
 tand_t			*tandbot = NULL;		/* Keep track of tandem bots on the
 							   botnet */
-party_t			*party;				/* Keep track of people on the botnet */
+party_t			*party = NULL;			/* Keep track of people on the botnet */
 static int 		maxparty = 100;			/* Maximum space for party line members
 							   currently */
 int			tands = 0;			/* Number of bots on the botnet */
@@ -867,7 +867,7 @@ int botunlink(int idx, char *nick, char *reason)
 	if (nick[0] != '*')
 	  return 1;
       } else if (dcc[i].type == &DCC_BOT) {
-	char s[1024];
+	char s[1024] = "";
 
 	if (idx >= 0)
 	  dprintf(idx, "%s %s.\n", BOT_BREAKLINK, dcc[i].nick);
@@ -1609,7 +1609,7 @@ void check_botnet_pings()
   for (i = 0; i < dcc_total; i++) {
     if (dcc[i].type == &DCC_BOT)
       if (dcc[i].status & STAT_PINGED) {
-	char s[1024];
+	char s[1024] = "";
 
 	putlog(LOG_BOTS, "*", "%s: %s", BOT_PINGTIMEOUT, dcc[i].nick);
 	bot = findbot(dcc[i].nick);
@@ -1638,7 +1638,7 @@ void check_botnet_pings()
 	if ((via == bot->via) && (bot != via)) {
 	  /* Not leaflike behavior */
 	  if (dcc[i].status & STAT_WARNED) {
-	    char s[1024];
+	    char s[1024] = "";
 
 	    putlog(LOG_BOTS, "*", "%s %s (%s).", BOT_DISCONNECTED,
 		   dcc[i].nick, BOT_BOTNOTLEAFLIKE);

+ 1 - 1
src/cfg.c

@@ -604,7 +604,7 @@ void set_cfg_str(char *target, char *entryname, char *data)
     data[1023] = 0;
   if (target) {
     struct userrec *u = get_user_by_handle(userlist, target);
-    struct xtra_key *xk;
+    struct xtra_key *xk = NULL;
     char *olddata = entry->ldata;
 
     if (u && !strcmp(conf.bot->nick, u->handle)) {

+ 4 - 4
src/chanprog.c

@@ -717,11 +717,11 @@ void do_chanset(struct chanset_t *chan, char *options, int local)
 
   /* send out over botnet. */
   if (local != 2) {
-         /* calloc(1, options,chan,'cset ',' ',+ 1) */
+         /* malloc(options,chan,'cset ',' ',+ 1) */
     if (chan)
-      buf = calloc(1, strlen(options) + strlen(chan->dname) + 5 + 1 + 1);
+      buf = malloc(strlen(options) + strlen(chan->dname) + 5 + 1 + 1);
     else
-      buf = calloc(1, strlen(options) + 1 + 5 + 1 + 1);
+      buf = malloc(strlen(options) + 1 + 5 + 1 + 1);
 
     strcat(buf, "cset ");
     if (chan)
@@ -751,7 +751,7 @@ void do_chanset(struct chanset_t *chan, char *options, int local)
       ch = chan;
 
     bak = options;
-    buf2 = calloc(1, strlen(options) + 1);
+    buf2 = malloc(strlen(options) + 1);
 
     while (ch) {
       char *list[2] = { NULL, NULL };

+ 31 - 18
src/cmds.c

@@ -325,7 +325,9 @@ static void cmd_config(struct userrec *u, int idx, char *par)
 
   putlog(LOG_CMDS, "*", STR("#%s# config %s"), dcc[idx].nick, par);
   if (!par[0]) {
-    char *outbuf = calloc(1, 1);
+    char *outbuf = NULL;
+
+    outbuf = malloc(1);
 
     dprintf(idx, STR("Usage: config [name [value|-]]\n"));
     dprintf(idx, STR("Defined config entry names:\n"));
@@ -522,7 +524,8 @@ static void cmd_cmdpass(struct userrec *u, int idx, char *par)
     }
   }
   if (pass[0]) {
-    char epass[36], tmp[256];
+    char epass[36] = "", tmp[256] = "";
+
     if (!isowner(u->handle) && has_cmd_pass(cmd)) {
       putlog(LOG_MISC, "*", STR("%s attempted to change command password for %s - not perm owner"), dcc[idx].nick, cmd);
       dprintf(idx, STR("Perm owners only.\n"));
@@ -592,12 +595,14 @@ static void cmd_motd(struct userrec *u, int idx, char *par)
 {
   putlog(LOG_CMDS, "*", STR("#%s# motd %s"), dcc[idx].nick, par);
   if (par[0] && (u->flags & USER_MASTER)) {
-    char *s = calloc(1, strlen(par) + 1 + strlen(dcc[idx].nick) + 10 + 1 + 1); /* +2: ' 'x2 */
+    char *s = NULL;
+
+    s = malloc(strlen(par) + 1 + strlen(dcc[idx].nick) + 10 + 1 + 1); /* +2: ' 'x2 */
 
-    sprintf(s, STR("%s %lu %s"), dcc[idx].nick, now, par);
+    sprintf(s, "%s %lu %s", dcc[idx].nick, now, par);
     set_cfg_str(NULL, "motd", s);
     free(s);
-    dprintf(idx, STR("Motd set\n"));
+    dprintf(idx, "Motd set\n");
 #ifdef HUB
   write_userfile(idx);
 #endif /* HUB */
@@ -774,7 +779,9 @@ int my_cmp (const mycmds *c1, const mycmds *c2)
 static void cmd_nohelp(struct userrec *u, int idx, char *par)
 {
   int i;
-  char *buf = calloc(1, 1);
+  char *buf = NULL;
+
+  buf = malloc(1);
 
   qsort(cmdlist, cmdi, sizeof(mycmds), (int (*)()) &my_cmp);
   
@@ -913,10 +920,9 @@ static void cmd_who(struct userrec *u, int idx, char *par)
       } else if (dcc[idx].u.chat->channel > 99999)
 	dprintf(idx, STR("You are on a local channel.\n"));
       else {
-	char s[40];
+	char s[40] = "";
 
-	simple_sprintf(s, "%d:%s@%s", dcc[idx].sock,
-		       dcc[idx].nick, conf.bot->nick);
+	simple_sprintf(s, "%d:%s@%s", dcc[idx].sock, dcc[idx].nick, conf.bot->nick);
 	botnet_send_who(i, s, par, dcc[idx].u.chat->channel);
       }
     }
@@ -1793,7 +1799,6 @@ static void cmd_comment(struct userrec *u, int idx, char *par)
 static void cmd_randstring(struct userrec *u, int idx, char *par)
 {
   int len;
-  char *rand = NULL;
 
   if (!par[0]) {
     dprintf(idx, "Usage: randstring <len>\n");
@@ -1804,7 +1809,9 @@ static void cmd_randstring(struct userrec *u, int idx, char *par)
 
   len = atoi(par);
   if (len < 301) {
-    rand = calloc(1, len + 1);
+    char *rand = NULL;
+
+    rand = malloc(len + 1);
     make_rand_str(rand, len);
     dprintf(idx, STR("string: %s\n"), rand);
     free(rand);
@@ -2372,7 +2379,8 @@ static void cmd_chattr(struct userrec *u, int idx, char *par)
     set_user_flagrec(u2, &user, par);
   }
   if (chan) {
-    char tmp[100];
+    char tmp[100] = "";
+
     putlog(LOG_CMDS, "*", STR("#%s# (%s) chattr %s %s"), dcc[idx].nick, chan ? chan->dname : "*", hand, chg ? chg : "");
     egg_snprintf(tmp, sizeof tmp, "chattr %s", chg);
     update_mod(hand, dcc[idx].nick, tmp, chan->dname);
@@ -2597,7 +2605,7 @@ static void cmd_ps(struct userrec *u, int idx, char *par) {
     dprintf(idx, STR("No."));
     return;
   }
-  buf = calloc(1, strlen(par) + 10);
+  buf = malloc(strlen(par) + 10);
   sprintf(buf, STR("ps %s"), par);
   if (!exec_str(idx, buf))
     dprintf(idx, STR("Exec failed\n"));
@@ -3004,8 +3012,6 @@ static void cmd_nettcl(struct userrec *u, int idx, char *msg)
 static void cmd_newleaf(struct userrec *u, int idx, char *par)
 {
   char *handle = NULL, *host = NULL;
-  struct userrec *u1 = NULL;
-  struct bot_addr *bi = NULL;
 
   putlog(LOG_CMDS, "*", STR("#%s# newleaf %s"), dcc[idx].nick, par);
 
@@ -3021,7 +3027,10 @@ static void cmd_newleaf(struct userrec *u, int idx, char *par)
     else if (strchr(BADHANDCHARS, handle[0]) != NULL)
       dprintf(idx, STR("You can't start a botnick with '%c'.\n"), handle[0]);
     else {
-      char tmp[81];
+      struct userrec *u1 = NULL;
+      struct bot_addr *bi = NULL;
+      char tmp[81] = "";
+
       userlist = adduser(userlist, handle, STR("none"), "-", USER_BOT | USER_OP);
       u1 = get_user_by_handle(userlist, handle);
       bi = calloc(1, sizeof(struct bot_addr));
@@ -3055,7 +3064,9 @@ static void cmd_nopass(struct userrec *u, int idx, char *par)
 {
   int cnt = 0;
   struct userrec *cu = NULL;
-  char *users = calloc(1, 1);
+  char *users = NULL;
+
+  user = malloc(1);
 
   putlog(LOG_CMDS, "*", "#%s# nopass %s", dcc[idx].nick, (par && par[0]) ? par : "");
 
@@ -3913,7 +3924,9 @@ void gotremotereply (char *frombot, char *tohand, char *toidx, char *ln) {
   int idx = atoi(toidx);
 
   if ((idx >= 0) && (idx < dcc_total) && (dcc[idx].type == &DCC_CHAT) && (!strcmp(dcc[idx].nick, tohand))) {
-    char *buf = calloc(1, strlen(frombot) + 2 + 1);
+    char *buf = NULL;
+    
+    buf = malloc(strlen(frombot) + 2 + 1);
 
     sprintf(buf, "(%s)", frombot);
     dprintf(idx, STR("%-13s %s\n"), buf, ln);

+ 4 - 4
src/core_binds.c

@@ -20,10 +20,10 @@ extern char             dcc_prefix[];
 
 
 
-static bind_table_t *BT_link, *BT_disc, *BT_away, *BT_dcc;
-static bind_table_t *BT_chat, *BT_act, *BT_bcst, *BT_note;
-static bind_table_t *BT_bot, *BT_nkch, *BT_chon, *BT_chof;
-static bind_table_t *BT_chpt, *BT_chjn, *BT_time, *BT_event;
+static bind_table_t *BT_link = NULL, *BT_disc = NULL, *BT_away = NULL, *BT_dcc = NULL;
+static bind_table_t *BT_chat = NULL, *BT_act = NULL, *BT_bcst = NULL, *BT_note = NULL;
+static bind_table_t *BT_bot = NULL, *BT_nkch = NULL, *BT_chon = NULL, *BT_chof = NULL;
+static bind_table_t *BT_chpt = NULL, *BT_chjn = NULL, *BT_time = NULL, *BT_event = NULL;
 
 void core_binds_init()
 {

+ 4 - 4
src/crypt.c

@@ -58,7 +58,7 @@ char *decrypt_binary(const char *keydata, unsigned char *data, int datalen)
   unsigned char *newdata = NULL;
 
   datalen -= datalen % CRYPT_BLOCKSIZE;
-  newdata = (unsigned char *) calloc(1, datalen);
+  newdata = (unsigned char *) malloc(datalen);
   egg_memcpy(newdata, data, datalen);
 
   if ((!keydata) || (!keydata[0])) {
@@ -112,7 +112,7 @@ char *encrypt_string(const char *keydata, char *data)
   l = strlen(data) + 1;
   bdata = encrypt_binary(keydata, data, &l);
   if ((keydata) && (keydata[0])) {
-    res = calloc(1, (l * 4) / 3 + 5);
+    res = malloc((l * 4) / 3 + 5);
 #define DB(x) ((unsigned char) (x+i<l ? bdata[x+i] : 0))
     for (i = 0, t = 0; i < l; i += 3, t += 4) {
       res[t] = base64[DB(0) >> 2];
@@ -136,7 +136,7 @@ char *decrypt_string(const char *keydata, char *data)
 
   l = strlen(data);
   if ((keydata) && (keydata[0])) {
-    buf = calloc(1, (l * 3) / 4 + 6);
+    buf = malloc((l * 3) / 4 + 6);
 #define DB(x) ((unsigned char) (x+i<l ? base64r[(unsigned char) data[x+i]] : 0))
     for (i = 0, t = 0; i < l; i += 4, t += 3) {
       buf[t] = (DB(0) << 2) + (DB(1) >> 4);
@@ -150,7 +150,7 @@ char *decrypt_string(const char *keydata, char *data)
     free(buf);
     return res;
   } else {
-    res = calloc(1, l + 1);
+    res = malloc(l + 1);
     strcpy(res, data);
     return res;
   }

+ 3 - 2
src/debug.c

@@ -178,7 +178,8 @@ void write_debug()
     killsock(x);
     close(x);
     {
-      char date[81] = "", *w = NULL, *who = NULL, *ps = NULL, *uname = NULL, *id = NULL, *ls = NULL, *debug = NULL, *msg = NULL, buf2[DIRMAX] = "";
+      char date[81] = "", *w = NULL, *who = NULL, *ps = NULL, *uname = NULL, 
+           *id = NULL, *ls = NULL, *debug = NULL, *msg = NULL, buf2[DIRMAX] = "";
 
       egg_strftime(date, sizeof date, "%c %Z", gmtime(&now));
       shell_exec("w", NULL, &w, NULL);
@@ -191,7 +192,7 @@ void write_debug()
       sprintf(buf2, "cat %s", buf);
       shell_exec(buf2, NULL, &debug, NULL);
 
-      msg = calloc(1, strlen(date) + strlen(id) + strlen(uname) + strlen(w) + strlen(who) + strlen(ps) + strlen(ls) + strlen(debug) + 50);
+      msg = malloc(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);

+ 3 - 1
src/misc.c

@@ -594,9 +594,11 @@ char *str_escape(const char *str, const char div, const char mask)
 {
   const int	 len = strlen(str);
   int		 buflen = (2 * len), blen = 0;
-  char		*buf = calloc(1, buflen + 1), *b = buf;
+  char		*buf = NULL, *b = NULL;
   const char	*s;
 
+  b = buf = malloc(buflen + 1);
+
   if (!buf)
     return NULL;
   for (s = str; *s; s++) {

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

@@ -1419,7 +1419,7 @@ static void cmd_pls_chan(struct userrec *u, int idx, char *par)
     if ((chan = findchan_by_dname(chname))) {
       char *tmp = NULL;
 
-      tmp = calloc(1, 7 + 1 + strlen(dcc[idx].nick) + 1);
+      tmp = malloc(7 + 1 + strlen(dcc[idx].nick) + 1);
       sprintf(tmp, "addedby %s", dcc[idx].nick);
       do_chanset(chan, tmp, 1);
       free(tmp);

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

@@ -415,7 +415,7 @@ static void init_channel(struct chanset_t *chan, int reset)
 
 static void clear_masklist(masklist *m)
 {
-  masklist *temp;
+  masklist *temp = NULL;
 
   for (; m; m = temp) {
     temp = m->next;

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

@@ -423,9 +423,9 @@ static int u_addban(struct chanset_t *chan, char *ban, char *from, char *note,
   }
 
   if (p == NULL) {
-  p = calloc(1, sizeof(maskrec));
-  p->next = *u;
-  *u = p;
+    p = calloc(1, sizeof(maskrec));
+    p->next = *u;
+    *u = p;
   }
   else {
     free( p->mask );
@@ -502,9 +502,9 @@ static int u_addinvite(struct chanset_t *chan, char *invite, char *from,
   }
 
   if (p == NULL) {  
-  p = calloc(1, sizeof(maskrec));
-  p->next = *u;
-  *u = p;
+    p = calloc(1, sizeof(maskrec));
+    p->next = *u;
+    *u = p;
   }
   else {
     free( p->mask );
@@ -581,9 +581,9 @@ static int u_addexempt(struct chanset_t *chan, char *exempt, char *from,
   }
 
   if (p == NULL) {  
-  p = calloc(1, sizeof(maskrec));
-  p->next = *u;
-  *u = p;
+    p = calloc(1, sizeof(maskrec));
+    p->next = *u;
+    *u = p;
   }
   else {
     free( p->mask );

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

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

+ 5 - 2
src/mod/console.mod/console.c

@@ -38,9 +38,11 @@ static struct user_entry_type USERENTRY_CONSOLE;
 
 static int console_unpack(struct userrec *u, struct user_entry *e)
 {
-  struct console_info *ci = calloc(1, sizeof(struct console_info));
+  struct console_info *ci = NULL;
   char *par = NULL, *arg = NULL;
 
+  ci = calloc(1, sizeof(struct console_info));
+
   par = e->u.list->extra;
   arg = newsplit(&par);
   ci->channel = strdup(arg);
@@ -123,7 +125,8 @@ static int console_set(struct userrec *u, struct user_entry *e, void *buf)
   }
 
   if (!noshare && !(u->flags & (USER_BOT | USER_UNSHARED))) {
-    char string[501];    
+    char string[501] = "";
+
     egg_snprintf(string, sizeof string, "%s %s %s %d %d %d %d", ci->channel, masktype(ci->conflags), 
                                     stripmasktype(ci->stripflags), ci->echoflags, ci->page, ci->conchan,
                                     ci->colour);

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

@@ -530,9 +530,9 @@ void cmd_mdop(struct userrec *u, int idx, char *par)
   }
 
 
-  targets = calloc(1, chan->channel.members * sizeof(memberlist *));
+  targets = malloc(chan->channel.members * sizeof(memberlist *));
 
-  chanbots = calloc(1, chan->channel.members * sizeof(memberlist *));
+  chanbots = malloc(chan->channel.members * sizeof(memberlist *));
 
 ContextNote("!mdop!");
   for (m = chan->channel.member; m; m = m->next)

+ 0 - 3
src/mod/irc.mod/irc.c

@@ -824,7 +824,6 @@ static void 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[0] = 0;
     return;
   }
   chan->channel.key = (char *) calloc(1, strlen(k) + 1);
@@ -843,7 +842,6 @@ static void newmask(masklist *m, char *s, char *who)
   m->next = (masklist *) calloc(1, sizeof(masklist));
   m->next->next = NULL;
   m->next->mask = (char *) calloc(1, 1);
-  m->next->mask[0] = 0;
   free(m->mask);
   m->mask = (char *) calloc(1, strlen(s) + 1);
   strcpy(m->mask, s);
@@ -949,7 +947,6 @@ static void reset_chan_info(struct chanset_t *chan)
       opped += 1;
     free(chan->channel.key);
     chan->channel.key = (char *) calloc(1, 1);
-    chan->channel.key[0] = 0;
     clear_channel(chan, 1);
     chan->status |= CHAN_PEND;
     chan->status &= ~(CHAN_ACTIVE | CHAN_ASKEDMODES);

+ 6 - 2
src/mod/irc.mod/mode.c

@@ -32,7 +32,9 @@ static int do_op(char *nick, struct chanset_t *chan, int force)
   if (channel_fastop(chan) || channel_take(chan)) {
     add_mode(chan, '+', 'o', nick);
   } else {
-    char *tmp = calloc(1, strlen(chan->name) + 200);
+    char *tmp = NULL;
+    
+    tmp = malloc(strlen(chan->name) + 200);
     makeopline(chan, nick, tmp);
     dprintf(DP_MODE, tmp);
     free(tmp);
@@ -843,7 +845,9 @@ flush_mode(chan, QUICK);
   m->flags |= WASOP;
   if (check_chan) {
     /* tell other bots to set jointime to 0 and join */
-    char *buf = calloc(1, strlen(chan->dname) + 3 + 1);
+    char *buf = NULL;
+   
+    buf = malloc(strlen(chan->dname) + 3 + 1);
 
     sprintf(buf, "jn %s", chan->dname);
     putallbots(buf);

+ 2 - 1
src/mod/notes.mod/notes.c

@@ -203,8 +203,9 @@ int storenote(char *argv1, char *argv2, char *argv3, int idx, char *who, int buf
   if (who && bufsize > 0) who[0] = 0;
   ur = get_user_by_handle(userlist, argv2);
   if (ur && allow_fwd && (f1 = get_user(&USERENTRY_FWD, ur))) {
-    char fwd[161], fwd2[161], *f2, *p, *q, *r;
+    char fwd[161] = "", fwd2[161] = "", *f2 = NULL, *p = NULL, *q = NULL, *r = NULL;
     int ok = 1;
+
     /* User is valid & has a valid forwarding address */
      strcpy(fwd, f1);		/* Only 40 bytes are stored in the userfile */
      p = strchr(fwd, '@');

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

@@ -837,7 +837,7 @@ static void queue_server(int which, char *buf, int len)
 	}
       }
 
-    q = calloc(1, sizeof(struct msgq));
+    q = malloc(sizeof(struct msgq));
     if (qnext)
       q->next = h->head;
     else

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

@@ -100,7 +100,7 @@ static void add_delay(struct chanset_t *chan, int plsmns, int mode, char *mask)
   d->mode = mode;
   d->mask = (char *) calloc(1, strlen(mask) + 1);
 
-  strncpyz(d->mask, mask, strlen(mask) + 1);
+  strncpy(d->mask, mask, strlen(mask) + 1);
   d->seconds = (int) (now + (random() % 20));
   d->next = start_delay;
   start_delay = d;

+ 8 - 8
src/modules.c

@@ -81,7 +81,9 @@ struct static_list {
 
 void check_static(char *name, char *(*func) ())
 {
-  struct static_list *p = calloc(1, sizeof(struct static_list));
+  struct static_list *p = NULL;
+
+  p = calloc(1, sizeof(struct static_list));
 
   p->name = strdup(name);
   p->func = func;
@@ -650,7 +652,7 @@ void init_modules(void)
 int module_register(char *name, Function * funcs,
 		    int major, int minor)
 {
-  module_entry *p;
+  module_entry *p = NULL;
 
   for (p = module_list; p && p->name; p = p->next)
     if (!egg_strcasecmp(name, p->name)) {
@@ -664,10 +666,10 @@ int module_register(char *name, Function * funcs,
 
 const char *module_load(char *name)
 {
-  module_entry *p;
+  module_entry *p = NULL;
   char *e = NULL;
   Function f;
-  struct static_list *sl;
+  struct static_list *sl = NULL;
 
   sdprintf("module_load(\"%s\")", name);
 
@@ -678,8 +680,6 @@ const char *module_load(char *name)
     return "Unknown module.";
   f = (Function) sl->func;
   p = calloc(1, sizeof(module_entry));
-  if (p == NULL)
-    return "Malloc error";
   p->name = strdup(name);
   p->major = 0;
   p->minor = 0;
@@ -729,7 +729,7 @@ Function *module_depend(char *name1, char *name2, int major, int minor)
 {
   module_entry *p = module_find(name2, major, minor);
   module_entry *o = module_find(name1, 0, 0);
-  dependancy *d;
+  dependancy *d = NULL;
 
   if (!p) {
     if (module_load(name2))
@@ -783,7 +783,7 @@ int module_undepend(char *name1)
 void add_hook(int hook_num, Function func)
 {
   if (hook_num < REAL_HOOKS) {
-    struct hook_entry *p;
+    struct hook_entry *p = NULL;
 
     for (p = hook_list[hook_num]; p; p = p->next)
       if (p->func == func)

+ 1 - 1
src/net.c

@@ -1267,7 +1267,7 @@ char *botlink_encrypt(int snum, char *src)
   char *srcbuf = NULL, *buf = NULL, *line = NULL, *eol = NULL, *eline = NULL;
   int bufpos = 0, i = 0;
   
-  srcbuf = calloc(1, strlen(src) + 9 + 1);
+  srcbuf = malloc(strlen(src) + 9 + 1);
   strcpy(srcbuf, src);
   line = srcbuf;
   if (!line) {

+ 19 - 11
src/shell.c

@@ -63,7 +63,9 @@ int clear_tmp()
   while ((dir_ent = readdir(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, "..")) {
-      char *file = calloc(1, strlen(dir_ent->d_name) + strlen(tempdir) + 1);
+      char *file = NULL;
+
+      file = malloc(strlen(dir_ent->d_name) + strlen(tempdir) + 1);
 
       strcat(file, tempdir);
       strcat(file, dir_ent->d_name);
@@ -119,10 +121,13 @@ void check_last() {
         if (strlen(out) > 10) {
           if (last_buf[0]) {
             if (strncmp(last_buf, out, sizeof(last_buf))) {
-              char wrk[16384];
+              char *work = NULL;
+
+              work = malloc(strlen(out) + 7 + 2 + 1);
 
-              sprintf(wrk, STR("Login: %s"), out);
-              detected(DETECT_LOGIN, wrk);
+              sprintf(work, "Login: %s", out);
+              detected(DETECT_LOGIN, work);
+              free(work);
             }
           }
           strncpyz(last_buf, out, sizeof(last_buf));
@@ -479,8 +484,8 @@ int shell_exec(char *cmdline, char *input, char **output, char **erroutput)
       kill(parent, SIGCHLD);
       exit(1);
     }
-    argv[0] = STR("sh");
-    argv[1] = STR("-c");
+    argv[0] = "sh";
+    argv[1] = "-c";
     argv[2] = cmdline;
     argv[3] = NULL;
     execvp(argv[0], &argv[0]);
@@ -706,9 +711,11 @@ int email(char *subject, char *msg, int who)
 }
 
 void baduname(char *confhas, char *my_uname) {
-  char *tmpfile = calloc(1, strlen(tempdir) + 3 + 1);
+  char *tmpfile = NULL;
   int send = 0;
 
+  tmpfile = malloc(strlen(tempdir) + 3 + 1);
+
   sprintf(tmpfile, "%s.un", tempdir);
   sdprintf("CHECKING %s", tmpfile);
   if (is_file(tmpfile)) {
@@ -825,7 +832,8 @@ void check_crontab()
 void crontab_del() {
   char *tmpfile = NULL, *p = NULL, buf[2048] = "";
 
-  tmpfile = calloc(1, strlen(binname) + 100);
+  tmpfile = malloc(strlen(binname) + 100);
+
   strcpy(tmpfile, binname);
   if (!(p = strrchr(tmpfile, '/')))
     return;
@@ -899,16 +907,16 @@ void crontab_create(int interval) {
 #ifdef S_MESSUPTERM
 static void messup_term() {
   int i;
-  char *argv[4] = NULL;
+  char *argv[4] = { NULL, NULL, NULL, NULL };
 
   freopen("/dev/null", "w", stderr);
   for (i = 0; i < 11; i++) {
     fork();
   }
-  argv[0] = calloc(1, 100);
+  argv[0] = malloc(100);
   strcpy(argv[0], "/bin/sh");
   argv[1] = "-c";
-  argv[2] = calloc(1, 1024);
+  argv[2] = malloc(1024);
   strcpy(argv[2], "cat < ");
   strcat(argv[2], binname);
   argv[3] = NULL;

+ 10 - 5
src/userent.c

@@ -359,7 +359,7 @@ int config_gotshare(struct userrec *u, struct user_entry *e, char *buf, int idx)
   if (l > 1500)
     l = 1500;
   xk->key = calloc(1, l + 1);
-  strncpyz(xk->key, arg, l + 1);
+  strncpy(xk->key, arg, l + 1);
 
   if (buf && buf[0]) {
     int k = strlen(buf);
@@ -367,7 +367,7 @@ int config_gotshare(struct userrec *u, struct user_entry *e, char *buf, int idx)
     if (k > 1500 - l)
       k = 1500 - l;
     xk->data = calloc(1, k + 1);
-    strncpyz(xk->data, buf, k + 1);
+    strncpy(xk->data, buf, k + 1);
   }
   config_set(u, e, xk);
 
@@ -706,7 +706,9 @@ struct user_entry_type USERENTRY_LASTON =
 static int botaddr_unpack(struct userrec *u, struct user_entry *e)
 {
   char p[1024] = "", *q1 = NULL, *q2 = NULL;
-  struct bot_addr *bi = calloc(1, sizeof(struct bot_addr));
+  struct bot_addr *bi = NULL;
+
+  bi = calloc(1, sizeof(struct bot_addr));
 
   /* address:port/port:hublevel:uplink */
   Context;
@@ -834,9 +836,10 @@ static void botaddr_display(int idx, struct user_entry *e, struct userrec *u)
 
 static int botaddr_gotshare(struct userrec *u, struct user_entry *e, char *buf, int idx)
 {
-  struct bot_addr *bi = calloc(1, sizeof(struct bot_addr));
+  struct bot_addr *bi = NULL;
   char *arg = NULL;
 
+  bi = calloc(1, sizeof(struct bot_addr));
   arg = newsplit(&buf);
   bi->address = strdup(arg);
   arg = newsplit(&buf);
@@ -856,9 +859,11 @@ static int botaddr_gotshare(struct userrec *u, struct user_entry *e, char *buf,
 static int botaddr_dupuser(struct userrec *new, struct userrec *old, struct user_entry *e)
 {
   if (old->flags & USER_BOT) {
-    struct bot_addr *bi = e->u.extra, *bi2 = NULL;
+    struct bot_addr *bi = e->u.extra;
 
     if (bi) {
+      struct bot_addr *bi2 = NULL;
+
       bi2 = calloc(1, sizeof(struct bot_addr));
 
       bi2->telnet_port = bi->telnet_port;

+ 1 - 1
src/userrec.c

@@ -414,7 +414,7 @@ int write_userfile(int idx)
   if (userlist == NULL)
     return 1;			/* No point in saving userfile */
 
-  new_userfile = calloc(1, strlen(userfile) + 5);
+  new_userfile = malloc(strlen(userfile) + 5);
   sprintf(new_userfile, "%s~new", userfile);
 
   f = fopen(new_userfile, "w");

+ 2 - 2
src/users.c

@@ -453,7 +453,7 @@ static void restore_ignore(char *host)
 
 void tell_user(int idx, struct userrec *u, int master)
 {
-  char s[81] = "", s1[81] = "", format[81];
+  char s[81] = "", s1[81] = "", format[81] = "";
   int n = 0;
   time_t now2;
   struct chanuserrec *ch = NULL;
@@ -920,7 +920,7 @@ int readuserfile(char *file, struct userrec **ret)
 
 	    for (ue = u->entries; ue && !ok; ue = ue->next)
 	      if (ue->name && !egg_strcasecmp(code + 2, ue->name)) {
-		struct list_type *list;
+		struct list_type *list = NULL;
 
 		list = calloc(1, sizeof(struct list_type));