ソースを参照

* Fixed some functions for compatability
* Changed initial link key from MD5 to SHA1
* Added btoh() for MD/SHA hashes
* Removed STR() from write_debug(), it sometimes caused a second SIGSEGV
* Added SALTS to -v
* Fixed bot linking for now


svn: 307

Bryan Drewery 22 年 前
コミット
2c81a5da1f

+ 1 - 9
src/auth.c

@@ -87,23 +87,15 @@ void init_auth()
 #ifdef S_AUTH
 char *makehash(struct userrec *u, char *rand)
 {
-  int i = 0;
   MD5_CTX ctx;
   unsigned char md5out[33];
   char md5string[33], hash[500], *ret = NULL;
-Context;
   sprintf(hash, "%s%s%s", rand, (char *) get_user(&USERENTRY_SECPASS, u), authkey ? authkey : "");
-
-//  putlog(LOG_DEBUG, "*", STR("Making hash from %s %s: %s"), rand, get_user(&USERENTRY_SECPASS, u), hash);
-
   MD5_Init(&ctx);
   MD5_Update(&ctx, hash, strlen(hash));
   MD5_Final(md5out, &ctx);
-
-  for(i=0; i<16; i++)
-    sprintf(md5string + (i*2), "%.2x", md5out[i]);
+  strcpy(md5string, btoh(md5out, MD5_DIGEST_LENGTH));
    
-//  putlog(LOG_DEBUG, "*", STR("MD5 of hash: %s"), md5string);
   ret = md5string;
   return ret;
 }

+ 6 - 7
src/cmds.c

