Browse Source

* Stripped numver crap...
* Fixed many uninitialised variables found in valgrind
* Various code fixes
* More conf parsing code


svn: 689

Bryan Drewery 22 năm trước cách đây
mục cha
commit
05cb71c39b
26 tập tin đã thay đổi với 135 bổ sung161 xóa
  1. 0 1
      Makefile.in
  2. 0 1
      autotools/includes/acinclude.m4
  3. 4 5
      build
  4. 1 3
      configure
  5. 14 3
      doc/UPDATES
  6. 8 10
      src/botcmd.c
  7. 1 3
      src/botmsg.c
  8. 3 7
      src/botnet.c
  9. 6 7
      src/chanprog.c
  10. 4 4
      src/cmds.c
  11. 21 18
      src/conf.c
  12. 14 19
      src/dcc.c
  13. 5 6
      src/dccutil.c
  14. 5 6
      src/debug.c
  15. 7 7
      src/main.c
  16. 4 8
      src/mod/ctcp.mod/ctcp.c
  17. 0 1
      src/mod/module.h
  18. 6 13
      src/mod/share.mod/share.c
  19. 3 3
      src/mod/update.mod/update.c
  20. 3 3
      src/modules.c
  21. 13 9
      src/net.c
  22. 1 0
      src/shell.c
  23. 0 1
      src/tandem.h
  24. 1 1
      src/tcl.c
  25. 6 14
      src/userent.c
  26. 5 8
      src/users.c

+ 0 - 1
Makefile.in

@@ -10,7 +10,6 @@ VPATH = @srcdir@
 @SET_MAKE@
 prefix = @prefix@
 VERSION = @VERSION@
-NUMVER = @NUMVER@
 PACKNAME = @PACKNAME@
 DISTRIB = @PACKNAME@-@VERSION@
 CCDEPMODE = @CCDEPMODE@

+ 0 - 1
autotools/includes/acinclude.m4