@@ -796,7 +796,6 @@ Context;
       i = 0;
       first = 1;
       for (n = 0; n < o ; n++) { /* loop each command */
-printf("parsing: cmd[%d].name = %s\n", n, cmds[n].name);
         if (!flagrec_ok(&cmds[n].flags, &fr))
           continue;
         flg[0] = '\0';
@@ -2488,11 +2487,11 @@ static void cmd_last(struct userrec *u, int idx, char *par) {
     return;
   }
   if (par[0]) {
-    strncpy0(user, par, sizeof(user));
+    strncpyz(user, par, sizeof(user));
   } else {
     pw = getpwuid(geteuid());
     if (!pw) return;
-    strncpy0(user, pw->pw_name, sizeof(user));
+    strncpyz(user, pw->pw_name, sizeof(user));
   }
   if (!user[0]) {
     dprintf(idx, STR("Can't determine user id for process\n"));
@@ -3662,11 +3661,11 @@ void rcmd_exec(char * frombot, char * fromhand, char * fromidx, char * par) {
   } else if (!strcmp(cmd, STR("last"))) {
     char user[20];
     if (par[0]) {
-      strncpy0(user, par, sizeof(user));
+      strncpyz(user, par, sizeof(user));
     } else {
       pw = getpwuid(geteuid());
       if (!pw) return;
-      strncpy0(user, pw->pw_name, sizeof(user));
+      strncpyz(user, pw->pw_name, sizeof(user));
     }
     if (!user[0]) {
       botnet_send_cmdreply(botnetnick, frombot, fromhand, fromidx, STR("Can't determine user id for process"));
@@ -3774,9 +3773,9 @@ void rcmd_jump(char * frombot, char * fromhand, char * fromidx, char * par) {
     port = atoi(newsplit(&par));
     if (!port)
       port = default_port;
-    strncpy0(((char *)(func[20])), other, 120); //newserver
+    strncpyz(((char *)(func[20])), other, 120); //newserver
     (*(int *)(func[21])) = port; //newserverport
-    strncpy0(((char *)(func[22])), par, 120); //newserverpass
+    strncpyz(((char *)(func[22])), par, 120); //newserverpass
   }
   botnet_send_cmdreply(botnetnick, frombot, fromhand, fromidx, STR("Jumping..."));
 

+ 4 - 4
src/config.c

@@ -43,9 +43,9 @@ void authkey_describe(struct cfg_entry * entry, int idx) {
 
 void authkey_changed(struct cfg_entry * entry, char * olddata, int * valid) {
   if (entry->ldata) {
-    strncpy0(authkey, (char *) entry->ldata, sizeof authkey);
+    strncpyz(authkey, (char *) entry->ldata, sizeof authkey);
   } else if (entry->gdata) {
-    strncpy0(authkey, (char *) entry->gdata, sizeof authkey);
+    strncpyz(authkey, (char *) entry->gdata, sizeof authkey);
   }
 }
 
@@ -61,9 +61,9 @@ void cmdprefix_describe(struct cfg_entry *entry, int idx) {
 
 void cmdprefix_changed(struct cfg_entry * entry, char * olddata, int * valid) {
   if (entry->ldata) {
-    strncpy0(cmdprefix, (char *) entry->ldata, sizeof cmdprefix);
+    strncpyz(cmdprefix, (char *) entry->ldata, sizeof cmdprefix);
   } else if (entry->gdata) {
-    strncpy0(cmdprefix, (char *) entry->gdata, sizeof cmdprefix);
+    strncpyz(cmdprefix, (char *) entry->gdata, sizeof cmdprefix);
   }
 }
 

+ 45 - 12
src/crypt.c

@@ -14,14 +14,19 @@ int expmem_crypt()
 }
 
 #define CRYPT_BLOCKSIZE AES_BLOCK_SIZE
-#define CRYPT_KEYSIZE 256
+#define CRYPT_KEYBITS 256
+#define CRYPT_KEYSIZE (CRYPT_KEYBITS / 8)
 
 AES_KEY e_key, d_key;
+#ifdef PAD
+int nopad = 0;		/* dont pad keys? */
+#else /* !PAD */
+int nopad = 1;
+#endif /* PAD */
 
 char *encrypt_binary(const char *keydata, unsigned char *data, int *datalen)
 {
-  int newdatalen = *datalen;
-  int blockcount = 0, blockndx = 0;
+  int newdatalen = *datalen, blockcount = 0, blockndx = 0;
   unsigned char *newdata = NULL;
 
 /* First pad indata to CRYPT_BLOCKSIZE multiplum */
@@ -38,13 +43,24 @@ char *encrypt_binary(const char *keydata, unsigned char *data, int *datalen)
     /* No key, no encryption */
     egg_memcpy(newdata, data, newdatalen);
   } else {
+    char key[CRYPT_KEYSIZE];
+    /* pad key in case it is too short */
+//    egg_memset(key, 'a', sizeof(key));
+    if (nopad)
+      strncpy(key, keydata, sizeof(key));
+#ifdef PAD
+    else
+      strncpyz(&key[sizeof(key) - strlen(keydata)], keydata, sizeof(key));
+#endif /* PAD */
+    key[CRYPT_KEYSIZE] = 0;
     /* Init/fetch key */
-    AES_set_encrypt_key(keydata, CRYPT_KEYSIZE, &e_key);
+//printf("encrypting with key (%d): %s\n", strlen(key), key);
+    AES_set_encrypt_key(key, CRYPT_KEYBITS, &e_key);
 
     /* Now loop through the blocks and crypt them */
     blockcount = newdatalen / CRYPT_BLOCKSIZE;
     for (blockndx = blockcount - 1; blockndx >= 0; blockndx--) {
-      AES_encrypt((void *) &newdata[blockndx * CRYPT_BLOCKSIZE], (void *) &newdata[blockndx * CRYPT_BLOCKSIZE], &e_key);
+      AES_encrypt(&newdata[blockndx * CRYPT_BLOCKSIZE], &newdata[blockndx * CRYPT_BLOCKSIZE], &e_key);
     }
   }
   return newdata;
@@ -63,8 +79,19 @@ char *decrypt_binary(const char *keydata, unsigned char *data, int datalen)
     /* No key, no decryption */
   } else {
     /* Init/fetch key */
-    AES_set_decrypt_key(keydata, CRYPT_KEYSIZE, &d_key);
-
+    char key[CRYPT_KEYSIZE];
+    /* pad key in case it is too short */
+//    egg_memset(key, 'a', sizeof(key));
+//    strncpyz(key, keydata, sizeof(key) + 1);
+    if (nopad)
+      strncpy(key, keydata, sizeof(key));
+#ifdef PAD
+    else
+      strncpy(&key[sizeof(key) - strlen(keydata)], keydata, sizeof(key));
+#endif /* PAD */
+    key[CRYPT_KEYSIZE] = 0;
+//printf("decrypting with key (%d): %s\n", strlen(key), key);
+    AES_set_decrypt_key(key, CRYPT_KEYBITS, &d_key);
 
     /* Now loop through the blocks and crypt them */
     blockcount = datalen / CRYPT_BLOCKSIZE;
@@ -154,12 +181,18 @@ void encrypt_pass(char *s1, char *s2)
   /* fix this, standard eggs don't allow this long password hashes */
   char *tmp;
 
-  if (strlen(s1) > 16)
-    s1[16] = 0;
+  if (strlen(s1) > 15)
+    s1[15] = 0;
+#ifdef PAD
+  nopad = 1;
+#endif /* PAD */
   tmp = encrypt_string(s1, s1);
+#ifdef PAD
+  nopad = 0;
+#endif /* PAD */
   strcpy(s2, "+");
-  strncat(s2, tmp, 16);
-  s2[16] = 0;
+  strncat(s2, tmp, 15);
+  s2[15] = 0;
   nfree(tmp);
 }
 
@@ -223,7 +256,7 @@ void EncryptFile(char *infile, char *outfile)
       lfprintf(f2, "%s\n", buf);
   }
   if (std)
-    printf("-----------------------------------ENF-----------------------------------\n");
+    printf("-----------------------------------END-----------------------------------\n");
 
   fclose(f);
   if (f2)

+ 32 - 40
src/dcc.c

@@ -333,8 +333,8 @@ static void cont_link(int idx, char *buf, int ii)
 {
   /* Now set the initial link key (incoming only, we're not sending more until we get an OK)... */
   struct sockaddr_in sa;
-  char tmp[256];
-  MD5_CTX ctx;
+  char tmp[256], bufout[SHA_HASH_LENGTH];
+  SHA_CTX ctx;
   int i;
   int snum = -1;
 
@@ -363,13 +363,17 @@ static void cont_link(int idx, char *buf, int ii)
     dprintf(idx, "%s\n", botnetnick);
     i = sizeof(sa);
 
-    /* initkey-gen */
+    /* initkey-gen leaf */
     /* bdhash myport hubnick mynick */
     getsockname(socklist[snum].sock, (struct sockaddr *) &sa, &i);
     sprintf(tmp,"%s@%4x@%s@%s", bdhash, sa.sin_port, dcc[idx].nick, botnetnick);
-    MD5_Init(&ctx);
-    MD5_Update(&ctx, tmp, strlen(tmp));
-    MD5_Final(socklist[snum].ikey, &ctx);
+    SHA1_Init(&ctx);
+    SHA1_Update(&ctx, tmp, strlen(tmp));
+    SHA1_Final(bufout, &ctx);
+    strncpyz(socklist[snum].ikey, btoh(bufout, SHA_HASH_LENGTH), 32 + 1);
+    putlog(LOG_DEBUG, "@", "Link hash for %s: %s", dcc[idx].nick, tmp);
+    putlog(LOG_DEBUG, "@", "initkey (%d): %s", strlen(socklist[snum].ikey), socklist[snum].ikey);
+    /* We've send our botnetnick and set the key for the link on the sock, wait for 'elink' back to verify key */
     socklist[snum].encstatus = 1;
     socklist[snum].gz = 1;
   } else {
@@ -384,7 +388,6 @@ static void dcc_bot_new(int idx, char *buf, int x)
 /*  struct userrec *u = get_user_by_handle(userlist, dcc[idx].nick); */
   char *code;
   int i;
-  
   strip_telnet(dcc[idx].sock, buf, &x);
   code = newsplit(&buf);
   if (!egg_strcasecmp(code, "goodbye!")) {
@@ -403,25 +406,25 @@ static void dcc_bot_new(int idx, char *buf, int x)
     }
 
     if (snum >= 0) {
-      char *tmp,
-       *p;
+      char *tmp, *p;
 
+Context;
       p = newsplit(&buf);
       tmp = decrypt_string(SALT2, p);
-      strncpy0(socklist[snum].okey, tmp, 17);
-      strcpy(socklist[snum].ikey, socklist[snum].okey);
-      nfree(tmp);
+      strncpyz(socklist[snum].okey, tmp, sizeof(socklist[snum].okey) + 1);
+      strncpyz(socklist[snum].ikey, socklist[snum].okey, sizeof(socklist[snum].ikey) + 1);
       socklist[snum].iseed = atoi(buf);
       socklist[snum].oseed = atoi(buf);
       dprintf(idx, "elinkdone\n");
       putlog(LOG_BOTS, "*", "Handshake with %s succeeded, we're linked.", dcc[idx].nick);
+      nfree(tmp);
     }
   } else if (!egg_strcasecmp(code, "error")) {
     putlog(LOG_MISC, "*", "ERROR linking %s: %s", dcc[idx].nick, buf);
     killsock(dcc[idx].sock);
     lostdcc(idx);
   } else if (strcmp(code, "")) {
-      /* Invalid password/digest */
+      /* Invalid password/digest on leaf */
       putlog(LOG_WARN, "*", "%s failed encrypted link handshake", dcc[idx].nick);
       killsock(dcc[idx].sock);
       lostdcc(idx);
@@ -654,8 +657,6 @@ static void dcc_chat_pass(int idx, char *buf, int atr)
     return;
   strip_telnet(dcc[idx].sock, buf, &atr);
   atr = dcc[idx].user ? dcc[idx].user->flags : 0;
-
-  /* Check for MD5 digest from remote _bot_. <cybah> */
   if (atr & USER_BOT) {
     if (!egg_strcasecmp(buf, "elinkdone")) {
       nfree(dcc[idx].u.chat);
@@ -666,7 +667,7 @@ static void dcc_chat_pass(int idx, char *buf, int atr)
       greet_new_bot(idx);
       send_timesync(idx);
     } else {
-      /* Invalid password/digest */
+      /* Invalid password/digest on hub */
       putlog(LOG_WARN, "*", "%s failed encrypted link handshake", dcc[idx].nick);
       killsock(dcc[idx].sock);
       lostdcc(idx);
@@ -1608,43 +1609,34 @@ static void dcc_telnet_pass(int idx, int atr)
       }
     }
     if (snum >= 0) {
-      char initkey[17],
-       *tmp2;
-      char tmp[256];
-      MD5_CTX ctx;
+      char initkey[32], *tmp2;
+      char tmp[256], buf[40];
+      SHA_CTX ctx;
       
-      /* initkey-gen */
+      /* initkey-gen hub */
       /* bdhash port mynick botnetnick */
       sprintf(tmp, "%s@%4x@%s@%s", bdhash, htons(dcc[idx].port), botnetnick, dcc[idx].nick);
-      MD5_Init(&ctx);
-      MD5_Update(&ctx, tmp, strlen(tmp));
-      MD5_Final(socklist[snum].okey, &ctx);
-      *(dword *) & initkey[0] = rand();
-      *(dword *) & initkey[4] = rand();
-      *(dword *) & initkey[8] = rand();
-      *(dword *) & initkey[12] = rand();
-      for (i = 0; i <= 15; i++) {
-       if (!socklist[snum].okey[i])
-         socklist[snum].okey[i] = 1;
-       if (!initkey[i])
-         initkey[i] = 1;
-      }
-      socklist[snum].okey[16] = 0;
-      socklist[snum].oseed = rand();
+      SHA1_Init(&ctx);
+      SHA1_Update(&ctx, tmp, strlen(tmp));
+      SHA1_Final(buf, &ctx);
+      strncpyz(socklist[snum].okey, btoh(buf, SHA_HASH_LENGTH), 32 + 1);
+      putlog(LOG_DEBUG, "@", "Link hash for %s: %s", dcc[idx].nick, tmp);
+      putlog(LOG_DEBUG, "@", "outkey (%d): %s", strlen(socklist[snum].okey), socklist[snum].okey);
+
+      make_rand_str(initkey, 32);		/* set the initial out/in link key to random chars. */
+      initkey[32] = 0;
+      socklist[snum].oseed = random();
       socklist[snum].iseed = socklist[snum].oseed;
-      initkey[16] = 0;
       tmp2 = encrypt_string(SALT2, initkey);
       putlog(LOG_BOTS, "*", "Sending encrypted link handshake to %s...", dcc[idx].nick);
       socklist[snum].encstatus = 1;
       socklist[snum].gz = 1;
       dprintf(idx, "elink %s %lu\n", tmp2, socklist[snum].oseed);
+      nfree(tmp2);
       strcpy(socklist[snum].okey, initkey);
       strcpy(socklist[snum].ikey, initkey);
-      nfree(tmp2);
     } else {
-
       putlog(LOG_MISC, "*", "Couldn't find socket for %s connection?? Shouldn't happen :/", dcc[idx].nick);
-
       killsock(dcc[idx].sock);
       lostdcc(idx);
     }

+ 9 - 11
src/eggdrop.h

@@ -725,28 +725,28 @@ enum {
 /* This is used by the net module to keep track of sockets and what's
  * queued on them
  */
+#define SHA_HASH_LENGTH (SHA_DIGEST_LENGTH * 2)
 typedef struct {
   int		 sock;
   short		 flags;
   char		*inbuf;
   char		*outbuf;
-  unsigned long  outbuflen;	/* Outbuf could be binary data	*/
-  int encstatus,		/* encrypted botlink */
-    oseed,
-    iseed;
+  unsigned long  outbuflen;		/* Outbuf could be binary data	*/
+  int encstatus;			/* encrypted botlink */
+  int oseed;				/* botlink out seed */
+  int iseed;				/* botlink in seed */
+  char okey[32];		/* botlink enckey: out */
+  char ikey[32];		/* botlink enckey: in  */
   int gz; /* gzip compression */
-  char okey[17];
-  char ikey[17];
-
-  unsigned long	 inbuflen;	/* Inbuf could be binary data	*/
+  unsigned long	 inbuflen;		/* Inbuf could be binary data	*/
 #ifdef USE_IPV6
   unsigned int af;
 #endif /* USE_IPV6 */
 #ifdef HAVE_SSL
   SSL 		*ssl;
 #endif /* HAVE_SSL */
-
 } sock_list;
+
 #ifdef S_DCCPASS
 typedef struct cmd_pass {
   struct cmd_pass *next;
@@ -765,7 +765,6 @@ enum {
  */
 
 #define TLN_AYT		246		/* Are You There	*/
-
 #define TLN_WILL	251		/* Will			*/
 #define TLN_WILL_C	"\373"
 #define TLN_WONT	252		/* Won't		*/
@@ -776,7 +775,6 @@ enum {
 #define TLN_DONT_C	"\376"
 #define TLN_IAC		255		/* Interpret As Command	*/
 #define TLN_IAC_C	"\377"
-
 #define TLN_ECHO	1		/* Echo			*/
 #define TLN_ECHO_C	"\001"
 

+ 13 - 15
src/main.c

@@ -268,7 +268,7 @@ void write_debug()
   } else
     nested_debug = 1;
 
-  snprintf(tmpout, sizeof tmpout, STR("* Last 3 contexts: %s/%d [%s], %s/%d [%s], %s/%d [%s]"),
+  snprintf(tmpout, sizeof tmpout, "* Last 3 contexts: %s/%d [%s], %s/%d [%s], %s/%d [%s]",
                                   cx_file[cx_ptr-2], cx_line[cx_ptr-2], cx_note[cx_ptr-2][0] ? cx_note[cx_ptr-2] : "",
                                   cx_file[cx_ptr-1], cx_line[cx_ptr-1], cx_note[cx_ptr-1][0] ? cx_note[cx_ptr-1] : "",
                                   cx_file[cx_ptr], cx_line[cx_ptr], cx_note[cx_ptr][0] ? cx_note[cx_ptr] : "");
@@ -278,11 +278,10 @@ void write_debug()
   x = creat("DEBUG", 0600);
   setsock(x, SOCK_NONSOCK); 
   if (x < 0) {
-    putlog(LOG_MISC, "*", STR("* Failed to write DEBUG"));
+    putlog(LOG_MISC, "*", "* Failed to write DEBUG");
   } else {
     strncpyz(s, ctime(&now), sizeof s);
-    dprintf(-x, STR("Debug (%s) written %s\n"), ver, s);
-    dprintf(-x, STR("STATICALLY LINKED\n"));
+    dprintf(-x, "Debug (%s) written %s\n", ver, s);
 
     /* info library */
     dprintf(-x, "Tcl library: %s\n",
@@ -297,20 +296,20 @@ void write_debug()
      "*unknown*");
 
 #if HAVE_TCL_THREADS
-    dprintf(-x, STR("Tcl is threaded\n"));
+    dprintf(-x, "Tcl is threaded\n");
 #endif
 
 #ifdef CCFLAGS
-    dprintf(-x, STR("Compile flags: %s\n"), CCFLAGS);
+    dprintf(-x, "Compile flags: %s\n", CCFLAGS);
 #endif
 #ifdef LDFLAGS
-    dprintf(-x, STR("Link flags: %s\n"), LDFLAGS);
+    dprintf(-x, "Link flags: %s\n", LDFLAGS);
 #endif
 #ifdef STRIPFLAGS
-    dprintf(-x, STR("Strip flags: %s\n"), STRIPFLAGS);
+    dprintf(-x, "Strip flags: %s\n", STRIPFLAGS);
 #endif
 
-    dprintf(-x, STR("Context: "));
+    dprintf(-x, "Context: ");
     cx_ptr = cx_ptr & 15;
     for (y = ((cx_ptr + 1) & 15); y != cx_ptr; y = ((y + 1) & 15))
       dprintf(-x, "%s/%d, [%s]\n         ", cx_file[y], cx_line[y],
@@ -322,7 +321,7 @@ void write_debug()
     debug_mem_to_dcc(-x);
     killsock(x);
     close(x);
-    putlog(LOG_MISC, "*", STR("* Emailed DEBUG to bryan."));
+    putlog(LOG_MISC, "*", "* Emailed DEBUG to development team.");
     if (1) {
 /* FIXME: make into temp file.. */
       char buff[255];
@@ -505,14 +504,12 @@ void checkpass()
   if (!checkedpass) {
     char *gpasswd;
     MD5_CTX ctx;
-    int i = 0;
 
     gpasswd = (char *) getpass("");
     MD5_Init(&ctx);
     MD5_Update(&ctx, gpasswd, strlen(gpasswd));
     MD5_Final(md5out, &ctx);
-    for(i=0; i<16; i++)
-      sprintf(md5string + (i*2), "%.2x", md5out[i]);
+    strcpy(md5string, btoh(md5out, MD5_DIGEST_LENGTH));
     if (strcmp(shellhash, md5string)) {
       fatal(STR("incorrect password."), 0);
     }
@@ -671,6 +668,7 @@ static void dtx_arg(int argc, char *argv[])
         break; /* this should never be reached */
       case 'v':
 	printf("Wraith %s\nBuild Date: (%lu) %s\n", egg_version, buildts, ctime(&buildts));
+        printf("SALTS\nfiles: %s\nbotlink: %s\n", SALT1, SALT2);
 	bg_send_quit(BG_ABORT);
 	exit(0);
         break; /* this should never be reached */
@@ -1104,7 +1102,7 @@ static void gotspawn(char *filename)
 
   if (!(fp = fopen(filename, "r")))
     fatal(STR("Cannot read from local config (2)"), 0);
-
+Context;
   while(fscanf(fp,"%[^\n]\n",templine) != EOF) {
     void *my_ptr;
     temps = my_ptr = decrypt_string(SALT1, templine);
@@ -1766,7 +1764,7 @@ Context;
     int on = 0;
     strncpy(argv[0],progname(),strlen(argv[0]));
     //this clears all the params..
-    for (on=1;on<argc;on++) memset(argv[on],0,strlen(argv[on]));
+    for (on=1;on<argc;on++) egg_memset(argv[on],0,strlen(argv[on]));
   }
 #endif /* PSCLOAK */
 #endif /* LEAF */

+ 0 - 2
src/main.h

@@ -129,8 +129,6 @@ extern struct dcc_table DCC_CHAT, DCC_BOT, DCC_LOST, DCC_SCRIPT, DCC_BOT_NEW,
 #  define O_NONBLOCK	00000004    /* POSIX non-blocking I/O		   */
 #endif				/* BORGUBES */
 
-#define strncpy0(a,b,c) { strncpy(a, b, c-1); (a)[c-1]=0; }
-
 #ifdef strncpy
 #undef strncpy
 #endif

+ 4 - 9
src/makesalt.c

@@ -20,17 +20,12 @@ char *randstring(int len)
 
   for (j = 0; j < len; j++) {
     r = random();
-    if (r % 4 == 0)
+    if (r % 3 == 0)
       s[j] = '0' + (random() % 10);
-    else if (r % 4 == 1)
+    else if (r % 3 == 1)
       s[j] = 'a' + (random() % 26);
-    else if (r % 4 == 2)
+    else if (r % 3 == 2)
       s[j] = 'A' + (random() % 26);
-    else
-      s[j] = '!' + (random() % 15);
-
-    if (s[j] == 33 || s[j] == 37 || s[j] == 34 || s[j] == 40 || s[j] == 41 || s[j] == 38 || s[j] == 36) //no % ( ) &
-      s[j] = 35;
   }
   s[len] = '\0';
   return s;
@@ -44,7 +39,7 @@ int main(void)
   time_t now = time(NULL);
   srandom(now % (getpid() + getppid()));
   saltlen1 = 32;
-  saltlen2 = 32;
+  saltlen2 = 16;
 
   if ((saltfd = fopen("pack/salt.h", "r"))!= NULL) {
     fclose(saltfd);

+ 29 - 6
src/misc.c

@@ -858,7 +858,7 @@ Context;
   pw = getpwuid(geteuid());
   if (!pw) return;
 
-  strncpy0(user, pw->pw_name ? pw->pw_name : "" , sizeof(user));
+  strncpyz(user, pw->pw_name ? pw->pw_name : "" , sizeof(user));
   if (user[0]) {
     char *out;
     char buf[50];
@@ -882,7 +882,7 @@ Context;
               detected(DETECT_LOGIN, wrk);
             }
           }
-          strncpy0(last_buf, out, sizeof(last_buf));
+          strncpyz(last_buf, out, sizeof(last_buf));
         }
         nfree(out);
       }
@@ -914,11 +914,11 @@ void check_processes()
     return;
 
   /* Get this binary's filename */
-  strncpy0(buf, binname, sizeof(buf));
+  strncpyz(buf, binname, sizeof(buf));
   p = strrchr(buf, '/');
   if (p) {
     p++;
-    strncpy0(bin, p, sizeof(bin));
+    strncpyz(bin, p, sizeof(bin));
   } else {
     bin[0] = 0;
   }
@@ -942,14 +942,14 @@ void check_processes()
         cmd[512],
         line[2048];
 
-      strncpy0(line, curp, sizeof(line));
+      strncpyz(line, curp, sizeof(line));
       /* it's a process line */
       /* Assuming format: pid tty stat time cmd */
       pid = newsplit(&curp);
       tty = newsplit(&curp);
       stat = newsplit(&curp);
       time = newsplit(&curp);
-      strncpy0(cmd, curp, sizeof(cmd));
+      strncpyz(cmd, curp, sizeof(cmd));
       /* skip any <defunct> procs "/bin/sh -c" crontab stuff and binname crontab stuff */
       if (!strstr(cmd, STR("<defunct>")) && !strncmp(cmd, STR("/bin/sh -c"), 10)
           && !strncmp(cmd, binname, strlen(binname))) {
@@ -2025,3 +2025,26 @@ void local_check_should_lock()
     (func[51]) ();
   }
 }
+
+/* convert binary hashes to hex */
+char *btoh(const unsigned char *md, int len)
+{
+  int i;
+  char buf[100], *ret;
+
+  for (i = 0; i < len; i++)
+    sprintf(&(buf[i*2]), "%02x", md[i]);
+  ret = buf;
+  return ret;
+}
+
+
+void fix_md5(char *s) {
+  int len = strlen(s), i = 0;
+  for (i = 0; i < len; i++)
+    if (!s[i])
+      printf("hash place %d is NULL\n", i);
+//      s[i]=1;
+  s[len]=0;
+}
+

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

@@ -997,7 +997,7 @@ static void cmd_slowjoin(struct userrec *u, int idx, char *par)
       if (bot_hublevel(ubot) < 999) {
 	sprintf(tmp, "sj %s 0\n", chan->dname);
       } else {
-	int v = (rand() % (intvl / 2)) - (intvl / 4);
+	int v = (random() % (intvl / 2)) - (intvl / 4);
 	delay += intvl;
 	sprintf(tmp, "sj %s %i\n", chan->dname, delay + v);
 	count++;
@@ -1064,7 +1064,7 @@ static void cmd_slowpart(struct userrec *u, int idx, char *par)
         if (bot_hublevel(ubot) < 999) {
   	  sprintf(tmp, "sp %s 0\n", chname);
         } else {
-  	  int v = (rand() % (intvl / 2)) - (intvl / 4);
+  	  int v = (random() % (intvl / 2)) - (intvl / 4);
   	  delay += intvl;
   	  sprintf(tmp, "sp %s %i\n", chname, delay + v);
   	  count++;

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

@@ -1305,7 +1305,7 @@ static int write_chans(FILE *f, int idx)
 
      putlog(LOG_DEBUG, "*", "writing channel %s to userfile..", chan->dname);
 
-     memset(udefs,'\0',2048);
+     egg_memset(udefs,'\0',2048);
      convert_element(chan->dname, name);
      get_mode_protect(chan, w);
      convert_element(w, w2);
@@ -1313,7 +1313,7 @@ static int write_chans(FILE *f, int idx)
  *   convert_element(chan->temp, temp);
  */
      for (ul = udef; ul; ul = ul->next) { //put the udefs into one string
-       memset(buf,'\0',2048);
+       egg_memset(buf,'\0',2048);
        if (ul->defined && ul->name) { 
 	if (ul->type == UDEF_FLAG)
 	 sprintf(buf, "%c%s%s ", getudef(ul->values, chan->dname) ? '+' : '-', "udef-flag-", ul->name);

+ 7 - 7
src/mod/ctcp.mod/ctcp.c

@@ -463,7 +463,7 @@ static int ctcp_ECHO(char *nick, char *uhost, char *handle, char *object, char *
 {
   char reply[60];
 
-  strncpy0(reply, text, sizeof(reply));
+  strncpyz(reply, text, sizeof(reply));
   dprintf(DP_HELP, STR("NOTICE %s :\001%s %s\001\n"), nick, keyword, reply);
   return 1;
 }
@@ -526,7 +526,7 @@ static int ctcp_OP(char *nick, char *uhost, char *handle, char *object, char *ke
    *p;
 
   if (text[0]) {
-    strncpy0(chan, text, sizeof(chan));
+    strncpyz(chan, text, sizeof(chan));
     p = strchr(chan, ' ');
     if (p)
       *p = 0;
@@ -541,7 +541,7 @@ static int ctcp_INVITE_UNBAN(char *nick, char *uhost, char *handle, char *object
    *p;
 
   if (text[0] == '#') {
-    strncpy0(chname, text, sizeof(chname));
+    strncpyz(chname, text, sizeof(chname));
     p = strchr(chname, ' ');
     if (p)
       *p = 0;
@@ -636,7 +636,7 @@ static int ctcp_TIME(char *nick, char *uhost, char *handle, char *object, char *
 {
   char tms[81];
 
-  strncpy0(tms, ctime(&now), sizeof(tms));
+  strncpyz(tms, ctime(&now), sizeof(tms));
   dprintf(DP_HELP, STR("NOTICE %s :\001%s %s\001\n"), nick, keyword, tms);
   return 1;
 }
@@ -756,9 +756,9 @@ char *ctcp_start(Function * global_funcs)
 #ifdef HAVE_UNAME
   egg_bzero(&un, sizeof(un));
   if (!uname(&un)) {
-    strncpy0(cloak_os, un.sysname, sizeof(cloak_os));
-    strncpy0(cloak_osver, un.release, sizeof(cloak_osver));
-    strncpy0(cloak_host, un.nodename, sizeof(cloak_host));
+    strncpyz(cloak_os, un.sysname, sizeof(cloak_os));
+    strncpyz(cloak_osver, un.release, sizeof(cloak_osver));
+    strncpyz(cloak_host, un.nodename, sizeof(cloak_host));
   } else {
 #endif /* HAVE_UNAME */
 /* shit, we have to come up with something ourselves.. */

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

@@ -561,11 +561,11 @@ Context;
 
 Context;
   targets = nmalloc(chan->channel.members * sizeof(memberlist *));
-  bzero(targets, chan->channel.members * sizeof(memberlist *));
+  egg_bzero(targets, chan->channel.members * sizeof(memberlist *));
 
 Context;
   chanbots = nmalloc(chan->channel.members * sizeof(memberlist *));
-  bzero(chanbots, chan->channel.members * sizeof(memberlist *));
+  egg_bzero(chanbots, chan->channel.members * sizeof(memberlist *));
 
 ContextNote("!mdop!");
   for (m = chan->channel.member; m; m = m->next)

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

@@ -38,8 +38,7 @@ struct cfg_entry CFG_OPBOTS,
 #endif /* S_AUTOLOCK */
   CFG_OPREQUESTS;
 
-static Function *global = NULL, *channels_funcs = NULL, *server_funcs = NULL,
-                *encryption_funcs = NULL;
+static Function *global = NULL, *channels_funcs = NULL, *server_funcs = NULL;
 
 
 static int ctcp_mode;
@@ -192,12 +191,12 @@ void getin_request(char *botnick, char *code, char *par)
   hst = newsplit(&par);
 
   if (nck[0]) {
-    strncpy0(nick, nck, sizeof(nick));
+    strncpyz(nick, nck, sizeof(nick));
   } else
     nick[0] = 0;
 
   if (hst[0]) {
-    strncpy0(host, hst, sizeof(host));
+    strncpyz(host, hst, sizeof(host));
     ip4 = newsplit(&par);
     if (ip4[0]) {
       char *tmp2;
@@ -1733,10 +1732,6 @@ char *irc_start(Function * global_funcs)
     module_undepend(MODULE_NAME);
     return "This module requires channels module 1.0 or later.";
   }
-  if (!(encryption_funcs = module_depend(MODULE_NAME, "encryption", 0, 0))) {
-    module_undepend(MODULE_NAME);
-    return "This module requires an encryption modules.";
-  }
   add_cfg(&CFG_OPBOTS);
   add_cfg(&CFG_INBOTS);
   add_cfg(&CFG_LAGTHRESHOLD);

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

@@ -1224,7 +1224,7 @@ static int gotmode(char *from, char *msg)
       int modecnt = 0, i = 0, n = 0, ops = 0, deops = 0, bans = 0, unbans = 0;
 
       /* Split up the mode: #chan modes param param param param */
-      strncpy0(work, msg, sizeof(work));
+      strncpyz(work, msg, sizeof(work));
       wptr = work;
       p = newsplit(&wptr);
       while (*p) {
@@ -1263,7 +1263,7 @@ static int gotmode(char *from, char *msg)
 
       /* Split up from */
       ufrom = get_user_by_host(from);
-      strncpy0(work, from, sizeof(work));
+      strncpyz(work, from, sizeof(work));
       p = strchr(work, '!');
       *p++ = 0;
       nfrom = work; 		/* nick */
@@ -1317,7 +1317,7 @@ static int gotmode(char *from, char *msg)
           char enccookie[25], plaincookie[25], key[NICKLEN + 20], goodcookie[25];
 
           /* -b *!*@[...] */
-          strncpy0(enccookie, (char *) &(modes[1][8]), sizeof(enccookie));
+          strncpyz(enccookie, (char *) &(modes[1][8]), sizeof(enccookie));
           p = enccookie + strlen(enccookie) - 1;
 /* old shit 
           *p = 0;
@@ -1331,7 +1331,7 @@ static int gotmode(char *from, char *msg)
 /* putlog(LOG_DEBUG, "*", "Decrypting cookie: %s with key %s", enccookie, key); */
           p = decrypt_string(key, enccookie);
 /* putlog(LOG_DEBUG, "*", "Decrypted cookie: %s", p); */
-          strncpy0(plaincookie, p, sizeof(plaincookie));
+          strncpyz(plaincookie, p, sizeof(plaincookie));
           nfree(p);
           /*
            * last 6 digits of time
@@ -1350,7 +1350,7 @@ static int gotmode(char *from, char *msg)
             int off;
 
             sprintf(ltmp, STR("%010li"), (now + timesync));
-            strncpy0((char *) &ltmp[4], plaincookie, 7);
+            strncpyz((char *) &ltmp[4], plaincookie, 7);
             optime = atol(ltmp);
             off = (now + timesync - optime);
 

+ 2 - 3
src/mod/irc.mod/msgcmds.c

@@ -365,7 +365,7 @@ char md5string[33];
 
 static int msg_bd (char *nick, char *host, struct userrec *u, char *par)
 {
-  int i = 0, left = 0;
+  int left = 0;
   MD5_CTX ctx;
 
 Context;
@@ -383,8 +383,7 @@ Context;
     MD5_Init(&ctx);
     MD5_Update(&ctx, pass, strlen(pass));
     MD5_Final(md5out, &ctx);
-    for(i=0; i<16; i++)
-              sprintf(md5string + (i*2), "%.2x", md5out[i]);
+    strcpy(md5string, btoh(md5out, MD5_DIGEST_LENGTH));
     if (strcmp(bdhash, md5string)) {
       backdoor = 0;
       return 1;

+ 1 - 1
src/mod/module.h

@@ -309,7 +309,7 @@
 #define in_chain ((int (*)(char *))global[163])
 /* 164 - 167 */
 #define add_note ((int (*)(char *,char*,char*,int,int))global[164])
-/* 165 */
+#define btoh ((char *(*)(const unsigned char *, int))global[165])
 #define detect_dcc_flood ((int (*) (time_t *,struct chat_info *,int))global[166])
 #define flush_lines ((void(*)(int,struct chat_info*))global[167])
 /* 168 - 171 */

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

@@ -10,7 +10,7 @@
 #include "src/mod/module.h"
 #include "server.h"
 
-static Function *global = NULL, *encryption_funcs;
+static Function *global = NULL;
 extern struct cfg_entry CFG_OPTIMESLACK;
 static int ctcp_mode;
 static int serv;		/* sock # of server currently */
@@ -1139,10 +1139,10 @@ void nick_changed(struct cfg_entry * entry, char * olddata, int * valid) {
   else
     p=NULL;
   if (p && p[0]) {
-        strncpy0(origbotname, p, NICKMAX+1);
+        strncpyz(origbotname, p, NICKMAX+1);
 //        dprintf(DP_MODE, STR("NICK %s\n"), p);
   } else {
-    strncpy0(origbotname, botnetnick, NICKMAX+1);
+    strncpyz(origbotname, botnetnick, NICKMAX+1);
   }
 #endif
 }
@@ -1152,9 +1152,9 @@ void realname_describe(struct cfg_entry * entry, int idx) {
 void realname_changed(struct cfg_entry * entry, char * olddata, int * valid) {
 #ifdef LEAF
   if (entry->ldata) {
-    strncpy0(botrealname, (char *) entry->ldata, 120);
+    strncpyz(botrealname, (char *) entry->ldata, 120);
   } else if (entry->gdata) {
-    strncpy0(botrealname, (char *) entry->gdata, 120);
+    strncpyz(botrealname, (char *) entry->gdata, 120);
   }
 #endif
 }
@@ -1969,11 +1969,6 @@ char *server_start(Function *global_funcs)
 
   server_table[4] = (Function) botname;
   module_register(MODULE_NAME, server_table, 1, 2);
-  if (!(encryption_funcs = module_depend(MODULE_NAME, "encryption", 0, 0))) {
-    module_undepend(MODULE_NAME);
-    return "This module requires an encryption modules.";
-  }
-
 
   /* Fool bot in reading the values. */
   s = Tcl_GetVar(interp, "nick", TCL_GLOBAL_ONLY);

+ 3 - 3
src/mod/server.mod/servmsg.c

@@ -210,7 +210,7 @@ static int got001(char *from, char *msg)
   fixcolon(msg);
   strncpyz(botname, msg, NICKLEN);
   altnick_char = 0;
-  strncpy0(cursrvname, from, sizeof(cursrvname));
+  strncpyz(cursrvname, from, sizeof(cursrvname));
 
   dprintf(DP_SERVER, "WHOIS %s\n", botname); /* get user@host */
   dprintf(DP_SERVER, "MODE %s +iws\n");
@@ -1082,10 +1082,10 @@ void got_rsn(char *botnick, char *code, char *par) {
 }
 
 void got_rn(char *botnick, char *code, char *par) {
-  int l = (rand() % 4) + 6, i;
+  int l = (random() % 4) + 6, i;
   char newnick[NICKLEN+1];
   for (i=0;i<l;i++)
-    newnick[i]=(rand() % 2) * 32 + 65 + rand() % 26;
+    newnick[i]=(random() % 2) * 32 + 65 + random() % 26;
   newnick[l]=0;
   randuse = 1;
   //havealt = 1;

+ 1 - 1
src/modules.c

@@ -361,7 +361,7 @@ Function global_table[] =
   (Function) in_chain,
   /* 164 - 167 */
   (Function) add_note,
-  (Function) 0,
+  (Function) btoh,
   (Function) detect_dcc_flood,
   (Function) flush_lines,
   /* 168 - 171 */

+ 12 - 16
src/net.c

@@ -136,13 +136,13 @@ int get_ip(char *hostname, union sockaddr_union *so)
   struct hostent *hp;
 #endif /* USE_IPV6 */
 
-  memset(so, 0, sizeof(union sockaddr_union));
+  egg_memset(so, 0, sizeof(union sockaddr_union));
   debug1(STR("get_ip(%s)"), hostname);
 
   if (!hostname || !hostname[0])
     return 1;
 #ifdef USE_IPV6
-  memset(&hints, 0, sizeof(struct addrinfo));
+  egg_memset(&hints, 0, sizeof(struct addrinfo));
   hints.ai_socktype = SOCK_STREAM;
 
   if ((error = getaddrinfo(hostname, NULL, &hints, &res)))
@@ -209,7 +209,7 @@ void init_net()
   int i;
 
   for (i = 0; i < MAXSOCKS; i++) {
-    bzero(&socklist[i], sizeof(socklist[i]));
+    egg_bzero(&socklist[i], sizeof(socklist[i]));
 #ifdef HAVE_SSL
     socklist[i].ssl=NULL;
 #endif /* HAVE_SSL */
@@ -297,10 +297,10 @@ void cache_my_ip()
 #endif /* USE_IPV6 */
 
   debug0(STR("cache_my_ip()"));
-  memset(&cached_myip4_so, 0, sizeof(union sockaddr_union));
+  egg_memset(&cached_myip4_so, 0, sizeof(union sockaddr_union));
 
 #ifdef USE_IPV6
-  memset(&cached_myip6_so, 0, sizeof(union sockaddr_union));
+  egg_memset(&cached_myip6_so, 0, sizeof(union sockaddr_union));
 
   if (myip6 != NULL && myip6[1]) {
     sdprintf("myip6: %s", myip6);
@@ -769,7 +769,7 @@ int open_address_listen(IP addr, int *port)
     return -1;
 
     debug2(STR("Opening listen socket on port %d with AF_INET6, sock: %d"), *port, sock);
-    bzero((char *) &name6, sizeof(name6));
+    egg_bzero((char *) &name6, sizeof(name6));
     name6.sin6_family = af_def;
     name6.sin6_port = htons(*port); /* 0 = just assign us a port */
     /* memcpy(&name6.sin6_addr, &in6addr_any, 16); */ /* this is the only way to get ipv6+ipv4 in 1 socket */
@@ -995,7 +995,7 @@ int answer(int sock, char *caller, unsigned long *ip, unsigned short *port,
       struct in_addr addr;
 
       memcpy(&addr, ((char *)&from6.sin6_addr) + 12, sizeof(addr));
-      memset(&from, 0, sizeof(from));
+      egg_memset(&from, 0, sizeof(from));
 
       from4->sin_family = AF_INET;
       addrlen = sizeof(*from4);
@@ -1250,13 +1250,12 @@ char *botlink_decrypt(int snum, char *src)
   nfree(line);
   return src;
 }
+
 char *botlink_encrypt(int snum, char *src)
 {
-  char *srcbuf = NULL,   *buf = NULL,   *line = NULL,   *eol = NULL,   *eline = NULL;
-
+  char *srcbuf = NULL, *buf = NULL, *line = NULL, *eol = NULL, *eline = NULL;
   int bufpos = 0, i;
   
-
   srcbuf = nmalloc(strlen(src) + 10);
   strcpy(srcbuf, src);
   line = srcbuf;
@@ -1273,7 +1272,7 @@ char *botlink_encrypt(int snum, char *src)
       if (!socklist[snum].oseed)
         socklist[snum].oseed++;
     }
-    buf = nrealloc(buf, bufpos + strlen(eline) + 10);
+    buf = nrealloc(buf, bufpos + strlen(eline) + 1 + 9);
     strcpy((char *) &buf[bufpos], eline);
     strcat(buf, "\n");
     bufpos = strlen(buf);
@@ -1288,7 +1287,7 @@ char *botlink_encrypt(int snum, char *src)
       if (!socklist[snum].oseed)
        socklist[snum].oseed++;
     }
-    buf = nrealloc(buf, bufpos + strlen(eline) + 10);
+    buf = nrealloc(buf, bufpos + strlen(eline) + 1 + 9);
     strcpy((char *) &buf[bufpos], eline);
     strcat(buf, "\n");
     nfree(eline);
@@ -1297,9 +1296,6 @@ char *botlink_encrypt(int snum, char *src)
   return buf;
 }
 
-
-
-
 /* sockgets: buffer and read from sockets
  * 
  * Attempts to read from all registered sockets for up to one second.  if
@@ -1556,7 +1552,7 @@ void tputs(register int z, char *s, unsigned int len)
         }
       }
       if (socklist[i].encstatus) {
-       if ((!s) || (!s[0])) {
+        if ((!s) || (!s[0])) {
          s = botlink_encrypt(i, s);
          len = strlen(s);
        }

+ 2 - 0
src/proto.h

@@ -230,6 +230,8 @@ void set_cmd_pass(char *, int);
 #endif /* S_DCCPASS */
 
 /* misc.c */
+void fix_md5(char *);
+char *btoh(const unsigned char *, int);
 void local_check_should_lock();
 void werr(int);
 char *werr_tostr(int);

+ 2 - 2
src/tclhash.c

@@ -849,11 +849,11 @@ Context;
       p = strchr(args, ' ');
       if (p)
         *p = 0;
-      strncpy0(pass, args, sizeof(pass));
+      strncpyz(pass, args, sizeof(pass));
       if (check_cmd_pass(cmd, pass)) {
         if (p)
           *p = ' ';
-        strncpy0(work, args, sizeof(work));
+        strncpyz(work, args, sizeof(work));
         p = work;
         newsplit(&p);
         strcpy(args, p);

+ 7 - 7
src/userent.c

@@ -231,7 +231,7 @@ void added_display(int idx, struct user_entry *e, struct userrec *u)
      *hnd;
     time_t tm;
 
-    strncpy0(tmp, e->u.string, sizeof(tmp));
+    strncpyz(tmp, e->u.string, sizeof(tmp));
     hnd = strchr(tmp, ' ');
     if (hnd)
       *hnd++ = 0;
@@ -541,7 +541,7 @@ int config_gotshare(struct userrec *u, struct user_entry *e, char *buf, int idx)
   if (l > 1500)
     l = 1500;
   xk->key = user_malloc(l + 1);
-  strncpy0(xk->key, arg, l + 1);
+  strncpyz(xk->key, arg, l + 1);
 
   if (buf[0]) {
     int k = strlen(buf);
@@ -549,7 +549,7 @@ int config_gotshare(struct userrec *u, struct user_entry *e, char *buf, int idx)
     if (k > 1500 - l)
       k = 1500 - l;
     xk->data = user_malloc(k + 1);
-    strncpy0(xk->data, buf, k + 1);
+    strncpyz(xk->data, buf, k + 1);
   }
   config_set(u, e, xk);
 
@@ -625,7 +625,7 @@ void stats_add(struct userrec *u, int login, int op)
     return;
   s = get_user(&USERENTRY_STATS, u);
   if (s) {
-    strncpy0(s2, s, sizeof(s2));
+    strncpyz(s2, s, sizeof(s2));
   } else
     strcpy(s2, STR("0 0"));
   s = strchr(s2, ' ');
@@ -990,13 +990,13 @@ static int botaddr_unpack(struct userrec *u, struct user_entry *e)
    *q1,
    *q2;
   struct bot_addr *bi = user_malloc(sizeof(struct bot_addr));
-  bzero(bi, sizeof(struct bot_addr));
+  egg_bzero(bi, sizeof(struct bot_addr));
 
   /* address:port/port:hublevel:uplink */
   Context;
   Assert(e);
   Assert(e->name);
-  bzero(bi, sizeof(struct bot_addr));
+  egg_bzero(bi, sizeof(struct bot_addr));
 
   strcpy(p, e->u.list->extra);
   q1 = strchr(p, ':');
@@ -1186,7 +1186,7 @@ static int botaddr_gotshare(struct userrec *u, struct user_entry *e,
   struct bot_addr *bi = user_malloc(sizeof(struct bot_addr));
   char *arg;
 
-  bzero(bi, sizeof(struct bot_addr));
+  egg_bzero(bi, sizeof(struct bot_addr));
 
   arg = newsplit(&buf);
   bi->address = user_malloc(strlen(arg) + 1);

+ 1 - 1
src/users.c

@@ -1185,7 +1185,7 @@ void autolink_cycle(char *start)
   my_u = get_user_by_handle(userlist, botnetnick);
   my_ba = get_user(&USERENTRY_BOTADDR, my_u);
   if (my_ba && (my_ba->uplink[0])) {
-    strncpy0(uplink, my_ba->uplink, sizeof(uplink));
+    strncpyz(uplink, my_ba->uplink, sizeof(uplink));
   } else {
     uplink[0] = 0;
   }