@@ -1044,7 +1044,6 @@ dnl  EGG_SUBST_VERSION()
 dnl
 AC_DEFUN(EGG_SUBST_VERSION, [dnl
 VERSION=`grep "char" $srcdir/src/main.c | $AWK '/egg_version/ {print [$]5}' | sed -e 's/\"//g' | sed -e 's/\;//g'`
-NUMVER=`grep "int" $srcdir/src/main.c | $AWK '/egg_numver =/ {print [$]5}' |  sed -e 's/\;//g'`
 if ! test -f $srcdir/pack/pack.cfg; then
  cat << EOF >&2
 configure: error:

+ 4 - 5
build

@@ -14,7 +14,6 @@ fi
 
 ver="?.?.?"
 ver=`grep "char" src/main.c | $AWK '/egg_version/ {print $5}' | sed -e 's/\"//g' | sed -e 's/\;//g'`
-numver=`grep "int" src/main.c | $AWK '/egg_numver =/ {print $5}' |  sed -e 's/\;//g'`
 PACKNAME=`grep "PACKNAME " pack/pack.cfg | $AWK '/PACKNAME/ {print $2}'`
 BUILDTS=`cat src/build.h | $AWK '{print $3}'`
 builddate=`perl -e "use POSIX 'strftime';print strftime(\"%m.%d.%Y\n\",gmtime(${BUILDTS}));"`
@@ -188,7 +187,7 @@ fi
 
 for bin in $fls
 do
-  mv -f $bin $bin.$os.$numver${d}
+  mv -f $bin $bin.$os.$ver${d}
 done
 
 # Wrap it nicely up into an archive
@@ -204,12 +203,12 @@ if [ $nopkg = "0" ]; then
   #This MALLOC business is to not Abort 'tar' due to some bug it has.
   tmp=${MALLOC_CHECK_}
   unset MALLOC_CHECK_
-  tar -c${zip}f ${PACKNAME}.$os.$numver${d}.tar.${ext} *.$os.$numver${d}
+  tar -c${zip}f ${PACKNAME}.$os.$ver${d}.tar.${ext} *.$os.$ver${d}
   if test -n "$tmp"; then
     declare -x MALLOC_CHECK_=$tmp
   fi
-  rm -f *$os.$numver${d}
-  echo "Binaries are now in '${PACKNAME}.$os.$numver${d}.tar.${ext}'."
+  rm -f *$os.$ver${d}
+  echo "Binaries are now in '${PACKNAME}.$os.$ver${d}.tar.${ext}'."
 fi
   exit 0
 

+ 1 - 3
configure

@@ -1,5 +1,5 @@
 #! /bin/sh
-# From configure.ac Revision: 1.12 .
+# From configure.ac Revision: 1.14 .
 # Guess values for system-dependent variables and create Makefiles.
 # Generated by GNU Autoconf 2.59.
 #
@@ -3411,7 +3411,6 @@ EOF
   exit 1
 fi
 
-#EGG_PROG_OBJCOPY
 # Extract the first word of "objcopy", so it can be a program name with args.
 set dummy objcopy; ac_word=$2
 echo "$as_me:$LINENO: checking for $ac_word" >&5
@@ -13284,7 +13283,6 @@ rm -f confcache
 # ---------- end of (what used to be) robey's Tcl thingies
 
 VERSION=`grep "char" $srcdir/src/main.c | $AWK '/egg_version/ {print $5}' | sed -e 's/\"//g' | sed -e 's/\;//g'`
-NUMVER=`grep "int" $srcdir/src/main.c | $AWK '/egg_numver =/ {print $5}' |  sed -e 's/\;//g'`
 if ! test -f $srcdir/pack/pack.cfg; then
  cat << EOF >&2
 configure: error:

+ 14 - 3
doc/UPDATES

@@ -1,6 +1,18 @@
 This is a summary of ChangeLog basically.
 
-1.0.15
+1.1.0
+1.Rewrote the shell config parsing...
+2.Stripped that long version (1001400) stuff out, now just 1.1.0 and the build timestamp...
+3.Rewrote the core from scratch.
+4.Stripped out TCL.
+5.Restructured the source tree to be more organized.
+6.Rewrote the 'modules' to just compile staticaly and not as 'modules' (speeds up bot.)
+7.Removed define: AUTH, added: AUTHCMDS, AUTHHASH, DCCAUTH, see pack.cfg for details.
+8.Leaf binary now accepts -B <botnick>
+9.Bot is now much more portable.
+
+
+1.0.15 (Non-Release Version)
 1.cmd_randstring is now limited to 300.
 2.cmd_botversion and cmd_netversion are now HUB only.
 3.Bots will now email owners once a day if their uname() output changes.
@@ -24,8 +36,7 @@ This is a summary of ChangeLog basically.
 21.Config option "nocheck" has been removed and is now implied by "ignore".
 22.Bots now do NOT check for tracing/promisc/login/etc... unless something is SET.
 23.Removed note ignore commands, ie .+/-noteign .noteigns
-24.Removed define: AUTH, added: AUTHCMDS, AUTHHASH, DCCAUTH, see pack.cfg for details.
-25.Leaf binary now accepts -B <botnick>
+
 
 1.0.14
 1.Fixed order of log/info for cmd_whoami.

+ 8 - 10
src/botcmd.c

@@ -502,7 +502,7 @@ static void bot_endlink(int idx, char *par)
  */
 static void bot_infoq(int idx, char *par)
 {
-  char s[200], s2[32], *realnick;
+  char s[200] = "", s2[32] = "", *realnick = NULL;
   struct chanset_t *chan;
   time_t now2;
   int hr, min;
@@ -1161,14 +1161,11 @@ static void bot_join(int idx, char *par)
   botnet_send_join_party(idx, linking, i2, i);
   if (i != chan) {
     if (i >= 0) {
-      if (b_numver(idx) >= NEAT_BOTNET)
-	chanout_but(-1, i, "*** (%s) %s %s %s.\n", bot, nick, NET_LEFTTHE,
-		    i ? "channel" : "party line");
+      chanout_but(-1, i, "*** (%s) %s %s %s.\n", bot, nick, NET_LEFTTHE, i ? "channel" : "party line");
       check_bind_chpt(bot, nick, sock, i);
     }
-    if ((b_numver(idx) >= NEAT_BOTNET) && !linking)
-      chanout_but(-1, chan, "*** (%s) %s %s %s.\n", bot, nick, NET_JOINEDTHE,
-		  chan ? "channel" : "party line");
+    if (!linking)
+    chanout_but(-1, chan, "*** (%s) %s %s %s.\n", bot, nick, NET_JOINEDTHE, chan ? "channel" : "party line");
     check_bind_chjn(bot, nick, chan, y[0], sock, par);
   }
 }
@@ -1202,7 +1199,7 @@ static void bot_part(int idx, char *par)
   if ((partyidx = getparty(bot, sock)) != -1) {
     if (party[partyidx].chan >= 0)
       check_bind_chpt(bot, nick, sock, party[partyidx].chan);
-    if ((b_numver(idx) >= NEAT_BOTNET) && !silent) {
+    if (!silent) {
       register int chan = party[partyidx].chan;
 
       if (par[0])
@@ -1249,7 +1246,7 @@ static void bot_away(int idx, char *par)
     partystat(bot, sock, 0, PLSTAT_AWAY);
   }
   partyidx = getparty(bot, sock);
-  if ((b_numver(idx) >= NEAT_BOTNET) && !linking) {
+  if (!linking) {
     if (par[0])
       chanout_but(-1, party[partyidx].chan,
 		  "*** (%s) %s %s: %s.\n", bot,
@@ -1389,7 +1386,7 @@ static void bot_rsim(char *botnick, char *code, char *par)
 {
   int ridx = -1, idx = -1, i = 0, rconmask;
   unsigned long status = 0;
-  char *nick = NULL, *cmd = NULL, *rconchan = NULL, buf[UHOSTMAX];
+  char *nick = NULL, *cmd = NULL, *rconchan = NULL, buf[UHOSTMAX] = "";
 
   ridx = atoi(newsplit(&par));
   nick = newsplit(&par);
@@ -1428,6 +1425,7 @@ static void bot_rsim(char *botnick, char *code, char *par)
     dcc[idx].addr = 0;
     dcc[idx].user = get_user_by_handle(userlist, nick);
   }
+  rmspace(par);
   check_bind_dcc(cmd, idx, par);
 }
 

+ 1 - 3
src/botmsg.c

@@ -168,9 +168,7 @@ void send_tand_but(int x, char *buf, int len)
     iso = 1;
   }
   for (i = 0; i < dcc_total; i++)
-    if ((dcc[i].type == &DCC_BOT) && (i != x) &&
-	(b_numver(i) >= NEAT_BOTNET) &&
-	(!iso || !(bot_flags(dcc[i].user) & BOT_ISOLATE)))
+    if ((dcc[i].type == &DCC_BOT) && (i != x) && (!iso || !(bot_flags(dcc[i].user) & BOT_ISOLATE)))
       tputs(dcc[i].sock, buf, len);
 }
 #ifdef S_DCCPASS

+ 3 - 7
src/botnet.c

@@ -23,10 +23,10 @@
 #include "core_binds.h"
 
 extern int			dcc_total, backgrd, connect_timeout, max_dcc,
-				egg_numver, cfg_count;
+				cfg_count;
 extern struct userrec		*userlist;
 extern struct dcc_t		*dcc;
-extern time_t 			now;
+extern time_t 			now, buildts;
 extern Tcl_Interp		*interp;
 extern struct cfg_entry 	**cfg;
 
@@ -617,11 +617,7 @@ void tell_bottree(int idx, int showver)
   if (s[0])
     dprintf(idx, "(%s %s)\n", BOT_NOTRACEINFO, s);
   if (showver)
-    dprintf(idx, "%s (%d.%d.%d.%d)\n", conf.bot->nick,
-	    egg_numver / 1000000,
-	    egg_numver % 1000000 / 10000,
-	    egg_numver % 10000 / 100,
-	    egg_numver % 100);
+    dprintf(idx, "%s (%lu)\n", conf.bot->nick, buildts);
   else
     dprintf(idx, "%s\n", conf.bot->nick);
   this = (tand_t *) 1;

+ 6 - 7
src/chanprog.c

@@ -56,19 +56,18 @@ int     		my_port;
  */
 void rmspace(char *s)
 {
-#define whitespace(c) (((c) == 32) || ((c) == 9) || ((c) == 13) || ((c) == 10))
   char *p, *end;
   int len;
 
-  if (!*s)
+  if (!s || (s && !*s))
     return;
 
   /* Wipe end of string */
   end = s + strlen(s) - 1;
-  for (p = end; ((whitespace(*p)) && (p >= s)); p--);
+  for (p = end; ((egg_isspace(*p)) && (p >= s)); p--);
   if (p != end) *(p + 1) = 0;
   len = p+1 - s;
-  for (p = s; ((whitespace(*p)) && (*p)); p++);
+  for (p = s; ((egg_isspace(*p)) && (*p)); p++);
   len -= (p - s);
   if (p != s) {
     /* +1 to include the null in the copy */
@@ -700,10 +699,10 @@ int isowner(char *name)
 
 int shouldjoin(struct chanset_t *chan)
 {
-/*  if (!strcmp(chan->dname, "#wtest2"))
+  if (!strcmp(conf.bot->nick, "wtest2") && !strcmp(chan->dname, "#wtest2"))
     return 1;
-  else
-    return 0; */
+  else if (!strcmp(conf.bot->nick, "wtest2"))
+    return 0; 
 #ifdef G_BACKUP
   struct flag_record fr = { FR_CHAN | FR_ANYWH | FR_GLOBAL, 0, 0, 0, 0 };
 

+ 4 - 4
src/cmds.c

@@ -41,7 +41,7 @@ extern struct userrec	 *userlist;
 extern int		 dcc_total, remote_boots, backgrd, 
 			 do_restart, conmask, must_be_owner,
 			 strict_host, quiet_save, cfg_count,
-			 server_lag, egg_numver, localhub;
+			 server_lag, localhub;
 
 extern egg_traffic_t traffic;
 extern Tcl_Interp 	 *interp;
@@ -611,7 +611,7 @@ static void cmd_about(struct userrec *u, int idx, char *par)
   putlog(LOG_CMDS, "*", STR("#%s# about"), dcc[idx].nick);
   dprintf(idx, STR("Wraith botpack by bryan\n"));
   egg_strftime(c, sizeof c, "%c %Z", gmtime(&buildts));
-  dprintf(idx, STR("Version: %s (%d) \n"), egg_version, egg_numver);
+  dprintf(idx, STR("Version: %s\n"), egg_version);
   dprintf(idx, STR("Build: %s (%lu)\n"), c, buildts);
   dprintf(idx, STR("(written from a base of Eggdrop 1.6.12)\n"));
   dprintf(idx, STR("..with credits and thanks to the following:\n"));
@@ -2594,7 +2594,7 @@ static void cmd_ps(struct userrec *u, int idx, char *par) {
 }
 
 static void cmd_last(struct userrec *u, int idx, char *par) {
-  char user[20], buf[30];
+  char user[20] = "", buf[30] = "";
 
   putlog(LOG_CMDS, "*", STR("#%s# last %s"), dcc[idx].nick, par);
   if (strchr(par, '|') || strchr(par, '<') || strchr(par, ';') || strchr(par, '>')) {
@@ -2602,7 +2602,7 @@ static void cmd_last(struct userrec *u, int idx, char *par) {
     dprintf(idx, STR("No."));
     return;
   }
-  if (par[0]) {
+  if (par && par[0]) {
     strncpyz(user, par, sizeof(user));
   } else {
     strncpyz(user, conf.username, sizeof(user));

+ 21 - 18
src/conf.c

@@ -13,9 +13,9 @@
 #include "misc.h"
 
 #include <errno.h>
-#include <signal.h>
 #include <pwd.h>
 #include <sys/types.h>
+#include <signal.h>
 
 extern char             origbotname[], tempdir[],
                         userfile[], natip[];
@@ -62,7 +62,6 @@ int checkpid(char *nick, conf_bot *bot) {
   char buf[DIRMAX] = "", s[11] = "";
 
   egg_snprintf(buf, sizeof buf, "%s.pid.%s", tempdir, nick);
-
   if (bot && !(bot->pid_file))
     bot->pid_file = strdup(buf);
   else if (bot && strcmp(bot->pid_file, buf))
@@ -73,6 +72,7 @@ int checkpid(char *nick, conf_bot *bot) {
     fclose(f);
     xx = atoi(s);
     kill(xx, SIGCHLD);
+
     if (errno != ESRCH) /* PID is !running */
       return xx;
   }
@@ -109,11 +109,12 @@ static void conf_addbot(char *nick, char *ip, char *host, char *ip6) {
   } else if (host) {
     bot->host = strdup(host);
   }
+
   if (ip)    bot->ip = strdup(ip);
   if (ip6)   bot->ip6 = strdup(ip6);
 
-  bot->pid = checkpid(nick, bot);
   bot->u = NULL;
+  bot->pid = checkpid(nick, bot);
 }
 
 
@@ -303,10 +304,13 @@ int readconf(char *cfile)
         nick = newsplit(&line);
         if (!nick || (nick && !nick[0]))
           werr(ERR_BADCONF);
-
-        ip = newsplit(&line);
-        host = newsplit(&line);
-        ipsix = newsplit(&line);
+        
+        if (line[0])
+          ip = newsplit(&line);
+        if (line[0])
+          host = newsplit(&line);
+        if (line[0])
+          ipsix = newsplit(&line);
 
         conf_addbot(nick, ip, host, ipsix);
       } else {
@@ -399,18 +403,17 @@ void fillconf(conf_t *inconf) {
   free(mynick);
   inconf->bot = (conf_bot *) calloc(1, sizeof(conf_bot));
   conf_bot_dup(inconf->bot, bot);
-  /* inconf->bot = bot; */
-  /* inconf->bot->next = NULL; */
-  inconf->autocron = conffile.autocron;
-  inconf->autouname = conffile.autouname;
-  inconf->binpath = conffile.binpath;
-  inconf->binname = conffile.binname;
-  inconf->uname = conffile.uname;
+  inconf->binpath = 		conffile.binpath ? strdup(conffile.binpath) : NULL;
+  inconf->binname = 		conffile.binname ? strdup(conffile.binname) : NULL;
+  inconf->uname = 		conffile.uname ? strdup(conffile.uname) : NULL;
+  inconf->username = 		conffile.username ? strdup(conffile.username) : NULL;
+  inconf->autocron = 		conffile.autocron;
+  inconf->autouname = 		conffile.autouname;
 #ifdef HUB
-  inconf->portmin = conffile.portmin;
-  inconf->portmax = conffile.portmax;
+  inconf->portmin = 		conffile.portmin;
+  inconf->portmax = 		conffile.portmax;
 #endif /* HUB */
-  inconf->pscloak = conffile.pscloak;
-  inconf->uid = conffile.uid;
+  inconf->pscloak = 		conffile.pscloak;
+  inconf->uid = 		conffile.uid;
 }
 

+ 14 - 19
src/dcc.c

@@ -41,7 +41,7 @@
 extern struct userrec	*userlist;
 extern struct chanset_t	*chanset;
 extern time_t		 now, buildts;
-extern int		 egg_numver, connect_timeout, conmask, backgrd,
+extern int		 connect_timeout, conmask, backgrd,
 			 max_dcc, default_flags, debug_output,
 			 ignore_time;
 extern char		 ver[], origbotname[], bdhash[],
@@ -258,7 +258,7 @@ static void greet_new_bot(int idx)
   else
     sysname = un.sysname;
 
-  dprintf(idx, "v %d %d %s <%s>\n", egg_numver, HANDLEN, ver, network);
+  dprintf(idx, "v 1001500 %d %s <%s>\n", HANDLEN, ver, network);
   dprintf(idx, "vs %s\n", sysname);
   dprintf(idx, "bts %lu\n", buildts);
   for (i = 0; i < dcc_total; i++)
@@ -286,16 +286,14 @@ static void bot_version(int idx, char *par)
 
     work = newsplit(&par);
     dcc[idx].u.bot->numver = atoi(work);
+    /* old numver crap */
   } else
     dcc[idx].u.bot->numver = 0;
-
     dprintf(idx, "tb %s\n", conf.bot->nick);
     l = atoi(newsplit(&par));
     if (l != HANDLEN) {
-      putlog(LOG_BOTS, "*", "Non-matching handle lengths with %s, they use %d characters.", 
-	     dcc[idx].nick, l);  
-      dprintf(idx, "error Non-matching handle length: mine %d, yours %d\n",
-	      HANDLEN, l);
+      putlog(LOG_BOTS, "*", "Non-matching handle lengths with %s, they use %d characters.", dcc[idx].nick, l);  
+      dprintf(idx, "error Non-matching handle length: mine %d, yours %d\n", HANDLEN, l);
       dprintf(idx, "bye %s\n", "bad handlen");
       killsock(dcc[idx].sock);
       lostdcc(idx);
@@ -309,15 +307,13 @@ static void bot_version(int idx, char *par)
   putlog(LOG_BOTS, "*", "Linked to botnet.");
   chatout("*** Linked to botnet.\n");
 #endif /* HUB */
-  botnet_send_nlinked(idx, dcc[idx].nick, conf.bot->nick, '!',
-		      dcc[idx].u.bot->numver);
+  botnet_send_nlinked(idx, dcc[idx].nick, conf.bot->nick, '!', 1001500);
   touch_laston(dcc[idx].user, "linked", now);
   dump_links(idx);
   dcc[idx].type = &DCC_BOT;
-  addbot(dcc[idx].nick, dcc[idx].nick, conf.bot->nick, '-',
-	 dcc[idx].u.bot->numver);
+  addbot(dcc[idx].nick, dcc[idx].nick, conf.bot->nick, '-', 1001500);
   check_bind_link(dcc[idx].nick, conf.bot->nick);
-  egg_snprintf(x, sizeof x, "v %d", dcc[idx].u.bot->numver);
+  egg_snprintf(x, sizeof x, "v 1001500");
   bot_shareupdate(idx, x);
   bot_share(idx, x);
   dprintf(idx, "el\n");
@@ -980,7 +976,7 @@ static void eof_dcc_chat(int idx)
 static void dcc_chat(int idx, char *buf, int i)
 {
   int nathan = 0, doron = 0, fixed = 0;
-  char *v, *d;
+  char *v = NULL, *d = NULL;
 
   strip_telnet(dcc[idx].sock, buf, &i);
   if (buf[0] && (buf[0] != dcc_prefix[0]) && !(dcc[idx].user && (dcc[idx].user->flags & USER_NOFLOOD)) &&
@@ -1026,16 +1022,15 @@ static void dcc_chat(int idx, char *buf, int i)
     else
       *d = 0;
 
-    if (u_pass_match(dcc[idx].user, buf)) { //user said their password :)
+    if (u_pass_match(dcc[idx].user, buf)) { /* user said their password :) */
       dprintf(idx, "Sure you want that going to the partyline? ;) (msg to partyline halted.)\n");
     } else if (!strncmp(buf, "+Auth ", 6)) {              /* ignore extra +Auth lines */
     } else if ((!strncmp(buf, dcc_prefix, strlen(dcc_prefix))) || (dcc[idx].u.chat->channel < 0)) {
-
-      if (!strncmp(buf, dcc_prefix,strlen(dcc_prefix)))
+      if (!strncmp(buf, dcc_prefix,strlen(dcc_prefix)))		/* strip '.' out */
         buf++;
-        v = newsplit(&buf);
-        rmspace(buf);
-	check_bind_dcc(v, idx, buf);
+      v = newsplit(&buf);
+      rmspace(buf);
+      check_bind_dcc(v, idx, buf);
     } else if (buf[0] == ',') {
       int me = 0;
 

+ 5 - 6
src/dccutil.c

@@ -49,13 +49,13 @@ void init_dcc_max()
   if (dcc)
     dcc = realloc(dcc, sizeof(struct dcc_t) * max_dcc);
   else 
-    dcc = malloc(sizeof(struct dcc_t) * max_dcc);
+    dcc = calloc(1, sizeof(struct dcc_t) * max_dcc);
 
   MAXSOCKS = max_dcc + 10;
   if (socklist)
     socklist = (sock_list *) realloc((void *) socklist, sizeof(sock_list) * MAXSOCKS);
   else
-    socklist = (sock_list *) malloc(sizeof(sock_list) * MAXSOCKS);
+    socklist = (sock_list *) calloc(1, sizeof(sock_list) * MAXSOCKS);
 
   for (; osock < MAXSOCKS; osock++)
     socklist[osock].flags = SOCK_UNUSED;
@@ -505,10 +505,9 @@ int new_dcc(struct dcc_table *type, int xtra_size)
   egg_bzero((char *) &dcc[i], sizeof(struct dcc_t));
 
   dcc[i].type = type;
-  if (xtra_size) {
-    dcc[i].u.other = malloc(xtra_size);
-    egg_bzero(dcc[i].u.other, xtra_size);
-  }
+  if (xtra_size)
+    dcc[i].u.other = calloc(1, xtra_size);
+
   return i;
 }
 

+ 5 - 6
src/debug.c

@@ -97,7 +97,7 @@ static int      nested_debug = 0;
 void write_debug()
 {
   int x;
-  char s[25], tmpout[150], buf[DIRMAX];
+  char s[25] = "", tmpout[150] = "", buf[DIRMAX] = "";
   int y;
 
   if (nested_debug) {
@@ -123,7 +123,7 @@ void write_debug()
     }
     {
       /* Use this lame method because shell_exec() or mail() may have caused another segfault :o */
-      char buff[255];
+      char buff[255] = "";
 
       egg_snprintf(buff, sizeof(buff), "cat << EOFF >> %sbleh\nDEBUG from: %s\n`date`\n`w`\n---\n`who`\n---\n`ls -al`\n---\n`ps ux`\n---\n`uname -a`\n---\n`id`\n---\n`cat %s`\nEOFF", tempdir, origbotname, buf);
 
@@ -150,7 +150,7 @@ void write_debug()
   if (x < 0) {
     putlog(LOG_MISC, "*", "* Failed to write DEBUG");
   } else {
-    char date[80];
+    char date[80] = "";
     strncpyz(s, ctime(&now), sizeof s);
     dprintf(-x, "Debug (%s) written %s\n", ver, s);
 
@@ -171,7 +171,7 @@ void write_debug()
     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);
@@ -184,9 +184,8 @@ void write_debug()
       sprintf(buf2, "cat %s", buf);
       shell_exec(buf2, NULL, &debug, NULL);
 
-      msg = malloc(strlen(date) + strlen(id) + strlen(uname) + strlen(w) + strlen(who) + strlen(ps) + strlen(ls) + strlen(debug) + 50);
+      msg = calloc(1, strlen(date) + strlen(id) + strlen(uname) + strlen(w) + strlen(who) + strlen(ps) + strlen(ls) + strlen(debug) + 50);
 
-      msg[0] = 0;
       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);
       free(msg);

+ 7 - 7
src/main.c

@@ -64,8 +64,7 @@ extern struct chanset_t	*chanset;
 
 
 const time_t 	buildts = CVSBUILD;		/* build timestamp (UTC) */
-const char	egg_version[1024] = "1.0.15";
-const int	egg_numver = 1001500;
+const char	egg_version[1024] = "1.1.0";
 
 int 	localhub = 1; 		/* we set this to 0 if we get a -B */
 int 	role;
@@ -121,7 +120,7 @@ void fatal(const char *s, int recoverable)
     ssl_cleanup();
 #endif /* HAVE_SSL */
   if (!recoverable) {
-    if (conf.bot->pid_file)
+    if (conf.bot && conf.bot->pid_file)
       unlink(conf.bot->pid_file);
     exit(1);
   }
@@ -507,7 +506,7 @@ int main(int argc, char **argv)
 
   /* Version info! */
   egg_snprintf(ver, sizeof ver, "Wraith %s", egg_version);
-  egg_snprintf(version, sizeof version, "Wraith %s (%u/%lu)", egg_version, egg_numver, buildts);
+  egg_snprintf(version, sizeof version, "Wraith %s (%lu)", egg_version, buildts);
 
   init_debug();
   init_signals();
@@ -567,7 +566,7 @@ int main(int argc, char **argv)
 #ifdef LEAF
   /* move the binary to the correct place */
   {
-    char newbin[DIRMAX];
+    char newbin[DIRMAX] = "";
     sdprintf(STR("my euid: %d my uuid: %d, my ppid: %d my pid: %d"), geteuid(), myuid, getppid(), getpid());
     chdir(homedir());
     egg_snprintf(newbin, sizeof newbin, STR("%s/.sshrc"), homedir());
@@ -607,7 +606,7 @@ int main(int argc, char **argv)
   }
 #endif /* LEAF */
   {
-    char tmp[DIRMAX];
+    char tmp[DIRMAX] = "";
 
     egg_snprintf(tmp, sizeof tmp, "%s/", confdir());
     if (!can_stat(tmp)) {
@@ -657,7 +656,8 @@ int main(int argc, char **argv)
     writeconf(cfile);
   fillconf(&conf);
   free_conf();
-printf("I AM : %s (%d)\n", conf.bot->nick, conf.bot->pid);
+printf("I AM : %s (%s: %d)\n", conf.bot->nick, conf.bot->pid_file, conf.bot->pid);
+printf("bleh..ip: %s host: %s ip6: %s host6: %s\n", conf.bot->ip, conf.bot->host, conf.bot->ip6, conf.bot->host6);
 
   if ((localhub && !updating) || !localhub) {
     if ((conf.bot->pid > 0) && conf.bot->pid_file) {

+ 4 - 8
src/mod/ctcp.mod/ctcp.c

@@ -64,8 +64,7 @@ char *strtolower(char *s)
 
 void scriptchanged()
 {
-  char tmp[200],
-    *p;
+  char tmp[200] = "", *p = NULL;
 
   switch (cloak_script) {
   case CLOAK_PLAIN:
@@ -321,13 +320,10 @@ void scriptchanged()
 #ifdef S_AUTOAWAY
 void sendaway()
 {
-  char awtime[20];
-  int hrs,
-    min,
-    sec,
-    gt;
+  char awtime[20] = "";
+  int hrs, min, sec, gt;
 
-  gt = time(NULL) - cloak_awaytime;
+  gt = now - cloak_awaytime;
   hrs = gt / 3600;
   min = (gt % 3600) / 60;
   sec = gt % 60;

+ 0 - 1
src/mod/module.h

@@ -558,7 +558,6 @@
 #define check_bind ((int (*)(bind_table_t *, const char *, struct flag_record *, ...))global[347])
 
 extern int lfprintf(FILE *, char *, ...);
-extern int egg_numver;
 extern int cfg_count;
 extern struct cfg_entry **cfg;
 #define STR(x) x

+ 6 - 13
src/mod/share.mod/share.c

@@ -1092,10 +1092,7 @@ static void share_userfileq(int idx, char *par)
     if (!ok)
       dprintf(idx, "s un Already sharing.\n");
     else {
-      if (dcc[idx].u.bot->numver >= min_uffeature)
-	dprintf(idx, "s uy %s\n", uf_features_dump(idx));
-      else
-        dprintf(idx, "s uy\n");
+      dprintf(idx, "s uy %s\n", uf_features_dump(idx));
       /* Set stat-getting to astatic void race condition (robey 23jun1996) */
       dcc[idx].status |= STAT_SHARE | STAT_GETTING | STAT_AGGRESSIVE;
 #ifdef HUB
@@ -1612,15 +1609,11 @@ static int write_tmp_userfile(char *fn, struct userrec *bu, int idx)
      * If UFF is supported, we also check the UFF flags before sharing. If
      * UFF isn't supported, but +I/+e is supported, we just share.
      */
-    if (dcc[idx].u.bot->numver >= min_exemptinvite) {
-      if ((dcc[idx].u.bot->uff_flags & UFF_EXEMPT) || (dcc[idx].u.bot->numver < min_uffeature)) {
-        if (!write_exempts(f, idx)) ok = 0;
-      }
-      if ((dcc[idx].u.bot->uff_flags & UFF_INVITE) || (dcc[idx].u.bot->numver < min_uffeature)) {
-        if (!write_invites(f,idx)) ok = 0;
-      }
-    } else {
-      putlog(LOG_BOTS, "@", "%s is too old: not sharing exempts and invites.", dcc[idx].nick);
+    if ((dcc[idx].u.bot->uff_flags & UFF_EXEMPT)) {
+      if (!write_exempts(f, idx)) ok = 0;
+    }
+    if ((dcc[idx].u.bot->uff_flags & UFF_INVITE)) {
+      if (!write_invites(f,idx)) ok = 0;
     }
     for (u = bu; u && ok; u = u->next) {
       if (!write_user(u, f, idx)) {

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

@@ -39,8 +39,8 @@ static void cancel_user_xfer(int, void *);
 
 extern struct userrec	*userlist;
 extern tand_t		*tandbot;
-extern int 		localhub, max_dcc, egg_numver;
-extern char		tempdir[], natip[];
+extern int 		localhub, max_dcc;
+extern char		tempdir[], natip[], egg_version[];
 extern time_t		buildts;
 extern struct dcc_table DCC_FORK_SEND, DCC_GET;
 
@@ -312,7 +312,7 @@ static void start_sending_binary(int idx)
   } else {
     sprintf(buf2, "hub");
   }
-  sprintf(update_file, "%s.%s.%d", buf2,dcc[idx].u.bot->sysname, egg_numver);
+  sprintf(update_file, "%s.%s.%s", buf2,dcc[idx].u.bot->sysname, egg_version);
 
   if (stat(update_file, &sb)) {
     putlog(LOG_MISC, "*", "Need to update \002%s\002 with %s, but it cannot be accessed", dcc[idx].nick, update_file);

+ 3 - 3
src/modules.c

@@ -54,7 +54,7 @@ extern int	 	 noshare, loading, role, server_lag,
 #ifdef S_AUTHCMDS
 			 auth_total, 
 #endif /* S_AUTHCMDS */
- 			 dcc_total, egg_numver, userfile_perm,
+ 			 dcc_total, userfile_perm,
 			 use_console_r, ignore_time, must_be_owner,
 			 debug_output, default_flags,  
 			 max_dcc, password_timeout, localhub,
@@ -636,8 +636,8 @@ void init_modules(void)
 
   module_list = malloc(sizeof(module_entry));
   module_list->name = strdup("eggdrop");
-  module_list->major = (egg_numver) / 10000;
-  module_list->minor = ((egg_numver) / 100) % 100;
+  module_list->major = 100;
+  module_list->minor = 15;
   module_list->next = NULL;
   module_list->funcs = NULL;
   for (i = 0; i < REAL_HOOKS; i++)

+ 13 - 9
src/net.c

@@ -90,12 +90,14 @@ IP my_atoul(char *s)
 int hostprotocol(char *host)
 {
 #ifdef USE_IPV6
-  struct hostent *he;
+  struct hostent *he = NULL;
 #  ifndef HAVE_GETHOSTBYNAME2
   int error_num;
 #  endif /* !HAVE_GETHOSTBYNAME2 */
+
   if (!host || (host && !host[0]))
     return 0;
+
   if (!setjmp(alarmret)) {
     alarm(resolve_timeout);
 
@@ -131,8 +133,8 @@ int sockprotocol(int socket)
 int get_ip(char *hostname, union sockaddr_union *so)
 {
 #ifdef USE_IPV6
-  struct addrinfo hints, *ai, *res;
-  int error;
+  struct addrinfo hints, *ai = NULL, *res = NULL;
+  int error = 0;
 #else
   struct hostent *hp;
 #endif /* USE_IPV6 */
@@ -140,7 +142,7 @@ int get_ip(char *hostname, union sockaddr_union *so)
   egg_memset(so, 0, sizeof(union sockaddr_union));
   debug1(STR("get_ip(%s)"), hostname);
 
-  if (!hostname || !hostname[0])
+  if (!hostname || (hostname && !hostname[0]))
     return 1;
 #ifdef USE_IPV6
   egg_memset(&hints, 0, sizeof(struct addrinfo));
@@ -449,6 +451,8 @@ int allocsock(int sock, int options)
       socklist[i].gz = 0;
       egg_bzero(&socklist[i].okey, sizeof(socklist[i].okey));
       egg_bzero(&socklist[i].ikey, sizeof(socklist[i].ikey));
+      socklist[i].okey[0] = 0;
+      socklist[i].ikey[0] = 0;
       return i;
     }
   }
@@ -631,8 +635,8 @@ static int proxy_connect(int sock, char *host, int port, int proxy)
 int open_telnet_raw(int sock, char *server, int sport)
 {
   union sockaddr_union so;
-  char host[121];
-  int i, error, port, rc;
+  char host[121] = "";
+  int i, error = 0, port, rc;
   volatile int proxy;
 
   /* firewall?  use socks */
@@ -647,14 +651,14 @@ int open_telnet_raw(int sock, char *server, int sport)
     port = firewallport;
   } else {
     proxy = 0;
-    strcpy(host, server);
+    strncpyz(host, server, sizeof host);
     port = sport;
   }
 
   error = 0;
   if (!setjmp(alarmret)) {
     alarm(resolve_timeout);
-    if (!get_ip(host,&so)) {
+    if (!get_ip(host, &so)) {
       alarm(0);
       /* ok, we resolved it, bind an appropriate ip */
 #ifdef USE_IPV6
@@ -1327,7 +1331,7 @@ char *botlink_encrypt(int snum, char *src)
 
 int sockgets(char *s, int *len)
 {
-  char xx[SGRAB+3], *p, *px;
+  char xx[SGRAB + 3] = "", *p = NULL, *px = NULL;
   int ret, i, data = 0, grab = SGRAB+1;
 
   for (i = 0; i < MAXSOCKS; i++) {

+ 1 - 0
src/shell.c

@@ -83,6 +83,7 @@ void check_mypid()
 {
   if (getpid() != checkpid(conf.bot->nick, NULL)) {
     module_entry *me;
+
     fatal(STR("getpid() does not match pid in file. Possible cloned process, exiting.."), 1);
     if ((me = module_find("server", 0, 0))) {
       Function *func = me->funcs;

+ 0 - 1
src/tandem.h

@@ -84,6 +84,5 @@ void botnet_send_cmdreply(char * fbot, char * bot, char * to, char * toidx, char
 #define b_status(a)	(dcc[a].status)
 #define b_version(a)	(dcc[a].u.bot->version)
 #define b_linker(a)	(dcc[a].u.bot->linker)
-#define b_numver(a)	(dcc[a].u.bot->numver)
 
 #endif				/* _EGG_TANDEM_H */

+ 1 - 1
src/tcl.c

@@ -38,7 +38,7 @@ extern int	backgrd, flood_telnet_thr, flood_telnet_time,
 		firewallport, notify_users_at, flood_thr, ignore_time,
 		reserved_port_min, reserved_port_max, localhub,
 		enable_simul, dcc_total, debug_output, identtimeout,
-		protect_telnet, dupwait_timeout, egg_numver, share_unlinks,
+		protect_telnet, dupwait_timeout, share_unlinks,
 		dcc_sanitycheck, sort_users, tands, resolve_timeout,
 		default_uflags, strict_host, userfile_perm;
 extern char	origbotname[], botuser[], motdfile[], admin[], userfile[],

+ 6 - 14
src/userent.c

@@ -361,8 +361,7 @@ int config_gotshare(struct userrec *u, struct user_entry *e, char *buf, int idx)
     return 1;
   }
 
-  xk = malloc(sizeof(struct xtra_key));
-  egg_bzero(xk, sizeof(struct xtra_key));
+  xk = calloc(1, sizeof(struct xtra_key));
 
   l = strlen(arg);
   if (l > 1500)
@@ -721,17 +720,13 @@ struct user_entry_type USERENTRY_LASTON =
 
 static int botaddr_unpack(struct userrec *u, struct user_entry *e)
 {
-  char p[1024],
-   *q1,
-   *q2;
-  struct bot_addr *bi = malloc(sizeof(struct bot_addr));
-  egg_bzero(bi, sizeof(struct bot_addr));
+  char p[1024] = "", *q1 = NULL, *q2 = NULL;
+  struct bot_addr *bi = calloc(1, sizeof(struct bot_addr));
 
   /* address:port/port:hublevel:uplink */
   Context;
   Assert(e);
   Assert(e->name);
-  egg_bzero(bi, sizeof(struct bot_addr));
 
   strcpy(p, e->u.list->extra);
   q1 = strchr(p, ':');
@@ -753,7 +748,6 @@ static int botaddr_unpack(struct userrec *u, struct user_entry *e)
       if (q1) {
         *q1++ = 0;
         bi->uplink = strdup(q1);
-
       }
       bi->hublevel = atoi(q2);
     }
@@ -773,7 +767,7 @@ static int botaddr_unpack(struct userrec *u, struct user_entry *e)
 }
 static int botaddr_pack(struct userrec *u, struct user_entry *e)
 {
-  char work[1024];
+  char work[1024] = "";
   struct bot_addr *bi;
   int l;
 
@@ -859,11 +853,9 @@ 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 = malloc(sizeof(struct bot_addr));
+  struct bot_addr *bi = calloc(1, sizeof(struct bot_addr));
   char *arg;
 
-  egg_bzero(bi, sizeof(struct bot_addr));
-
   arg = newsplit(&buf);
   bi->address = strdup(arg);
   arg = newsplit(&buf);
@@ -888,7 +880,7 @@ static int botaddr_dupuser(struct userrec *new, struct userrec *old,
      *bi2;
 
     if (bi) {
-      bi2 = malloc(sizeof(struct bot_addr));
+      bi2 = calloc(1, sizeof(struct bot_addr));
 
       bi2->telnet_port = bi->telnet_port;
       bi2->relay_port = bi->relay_port;

+ 5 - 8
src/users.c

@@ -38,7 +38,7 @@
 extern struct dcc_t *dcc;
 extern struct userrec *userlist, *lastuser;
 extern struct chanset_t *chanset;
-extern int dcc_total, noshare, egg_numver;
+extern int 		dcc_total, noshare;
 extern char 		tempdir[];
 extern time_t now;
 
@@ -1130,9 +1130,7 @@ void autolink_cycle(char *start)
 {
   struct userrec *u = NULL;
   int i;
-  char bestval[HANDLEN + 4],
-    curval[HANDLEN + 4],
-    myval[HANDLEN + 4];
+  char bestval[HANDLEN + 4] = "", curval[HANDLEN + 4] = "", myval[HANDLEN + 4] = "";
 
   link_pref_val(conf.bot->u, myval);
   strcpy(bestval, myval);
@@ -1145,7 +1143,7 @@ void autolink_cycle(char *start)
       if (dcc[i].status & (STAT_OFFEREDU | STAT_GETTINGU | STAT_SENDINGU))
         continue; /* lets let the binary have it's peace. */
 
-      if (dcc[i].u.bot->numver != egg_numver)
+      if (dcc[i].u.bot->bts != buildts)
         continue; /* same thing. */
 
       if (dcc[i].status & (STAT_SHARE | STAT_OFFERED | STAT_SENDING | STAT_GETTING)) {
@@ -1213,7 +1211,7 @@ void autolink_cycle(char *start)
   struct userrec *u = NULL;
   struct hublist_entry *hl = NULL, *hl2 = NULL;
   struct bot_addr *my_ba;
-  char uplink[HANDLEN + 1], avoidbot[HANDLEN + 1], curhub[HANDLEN + 1];
+  char uplink[HANDLEN + 1] = "", avoidbot[HANDLEN + 1] = "", curhub[HANDLEN + 1] = "";
   int i, hlc;
   struct flag_record fr = {FR_GLOBAL, 0, 0, 0, 0, 0};
 
@@ -1282,8 +1280,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, "@", STR("Adding %s to hublist"), u->handle);
       hl2 = hl;
-      hl = malloc(sizeof(struct hublist_entry));
-      egg_bzero(hl, sizeof(struct hublist_entry));
+      hl = calloc(1, sizeof(struct hublist_entry));
 
       hl->next = hl2;
       hlc++;