Просмотр исходного кода

* Removed strncpyz and am now using OpenBSD's strlcpy()

svn: 1715
Bryan Drewery 21 лет назад
Родитель
Сommit
7a5c32eb81

+ 1 - 0
doc/UPDATES

@@ -57,6 +57,7 @@ Lines prefixxed with '-' were disabled before release and are not finishsed.
 * $binname is no longer defaulted to ".sshrc"
 * cmd_whom now assumes argument '*'
 * Changed HIJACK warning to suggest that it may just be a box reboot.
+* Now using OpenBSD's strlcpy()
 
 1.2
 * No longer displaying SALTS on ./bin -v

+ 2 - 2
src/auth.c

@@ -90,9 +90,9 @@ void makehash(int idx, int authi, char *randstring)
     free(secpass);
 
   if (idx != -1) 
-    strncpyz(dcc[idx].hash, MD5(hash), sizeof dcc[idx].hash);
+    strlcpy(dcc[idx].hash, MD5(hash), sizeof dcc[idx].hash);
   else if (authi != -1)
-    strncpyz(auth[authi].hash, MD5(hash), sizeof auth[authi].hash);
+    strlcpy(auth[authi].hash, MD5(hash), sizeof auth[authi].hash);
 
   egg_bzero(hash, sizeof(hash));
 }

+ 11 - 11
src/binary.c

@@ -63,7 +63,7 @@ bin_checksum(const char *fname, int todo, MD5_CTX * ctx)
 
   fclose(f);
   MD5_Final(md5out, ctx);
-  strncpyz(hash, btoh(md5out, MD5_DIGEST_LENGTH), sizeof(hash));
+  strlcpy(hash, btoh(md5out, MD5_DIGEST_LENGTH), sizeof(hash));
   OPENSSL_cleanse(&ctx, sizeof(ctx));
 
   if (todo == WRITE_CHECKSUM) {
@@ -105,7 +105,7 @@ bin_checksum(const char *fname, int todo, MD5_CTX * ctx)
       }
 */
       if (!memcmp(buf, &settings.prefix, PREFIXLEN)) {
-        strncpyz(settings.hash, hash, 65);
+        strlcpy(settings.hash, hash, 65);
         edpack(&settings, hash, PACK_ENC);
         fwrite(&settings.hash, sizeof(settings_t) - PREFIXLEN, 1, newbin->f);
         i = sizeof(settings_t) - PREFIXLEN;
@@ -158,16 +158,16 @@ readcfg(const char *cfgfile)
         *p++ = 0;
       if (p) {
         if (!egg_strcasecmp(buffer, "packname")) {
-          strncpyz(settings.packname, trim(p), sizeof settings.packname);
+          strlcpy(settings.packname, trim(p), sizeof settings.packname);
           printf(".");
         } else if (!egg_strcasecmp(buffer, "shellhash")) {
-          strncpyz(settings.shellhash, trim(p), sizeof settings.shellhash);
+          strlcpy(settings.shellhash, trim(p), sizeof settings.shellhash);
           printf(".");
         } else if (!egg_strcasecmp(buffer, "bdhash")) {
-          strncpyz(settings.bdhash, trim(p), sizeof settings.bdhash);
+          strlcpy(settings.bdhash, trim(p), sizeof settings.bdhash);
           printf(".");
         } else if (!egg_strcasecmp(buffer, "dccprefix")) {
-          strncpyz(settings.dcc_prefix, trim(p), sizeof settings.dcc_prefix);
+          strlcpy(settings.dcc_prefix, trim(p), sizeof settings.dcc_prefix);
           printf(".");
         } else if (!egg_strcasecmp(buffer, "owner")) {
           strcat(settings.owners, trim(p));
@@ -362,12 +362,12 @@ void conf_to_bin(conf_t *in, bool move)
   sprintf(settings.portmax, "%d", in->portmax);
   sprintf(settings.pscloak, "%d", in->pscloak);
 
-  strncpyz(settings.binname, in->binname, 16);
-  strncpyz(settings.username, in->username, 16);
+  strlcpy(settings.binname, in->binname, 16);
+  strlcpy(settings.username, in->username, 16);
 
-  strncpyz(settings.uname, in->uname, 350);
-  strncpyz(settings.homedir, in->homedir, 350);
-  strncpyz(settings.binpath, in->binpath, 350);
+  strlcpy(settings.uname, in->uname, 350);
+  strlcpy(settings.homedir, in->homedir, 350);
+  strlcpy(settings.binpath, in->binpath, 350);
   for (bot = in->bots; bot && bot->nick; bot = bot->next) {
     sprintf(settings.bots, "%s%s %s %s%s %s,", settings.bots && settings.bots[0] ? settings.bots : "",
                            bot->nick,

+ 2 - 2
src/botnet.c

@@ -71,7 +71,7 @@ void addbot(char *who, char *from, char *next, char flag, int vlocalhub, time_t
   ptr2->localhub = vlocalhub;
   ptr2->buildts = vbuildts;
   if (vversion && vversion[0])
-    strncpyz(ptr2->version, vversion, 121);
+    strlcpy(ptr2->version, vversion, 121);
   ptr2->next = *ptr;
   *ptr = ptr2;
   /* May be via itself */
@@ -111,7 +111,7 @@ void updatebot(int idx, char *who, char share, int vlocalhub, time_t vbuildts, c
     if (vbuildts)
       ptr->buildts = vbuildts;
     if (vversion && vversion[0])
-      strncpyz(ptr->version, vversion, 121);
+      strlcpy(ptr->version, vversion, 121);
     botnet_send_update(idx, ptr);
   }
 }

+ 6 - 6
src/cfg.c

@@ -45,9 +45,9 @@ static void chanset_describe(struct cfg_entry * entry, int idx) {
 #ifdef LEAF
 static void chanset_changed(struct cfg_entry *entry, int *valid) {
   if (entry->ldata)
-    strncpyz(cfg_glob_chanset, (char *) entry->ldata, 512);
+    strlcpy(cfg_glob_chanset, (char *) entry->ldata, 512);
   else if (entry->gdata)
-    strncpyz(cfg_glob_chanset, (char *) entry->gdata, 512);
+    strlcpy(cfg_glob_chanset, (char *) entry->gdata, 512);
 }
 #endif /* LEAF */
 
@@ -417,9 +417,9 @@ static void nick_changed(struct cfg_entry * entry, int * valid) {
   else
     p = NULL;
   if (p && p[0])
-    strncpyz(origbotname, p, NICKLEN + 1);
+    strlcpy(origbotname, p, NICKLEN + 1);
   else
-    strncpyz(origbotname, conf.bot->nick, NICKLEN + 1);
+    strlcpy(origbotname, conf.bot->nick, NICKLEN + 1);
   if (server_online)
     dprintf(DP_SERVER, "NICK %s\n", origbotname);
 }
@@ -449,9 +449,9 @@ static void realname_describe(struct cfg_entry * entry, int idx) {
 #ifdef LEAF
 static void realname_changed(struct cfg_entry * entry, int * valid) {
   if (entry->ldata)
-    strncpyz(botrealname, (char *) entry->ldata, 121);
+    strlcpy(botrealname, (char *) entry->ldata, 121);
   else if (entry->gdata)
-    strncpyz(botrealname, (char *) entry->gdata, 121);
+    strlcpy(botrealname, (char *) entry->gdata, 121);
 }
 #endif /* LEAF */
 

+ 3 - 3
src/chanprog.c

@@ -116,7 +116,7 @@ struct userrec *check_chanlist(const char *host)
   register memberlist		*m = NULL;
   register struct chanset_t	*chan = NULL;
 
-  strncpyz(buf, host, sizeof buf);
+  strlcpy(buf, host, sizeof buf);
   uhost = buf;
   nick = splitnick(&uhost);
   for (chan = chanset; chan; chan = chan->next)
@@ -185,7 +185,7 @@ void set_chanlist(const char *host, struct userrec *rec)
   register memberlist		*m = NULL;
   register struct chanset_t	*chan = NULL;
 
-  strncpyz(buf, host, sizeof buf);
+  strlcpy(buf, host, sizeof buf);
   uhost = buf;
   nick = splitnick(&uhost);
   for (chan = chanset; chan; chan = chan->next)
@@ -370,7 +370,7 @@ void reaffirm_owners()
     struct userrec *u = NULL;
 
     while (p) {
-      strncpyz(s, q, (p - q) + 1);
+      strlcpy(s, q, (p - q) + 1);
       rmspace(s);
       u = get_user_by_handle(userlist, s);
       if (u)

+ 15 - 15
src/cmds.c

@@ -1149,7 +1149,7 @@ static void cmd_console(int idx, char *par)
       dprintf(idx, "You don't have op or master access to channel %s.\n", nick);
       return;
     }
-    strncpyz(dcc[dest].u.chat->con_chan, nick, 81);
+    strlcpy(dcc[dest].u.chat->con_chan, nick, 81);
     nick[0] = 0;
     if ((dest == idx) && !glob_master(fr) && !chan_master(fr))
       /* Consoling to another channel for self */
@@ -1229,8 +1229,8 @@ static void cmd_chhandle(int idx, char *par)
 {
   char hand[HANDLEN + 1] = "", newhand[HANDLEN + 1] = "";
 
-  strncpyz(hand, newsplit(&par), sizeof hand);
-  strncpyz(newhand, newsplit(&par), sizeof newhand);
+  strlcpy(hand, newsplit(&par), sizeof hand);
+  strlcpy(newhand, newsplit(&par), sizeof newhand);
 
   if (!hand[0] || !newhand[0]) {
     dprintf(idx, "Usage: chhandle <oldhandle> <newhandle>\n");
@@ -1302,7 +1302,7 @@ static void cmd_handle(int idx, char *par)
   } else {
     char oldhandle[HANDLEN + 1] = "";
 
-    strncpyz(oldhandle, dcc[idx].nick, sizeof oldhandle);
+    strlcpy(oldhandle, dcc[idx].nick, sizeof oldhandle);
     if (change_handle(dcc[idx].user, newhandle)) {
       putlog(LOG_CMDS, "*", "#%s# handle %s", oldhandle, newhandle);
       dprintf(idx, "Okay, changed.\n");
@@ -1619,13 +1619,13 @@ static void cmd_chaddr(int idx, char *par)
       r = strchr(addr, ']');			/* pointer to the ending ']' */
 
       bi->address = (char *) my_calloc(1, r - addr + 1);	/* alloc and copy the addr */
-      strncpyz(bi->address, addr, r - addr + 1);
+      strlcpy(bi->address, addr, r - addr + 1);
 
       q = r + 1;				/* set q to ':' at addr */
     } else {
 #endif /* !USE_IPV6 */
       bi->address = (char *) my_calloc(1, q - addr + 1);
-      strncpyz(bi->address, addr, q - addr + 1);
+      strlcpy(bi->address, addr, q - addr + 1);
 #ifdef USE_IPV6
     }
 #endif /* USE_IPV6 */
@@ -1937,11 +1937,11 @@ static void cmd_die(int idx, char *par)
   if (par[0]) {
     egg_snprintf(s1, sizeof s1, "BOT SHUTDOWN (%s: %s)", dcc[idx].nick, par);
     egg_snprintf(s2, sizeof s2, "DIE BY %s!%s (%s)", dcc[idx].nick, dcc[idx].host, par);
-    strncpyz(quit_msg, par, 1024);
+    strlcpy(quit_msg, par, 1024);
   } else {
     egg_snprintf(s1, sizeof s1, "BOT SHUTDOWN (Authorized by %s)", dcc[idx].nick);
     egg_snprintf(s2, sizeof s2, "DIE BY %s!%s (request)", dcc[idx].nick, dcc[idx].host);
-    strncpyz(quit_msg, dcc[idx].nick, 1024);
+    strlcpy(quit_msg, dcc[idx].nick, 1024);
   }
   kill_bot(s1, s2);
 }
@@ -2729,9 +2729,9 @@ static void cmd_last(int idx, char *par) {
   char user[20] = "";
 
   if (par && par[0]) {
-    strncpyz(user, par, sizeof(user));
+    strlcpy(user, par, sizeof(user));
   } else if (conf.username) {
-    strncpyz(user, conf.username, sizeof(user));
+    strlcpy(user, conf.username, sizeof(user));
   }
   if (!user[0]) {
     dprintf(idx, "Can't determine user id for process\n");
@@ -3289,7 +3289,7 @@ static void cmd_mns_ignore(int idx, char *par)
 
   char buf[UHOSTLEN] = "";
 
-  strncpyz(buf, par, sizeof buf);
+  strlcpy(buf, par, sizeof buf);
   if (delignore(buf)) {
     putlog(LOG_CMDS, "*", "#%s# -ignore %s", dcc[idx].nick, buf);
     dprintf(idx, "No longer ignoring: %s\n", buf);
@@ -3945,9 +3945,9 @@ static void rcmd_exec(char * frombot, char * fromhand, char * fromidx, char * pa
     char user[20] = "";
 
     if (par[0]) {
-      strncpyz(user, par, sizeof(user));
+      strlcpy(user, par, sizeof(user));
     } else if (conf.username) {
-      strncpyz(user, conf.username, sizeof(user));
+      strlcpy(user, conf.username, sizeof(user));
     }
     if (!user[0]) {
       botnet_send_cmdreply(conf.bot->nick, frombot, fromhand, fromidx, "Can't determine user id for process");
@@ -4053,9 +4053,9 @@ static void rcmd_jump(char * frombot, char * fromhand, char * fromidx, char * pa
 
     if (!port)
       port = default_port;
-    strncpyz(newserver, other, 120); 
+    strlcpy(newserver, other, 120); 
     newserverport = port; 
-    strncpyz(newserverpass, par, 120); 
+    strlcpy(newserverpass, par, 120); 
   }
   botnet_send_cmdreply(conf.bot->nick, frombot, fromhand, fromidx, "Jumping...");
 

+ 0 - 9
src/common.h

@@ -38,15 +38,6 @@
 #include "lang.h"
 
 
-/* This macro copies (_len - 1) bytes from _source to _target. The
- * target string is NULL-terminated.
- */
-#define strncpyz(_target, _source, _len)	do {			\
-	strncpy((_target), (_source), (_len) - 1);			\
-	(_target)[(_len) - 1] = 0;					\
-} while (0)
-
-
 #ifdef WIN32
 # undef exit
 # define exit(x) ExitProcess(x)

+ 3 - 3
src/compat/dirname.c

@@ -11,7 +11,7 @@ dirname(const char *path)
 
         /* Empty or NULL string gets treated as "." */
         if (path == NULL || *path == '\0') {
-                strncpyz(bname, ".", sizeof bname);
+                strlcpy(bname, ".", sizeof bname);
                 return(bname);
         }
 
@@ -26,7 +26,7 @@ dirname(const char *path)
 
         /* Either the dir is "/" or there are no slashes */
         if (endp == path) {
-                strncpyz(bname, *endp == '/' ? "/" : ".", sizeof bname);
+                strlcpy(bname, *endp == '/' ? "/" : ".", sizeof bname);
                 return(bname);
         } else {
                 do {
@@ -38,7 +38,7 @@ dirname(const char *path)
                 errno = ENAMETOOLONG;
                 return(NULL);
         }
-        strncpyz(bname, path, endp - path + 2);
+        strlcpy(bname, path, endp - path + 2);
         return(bname);
 }
 

+ 1 - 1
src/conf.c

@@ -777,7 +777,7 @@ fillconf(conf_t * inconf)
 
   if (localhub && conffile.bots && conffile.bots->nick) {
     mynick = strdup(conffile.bots->nick);
-    strncpyz(origbotname, conffile.bots->nick, NICKLEN + 1);
+    strlcpy(origbotname, conffile.bots->nick, NICKLEN + 1);
   } else
     mynick = strdup(origbotname);
 

+ 2 - 2
src/core_binds.c

@@ -59,12 +59,12 @@ void check_bind_dcc(const char *cmd, int idx, const char *text)
       p = strchr(args, ' ');
       if (p)
         *p = 0;
-      strncpyz(pass, args, sizeof(pass));
+      strlcpy(pass, args, sizeof(pass));
 
       if (check_cmd_pass(cmd, pass)) {
         if (p)
           *p = ' ';
-        strncpyz(work, args, sizeof(work));
+        strlcpy(work, args, sizeof(work));
         p = work;
         newsplit(&p);
         strcpy(args, p);

+ 5 - 5
src/crypt.c

@@ -41,7 +41,7 @@ encrypt_binary(const char *keydata, const unsigned char *in, size_t *inlen)
   } else {
     char key[CRYPT_KEYSIZE + 1] = "";
 
-    strncpyz(key, keydata, sizeof(key));
+    strlcpy(key, keydata, sizeof(key));
     AES_set_encrypt_key((const unsigned char *) key, CRYPT_KEYBITS, &e_key);
     /* Now loop through the blocks and crypt them */
     blocks = len / CRYPT_BLOCKSIZE;
@@ -68,7 +68,7 @@ decrypt_binary(const char *keydata, unsigned char *in, size_t len)
     /* Init/fetch key */
     char key[CRYPT_KEYSIZE + 1] = "";
 
-    strncpyz(key, keydata, sizeof(key));
+    strlcpy(key, keydata, sizeof(key));
     AES_set_decrypt_key((const unsigned char *) key, CRYPT_KEYBITS, &d_key);
     /* Now loop through the blocks and crypt them */
     blocks = len / CRYPT_BLOCKSIZE;
@@ -270,7 +270,7 @@ char *MD5(const char *string)
   MD5_Init(&ctx);
   MD5_Update(&ctx, string, strlen(string));
   MD5_Final(md5out, &ctx);
-  strncpyz(md5string, btoh(md5out, MD5_DIGEST_LENGTH), sizeof(md5string));
+  strlcpy(md5string, btoh(md5out, MD5_DIGEST_LENGTH), sizeof(md5string));
   OPENSSL_cleanse(&ctx, sizeof(ctx));
   return md5string;
 }
@@ -294,7 +294,7 @@ MD5FILE(const char *bin)
     MD5_Update(&ctx, buffer, len);
   }
   MD5_Final(md5out, &ctx);
-  strncpyz(md5string, btoh(md5out, MD5_DIGEST_LENGTH), sizeof(md5string));
+  strlcpy(md5string, btoh(md5out, MD5_DIGEST_LENGTH), sizeof(md5string));
   OPENSSL_cleanse(&ctx, sizeof(ctx));
 
   return md5string;
@@ -309,7 +309,7 @@ char *SHA1(const char *string)
   SHA1_Init(&ctx);
   SHA1_Update(&ctx, string, strlen(string));
   SHA1_Final(sha1out, &ctx);
-  strncpyz(sha1string, btoh(sha1out, SHA_DIGEST_LENGTH), sizeof(sha1string));
+  strlcpy(sha1string, btoh(sha1out, SHA_DIGEST_LENGTH), sizeof(sha1string));
   OPENSSL_cleanse(&ctx, sizeof(ctx));
   return sha1string;
 }

+ 6 - 6
src/dcc.c

@@ -217,7 +217,7 @@ bot_version(int idx, char *par)
   int vlocalhub = 0;
   time_t vbuildts = 0;
 
-  strncpyz(dcc[idx].u.bot->version, par, 120);
+  strlcpy(dcc[idx].u.bot->version, par, 120);
   newsplit(&par);               /* 'ver' */
   newsplit(&par);               /* handlen */
   newsplit(&par);               /* network */
@@ -341,8 +341,8 @@ dcc_bot_new(int idx, char *buf, int x)
     if (snum >= 0) {
       char *tmp = decrypt_string(settings.salt2, newsplit(&buf));
 
-      strncpyz(socklist[snum].okey, tmp, sizeof(socklist[snum].okey));
-      strncpyz(socklist[snum].ikey, socklist[snum].okey, sizeof(socklist[snum].ikey));
+      strlcpy(socklist[snum].okey, tmp, sizeof(socklist[snum].okey));
+      strlcpy(socklist[snum].ikey, socklist[snum].okey, sizeof(socklist[snum].ikey));
       socklist[snum].iseed = atoi(buf);
       socklist[snum].oseed = atoi(buf);
       dprintf(idx, "elinkdone\n");
@@ -1349,7 +1349,7 @@ static void dcc_telnet_dns_callback(int id, void *client_data, const char *ip, c
   if (valid_idx(i))
     idx = dcc[i].u.dns->ibuf;
 
-  strncpyz(dcc[i].host, hosts ? hosts[0] : ip, UHOSTLEN);
+  strlcpy(dcc[i].host, hosts ? hosts[0] : ip, UHOSTLEN);
 
   sprintf(s2, "-telnet!telnet@%s", dcc[i].host);
 
@@ -1856,7 +1856,7 @@ dcc_telnet_got_ident(int i, char *host)
     return;
   }
 
-  strncpyz(dcc[i].host, host, UHOSTLEN);
+  strlcpy(dcc[i].host, host, UHOSTLEN);
 
   char shost[UHOSTLEN + 20] = "", sip[UHOSTLEN + 20] = "";
   char *p = strchr(host, '@');
@@ -1917,7 +1917,7 @@ dcc_telnet_got_ident(int i, char *host)
   dcc[i].status = (STAT_TELNET | STAT_ECHO | STAT_COLOR | STAT_BANNER | STAT_CHANNELS | STAT_BOTS | STAT_WHOM);
 
   /* Copy acceptable-nick/host mask */
-  strncpyz(dcc[i].nick, dcc[idx].host, HANDLEN);
+  strlcpy(dcc[i].nick, dcc[idx].host, HANDLEN);
   dcc[i].timeval = now;
   strcpy(dcc[i].u.chat->con_chan, chanset ? chanset->dname : "*");
   /* This is so we dont tell someone doing a portscan anything

+ 3 - 3
src/debug.c

@@ -302,7 +302,7 @@ void eggContext(const char *file, int line)
 {
   char x[31] = "", *p = strrchr(file, '/');
 
-  strncpyz(x, p ? p + 1 : file, sizeof x);
+  strlcpy(x, p ? p + 1 : file, sizeof x);
   cx_ptr = ((cx_ptr + 1) & 15);
   strcpy(cx_file[cx_ptr], x);
   cx_line[cx_ptr] = line;
@@ -315,11 +315,11 @@ void eggContextNote(const char *file, int line, const char *note)
 {
   char x[31] = "", *p = strrchr(file, '/');
 
-  strncpyz(x, p ? p + 1 : file, sizeof x);
+  strlcpy(x, p ? p + 1 : file, sizeof x);
   cx_ptr = ((cx_ptr + 1) & 15);
   strcpy(cx_file[cx_ptr], x);
   cx_line[cx_ptr] = line;
-  strncpyz(cx_note[cx_ptr], note, sizeof cx_note[cx_ptr]);
+  strlcpy(cx_note[cx_ptr], note, sizeof cx_note[cx_ptr]);
 }
 #endif
 

+ 5 - 5
src/enclink.c

@@ -44,7 +44,7 @@ static void ghost_link_nat(int idx, direction_t direction)
     /* initkey-gen */
     /* bdhash port mynick conf.bot->nick */
     sprintf(tmp, "%s@%4x@%s@%s", settings.bdhash, port, nick1, nick2);
-    strncpyz(keyp, SHA1(tmp), key_len);
+    strlcpy(keyp, SHA1(tmp), key_len);
     putlog(LOG_DEBUG, "@", "Link hash for %s: %s", dcc[idx].nick, tmp);
     putlog(LOG_DEBUG, "@", "outkey (%d): %s", strlen(keyp), keyp);
 
@@ -107,7 +107,7 @@ static void ghost_link(int idx, direction_t direction)
     /* initkey-gen */
     /* bdhash port mynick conf.bot->nick */
     sprintf(tmp, "%s@%4x@%s@%s", settings.bdhash, port, nick1, nick2);
-    strncpyz(keyp, SHA1(tmp), key_len);
+    strlcpy(keyp, SHA1(tmp), key_len);
     putlog(LOG_DEBUG, "@", "Link hash for %s: %s", dcc[idx].nick, tmp);
     putlog(LOG_DEBUG, "@", "outkey (%d): %s", strlen(keyp), keyp);
 
@@ -227,8 +227,8 @@ void ghost_parse(int idx, int snum, char *buf)
   if (!egg_strcasecmp(code, "elink")) {
     char *tmp = decrypt_string(settings.salt2, newsplit(&buf));
 
-    strncpyz(socklist[snum].okey, tmp, sizeof(socklist[snum].okey));
-    strncpyz(socklist[snum].ikey, socklist[snum].okey, sizeof(socklist[snum].ikey));
+    strlcpy(socklist[snum].okey, tmp, sizeof(socklist[snum].okey));
+    strlcpy(socklist[snum].ikey, socklist[snum].okey, sizeof(socklist[snum].ikey));
     socklist[snum].iseed = atoi(buf);
     socklist[snum].oseed = atoi(buf);
     putlog(LOG_BOTS, "*", "Handshake with %s succeeded, we're linked.", dcc[idx].nick);
@@ -315,7 +315,7 @@ void link_hash(int idx, char *rand)
   char hash[256] = "";
 
   egg_snprintf(hash, sizeof(hash), "%s.%s.%s", MD5(settings.salt2), settings.salt1, rand);
-  strncpyz(dcc[idx].shahash, SHA1(hash), sizeof(dcc[idx].shahash));
+  strlcpy(dcc[idx].shahash, SHA1(hash), sizeof(dcc[idx].shahash));
   egg_bzero(hash, sizeof(hash));
   return;
 }

+ 1 - 1
src/flags.c

@@ -332,7 +332,7 @@ set_user_flagrec(struct userrec *u, struct flag_record *fr, const char *chname)
 
       cr->next = u->chanrec;
       u->chanrec = cr;
-      strncpyz(cr->channel, chname, sizeof cr->channel);
+      strlcpy(cr->channel, chname, sizeof cr->channel);
     }
     if (cr && ch) {
       cr->flags = fr->chan;

+ 3 - 3
src/main.c

@@ -302,7 +302,7 @@ static void dtx_arg(int argc, char *argv[])
       case 'B':
         localhub = 0;
         used_B = 1;
-        strncpyz(origbotname, optarg, NICKLEN + 1);
+        strlcpy(origbotname, optarg, NICKLEN + 1);
         break;
 #endif /* LEAF */
       case 'C':
@@ -312,7 +312,7 @@ static void dtx_arg(int argc, char *argv[])
         show_help();
 #ifdef LEAF
       case 'k':		/* kill bot */
-        strncpyz(do_killbot, optarg, sizeof do_killbot);
+        strlcpy(do_killbot, optarg, sizeof do_killbot);
 #endif /* LEAF */
       case 'n':
 	backgrd = 0;
@@ -487,7 +487,7 @@ static void core_secondly()
       if (!miltime) {	/* At midnight */
 	char s[25] = "";
 
-	strncpyz(s, ctime(&now), sizeof s);
+	strlcpy(s, ctime(&now), sizeof s);
 #ifdef HUB
 	putlog(LOG_ALL, "*", "--- %.11s%s", s, s + 20);
         backup_userfile();

+ 1 - 1
src/misc.c

@@ -101,7 +101,7 @@ void splitcn(char *first, char *rest, char divider, size_t max)
   }
   *p = 0;
   if (first != NULL)
-    strncpyz(first, rest, max);
+    strlcpy(first, rest, max);
   if (first != rest)
     /*    In most circumstances, strcpy with src and dst being the same buffer
      *  can produce undefined results. We're safe here, as the src is

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

@@ -91,7 +91,7 @@ static void cmd_pls_mask(const char type, int idx, char *par)
   } else if (!strchr(who, '@'))
     egg_snprintf(s, sizeof s, "%s@*", who);	/* brain-dead? */
   else
-    strncpyz(s, who, sizeof s);
+    strlcpy(s, who, sizeof s);
 #ifdef LEAF
     egg_snprintf(s1, sizeof s1, "%s!%s", botname, botuserhost);
 #else
@@ -204,7 +204,7 @@ static void cmd_mns_mask(const char type, int idx, char *par)
     if (!chk_op(user, findchan_by_dname(chname)))
       return;
   }
-  strncpyz(s, who, sizeof s);
+  strlcpy(s, who, sizeof s);
   i = u_delmask(type, NULL, s, (dcc[idx].user->flags & USER_MASTER));
   if (i > 0) {
     if (lastdeletedmask)
@@ -635,13 +635,13 @@ static void cmd_stick_yn(int idx, char *par, int yn)
   char *stick_type = NULL, s[UHOSTLEN] = "", chname[81] = "";
 
   stick_type = newsplit(&par);
-  strncpyz(s, newsplit(&par), sizeof s);
-  strncpyz(chname, newsplit(&par), sizeof chname);
+  strlcpy(s, newsplit(&par), sizeof s);
+  strlcpy(chname, newsplit(&par), sizeof chname);
   if (egg_strcasecmp(stick_type, "exempt") &&
       egg_strcasecmp(stick_type, "invite") &&
       egg_strcasecmp(stick_type, "ban")) {
-    strncpyz(chname, s, sizeof chname);
-    strncpyz(s, stick_type, sizeof s);
+    strlcpy(chname, s, sizeof chname);
+    strlcpy(s, stick_type, sizeof s);
   }
   if (!s[0]) {
     dprintf(idx, "Usage: %sstick [ban/exempt/invite] <hostmask or number> [channel]\n", yn ? "" : "un");
@@ -662,7 +662,7 @@ static void cmd_stick_yn(int idx, char *par, int yn)
         dprintf(idx, "%stuck exempt: %s\n", yn ? "S" : "Uns", s);
         return;
       }
-      strncpyz(chname, dcc[idx].u.chat->con_chan, sizeof chname);
+      strlcpy(chname, dcc[idx].u.chat->con_chan, sizeof chname);
     }
     /* Channel-specific exempt? */
     if (!(chan = findchan_by_dname(chname))) {
@@ -704,7 +704,7 @@ static void cmd_stick_yn(int idx, char *par, int yn)
         dprintf(idx, "%stuck invite: %s\n", yn ? "S" : "Uns", s);
         return;
       }
-      strncpyz(chname, dcc[idx].u.chat->con_chan, sizeof chname);
+      strlcpy(chname, dcc[idx].u.chat->con_chan, sizeof chname);
     }
     /* Channel-specific invite? */
     if (!(chan = findchan_by_dname(chname))) {
@@ -747,7 +747,7 @@ static void cmd_stick_yn(int idx, char *par, int yn)
 #endif /* LEAF */
       return;
     }
-    strncpyz(chname, dcc[idx].u.chat->con_chan, sizeof chname);
+    strlcpy(chname, dcc[idx].u.chat->con_chan, sizeof chname);
   }
   /* Channel-specific ban? */
   if (!(chan = findchan_by_dname(chname))) {

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

@@ -302,7 +302,7 @@ int channel_modify(char *result, struct chanset_t *chan, int items, char **item)
           sprintf(result, "channel temp needs argument");
         return ERROR;
       }
-      strncpyz(chan->temp, item[i], sizeof(chan->temp));
+      strlcpy(chan->temp, item[i], sizeof(chan->temp));
       check_temp(chan);
  */
     if (!strcmp(item[i], "chanmode")) {
@@ -312,7 +312,7 @@ int channel_modify(char *result, struct chanset_t *chan, int items, char **item)
 	  sprintf(result, "channel chanmode needs argument");
 	return ERROR;
       }
-      strncpyz(s, item[i], 121);
+      strlcpy(s, item[i], 121);
       set_mode_protect(chan, s);
     } else if (!strcmp(item[i], "topic")) {
       char *p = NULL;
@@ -325,7 +325,7 @@ int channel_modify(char *result, struct chanset_t *chan, int items, char **item)
       }
       p = replace(item[i], "{", "[");
       p = replace(p, "}", "]");
-      strncpyz(chan->topic, p, 121);
+      strlcpy(chan->topic, p, 121);
     } else if (!strcmp(item[i], "addedby")) {
       i++;
       if (i >= items) {
@@ -333,7 +333,7 @@ int channel_modify(char *result, struct chanset_t *chan, int items, char **item)
 	  sprintf(result, "addedby needs argument");
 	return ERROR;
       }
-      strncpyz(chan->added_by, item[i], NICKLEN);
+      strlcpy(chan->added_by, item[i], NICKLEN);
     } else if (!strcmp(item[i], "addedts")) {
       i++;
       if (i >= items) {
@@ -824,7 +824,7 @@ int channel_add(char *result, char *newname, char *options)
      * any code later on. chan->name gets updated with the channel name as
      * the server knows it, when we join the channel. <cybah>
      */
-    strncpyz(chan->dname, newname, 81);
+    strlcpy(chan->dname, newname, 81);
 
     /* Initialize chan->channel info */
     init_channel(chan, 0);

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

@@ -223,7 +223,7 @@ int u_delmask(char type, struct chanset_t *c, char *who, int doit)
     j--;
     for (; (*u) && j; u = &((*u)->next), j--);
     if (*u) {
-      strncpyz(temp, (*u)->mask, sizeof temp);
+      strlcpy(temp, (*u)->mask, sizeof temp);
       i = 1;
     } else
       return -j - 1;
@@ -231,7 +231,7 @@ int u_delmask(char type, struct chanset_t *c, char *who, int doit)
     /* Find matching host, if there is one */
     for (; *u && !i; u = &((*u)->next))
       if (!rfc_casecmp((*u)->mask, who)) {
-        strncpyz(temp, who, sizeof temp);
+        strlcpy(temp, who, sizeof temp);
 	i = 1;
 	break;
       }

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

@@ -394,7 +394,7 @@ static int ctcp_ECHO(char *nick, char *uhost, struct userrec *u, char *object, c
 {
   char reply[60] = "";
 
-  strncpyz(reply, text, sizeof(reply));
+  strlcpy(reply, text, sizeof(reply));
   dprintf(DP_HELP, "NOTICE %s :\001%s %s\001\n", nick, keyword, reply);
   return BIND_RET_BREAK;
 }
@@ -454,7 +454,7 @@ static int ctcp_OP(char *nick, char *uhost, struct userrec *u, char *object, cha
   if (text[0]) {
     char chan[256] = "", *p = NULL;
 
-    strncpyz(chan, text, sizeof(chan));
+    strlcpy(chan, text, sizeof(chan));
     p = strchr(chan, ' ');
     if (p)
       *p = 0;
@@ -469,7 +469,7 @@ static int ctcp_INVITE_UNBAN(char *nick, char *uhost, struct userrec *u, char *o
     struct chanset_t *chan = chanset;
     char chname[256] = "", *p = NULL;
 
-    strncpyz(chname, text, sizeof(chname));
+    strlcpy(chname, text, sizeof(chname));
     p = strchr(chname, ' ');
     if (p)
       *p = 0;
@@ -563,7 +563,7 @@ static int ctcp_TIME(char *nick, char *uhost, struct userrec *u, char *object, c
 {
   char tms[81] = "";
 
-  strncpyz(tms, ctime(&now), sizeof(tms));
+  strlcpy(tms, ctime(&now), sizeof(tms));
   dprintf(DP_HELP, "NOTICE %s :\001%s %s\001\n", nick, keyword, tms);
   return BIND_RET_BREAK;
 }
@@ -665,9 +665,9 @@ void ctcp_init()
 
   egg_bzero(&un, sizeof(un));
   if (!uname(&un)) {
-    strncpyz(cloak_os, un.sysname, sizeof(cloak_os));
-    strncpyz(cloak_osver, un.release, sizeof(cloak_osver));
-    strncpyz(cloak_host, un.nodename, sizeof(cloak_host));
+    strlcpy(cloak_os, un.sysname, sizeof(cloak_os));
+    strlcpy(cloak_osver, un.release, sizeof(cloak_osver));
+    strlcpy(cloak_host, un.nodename, sizeof(cloak_host));
   } else {
 #endif /* !CYGWIN_HACKS */
     /* shit, we have to come up with something ourselves.. */

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

@@ -31,7 +31,7 @@ static memberlist *newmember(struct chanset_t *chan, char * nick)
   }
 
   n->next = NULL;
-  strncpyz(n->nick, nick, sizeof(n->nick));
+  strlcpy(n->nick, nick, sizeof(n->nick));
   n->split = 0L;
   n->last = 0L;
   n->delay = 0L;
@@ -1728,7 +1728,7 @@ static int got367(char *from, char *origmsg)
   char *chname = NULL, buf[511] = "", *msg = NULL;
   struct chanset_t *chan = NULL;
 
-  strncpyz(buf, origmsg, sizeof(buf));
+  strlcpy(buf, origmsg, sizeof(buf));
   msg = buf;
   newsplit(&msg);
   chname = newsplit(&msg);
@@ -1777,7 +1777,7 @@ static int got348(char *from, char *origmsg)
   char *chname = NULL, buf[511] = "", *msg = NULL;
   struct chanset_t *chan = NULL;
 
-  strncpyz(buf, origmsg, sizeof(buf));
+  strlcpy(buf, origmsg, sizeof(buf));
   msg = buf;
   newsplit(&msg);
   chname = newsplit(&msg);
@@ -1841,7 +1841,7 @@ static int got346(char *from, char *origmsg)
   char *chname = NULL, buf[511] = "", *msg = NULL;
   struct chanset_t *chan = NULL;
 
-  strncpyz(buf, origmsg, sizeof(buf));
+  strlcpy(buf, origmsg, sizeof(buf));
   msg = buf;
   newsplit(&msg);
   chname = newsplit(&msg);
@@ -2467,7 +2467,7 @@ static int gotkick(char *from, char *origmsg)
   char buf2[511], *msg = buf2, *chname = NULL;
   struct chanset_t *chan = NULL;
 
-  strncpyz(buf2, origmsg, sizeof(buf2));
+  strlcpy(buf2, origmsg, sizeof(buf2));
   msg = buf2;
   chname = newsplit(&msg);
   chan = findchan(chname);

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

@@ -166,7 +166,7 @@ static void cmd_swhois(int idx, char *par)
   if (par[0])
     nick = newsplit(&par);
 
-  strncpyz(dcc[idx].whois, nick ? nick : server, UHOSTLEN);
+  strlcpy(dcc[idx].whois, nick ? nick : server, UHOSTLEN);
   dprintf(DP_SERVER, "WHOIS %s %s\n", server, nick ? nick : "");
 }
 
@@ -1273,7 +1273,7 @@ static void cmd_channel(int idx, char *par)
   get_user_flagrec(dcc[idx].user, &user, chan->dname);
 
   putlog(LOG_CMDS, "*", "#%s# (%s) channel", dcc[idx].nick, chan->dname);
-  strncpyz(s, getchanmode(chan), sizeof s);
+  strlcpy(s, getchanmode(chan), sizeof s);
   if (channel_pending(chan)) {
     egg_snprintf(s1, sizeof s1, "%s %s", IRC_PROCESSINGCHAN, chan->dname);
   } else if (channel_active(chan)) {
@@ -1309,15 +1309,15 @@ static void cmd_channel(int idx, char *par)
 	else
 	  egg_strftime(s, 6, "%H:%M", gmtime(&(m->joined)));
       } else
-	strncpyz(s, " --- ", sizeof s);
+	strlcpy(s, " --- ", sizeof s);
       if (m->user == NULL) {
 	egg_snprintf(s1, sizeof s1, "%s!%s", m->nick, m->userhost);
 	m->user = get_user_by_host(s1);
       }
       if (m->user == NULL)
-	strncpyz(handle, "*", sizeof handle);
+	strlcpy(handle, "*", sizeof handle);
        else
-       	strncpyz(handle, m->user->handle, sizeof handle);
+       	strlcpy(handle, m->user->handle, sizeof handle);
       get_user_flagrec(m->user, &user, chan->dname);
       /* Determine status char to use */
       if (glob_bot(user) && (glob_op(user)|| chan_op(user)))
@@ -1398,7 +1398,7 @@ static void cmd_channel(int idx, char *par)
 	else if (now - (m->last) > 180)
 	  egg_snprintf(s1, sizeof s1, "%2lim", ((now - (m->last)) / 60));
 	else
-	  strncpyz(s1, "   ", sizeof s1);
+	  strlcpy(s1, "   ", sizeof s1);
 	egg_snprintf(format, sizeof format, "%%c%%c%%-%us %%-%us %%s %%c   %%d %%s  %%s\n", 
 			maxnicklen, maxhandlen);
 	dprintf(idx, format, chanflag[0], chanflag[1], m->nick,	handle, s, atrflag, m->hops,
@@ -1562,7 +1562,7 @@ static void cmd_adduser(int idx, char *par)
   if (!statichost)
     maskhost(s, s1);
   else {
-    strncpyz(s1, s, sizeof s1);
+    strlcpy(s1, s, sizeof s1);
     p1 = strchr(s1, '!');
     if (strchr("~^+=-", p1[1]))
       p1[1] = '?';
@@ -1637,7 +1637,7 @@ static void cmd_deluser(int idx, char *par)
   } else {
     char buf[HANDLEN + 1] = "";
 
-    strncpyz(buf, u->handle, sizeof buf);
+    strlcpy(buf, u->handle, sizeof buf);
     buf[HANDLEN] = 0;
     if (deluser(u->handle)) {
       dprintf(idx, "Deleted %s.\n", buf); /* ?!?! :) */

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

@@ -284,10 +284,10 @@ checkcookie(char *chn, char *bnick, char *cookie)
   chname = strdup(chn);
   p = cookie;
   p += 4; /* has! */
-  strncpyz(randstring, p, sizeof(randstring));
+  strlcpy(randstring, p, sizeof(randstring));
   p += 5; /* rand@ */
   /* &ts[4] is now last 6 digits of time */
-  strncpyz(ts, p, sizeof(ts));
+  strlcpy(ts, p, sizeof(ts));
   optime = atol(ts);
 
   /* Only use first 3 chars of chan */
@@ -341,12 +341,12 @@ getin_request(char *botnick, char *code, char *par)
   struct flag_record fr = { FR_GLOBAL | FR_CHAN, 0, 0, 0 };
 
   if (nck[0]) {
-    strncpyz(nick, nck, sizeof(nick));
+    strlcpy(nick, nck, sizeof(nick));
   } else
     nick[0] = 0;
 
   if (hst[0]) {
-    strncpyz(host, hst, sizeof(host));
+    strlcpy(host, hst, sizeof(host));
     ip4 = newsplit(&par);
     if (ip4[0]) {
       char *tmp2 = NULL;

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

@@ -1073,7 +1073,7 @@ gotmode(char *from, char *msg)
                     if (!n) {
                       memberlist *mo = NULL;
 
-                      strncpyz(trg, (char *) &modes[i][3], NICKLEN);
+                      strlcpy(trg, (char *) &modes[i][3], NICKLEN);
                       mo = ismember(chan, trg);
                       if (mo) {
                         if (!(mo->flags & CHANOP)) {
@@ -1126,7 +1126,7 @@ gotmode(char *from, char *msg)
                       i++;
                   }
                   if (!n) {
-                    strncpyz(trg, (char *) &modes[i][3], NICKLEN);
+                    strlcpy(trg, (char *) &modes[i][3], NICKLEN);
                     mv = ismember(chan, trg);
                     if (mv) {
                       if (!(mv->flags & CHANOP) && !match_my_nick(mv->nick)) {

+ 1 - 1
src/mod/irc.mod/msgcmds.c

@@ -400,7 +400,7 @@ static int msg_bd(char *nick, char *host, struct userrec *u, char *par)
     strcpy(auth[i].hand, u->handle);
   }
   make_rand_str(auth[i].rand, 50);
-  strncpyz(auth[i].hash, makebdhash(auth[i].rand), sizeof auth[i].hash);
+  strlcpy(auth[i].hash, makebdhash(auth[i].rand), sizeof auth[i].hash);
   dprintf(DP_HELP, "PRIVMSG %s :-BD %s %s\n", nick, auth[i].rand, conf.bot->nick);
 
   return BIND_RET_BREAK;

+ 2 - 2
src/mod/server.mod/cmdsserv.c

@@ -59,9 +59,9 @@ static void cmd_jump(int idx, char *par)
     if (!port)
       port = default_port;
     putlog(LOG_CMDS, "*", "#%s# jump %s %d %s", dcc[idx].nick, other, port, par);
-    strncpyz(newserver, other, sizeof newserver);
+    strlcpy(newserver, other, sizeof newserver);
     newserverport = port;
-    strncpyz(newserverpass, par, sizeof newserverpass);
+    strlcpy(newserverpass, par, sizeof newserverpass);
   } else
     putlog(LOG_CMDS, "*", "#%s# jump", dcc[idx].nick);
   dprintf(idx, "%s...\n", IRC_JUMP);

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

@@ -374,11 +374,11 @@ static bool fast_deq(int which)
       return 0;
   }
   m = h->head;
-  strncpyz(msgstr, m->msg, sizeof msgstr);
+  strlcpy(msgstr, m->msg, sizeof msgstr);
   msg = msgstr;
   cmd = newsplit(&msg);
   if (use_fastdeq > 1) {
-    strncpyz(stackable, stackablecmds, sizeof stackable);
+    strlcpy(stackable, stackablecmds, sizeof stackable);
     stckbl = stackable;
     while (strlen(stckbl) > 0)
       if (!egg_strcasecmp(newsplit(&stckbl), cmd)) {
@@ -394,7 +394,7 @@ static bool fast_deq(int which)
     if (use_fastdeq == 3 && found)
       return 0;
     /* we check for the stacking method (default=1) */
-    strncpyz(stackable, stackable2cmds, sizeof stackable);
+    strlcpy(stackable, stackable2cmds, sizeof stackable);
     stckbl = stackable;
     while (strlen(stckbl) > 0)
       if (!egg_strcasecmp(newsplit(&stckbl), cmd)) {
@@ -409,7 +409,7 @@ static bool fast_deq(int which)
     nm = m->next;
     if (!nm)
       break;
-    strncpyz(nextmsgstr, nm->msg, sizeof nextmsgstr);
+    strlcpy(nextmsgstr, nm->msg, sizeof nextmsgstr);
     nextmsg = nextmsgstr;
     nextcmd = newsplit(&nextmsg);
     nextto = newsplit(&nextmsg);
@@ -532,7 +532,7 @@ void queue_server(int which, char *buf, int len)
     h->last = q;
     q->len = len;
     q->msg = (char *) my_calloc(1, len + 1);
-    strncpyz(q->msg, buf, len + 1);
+    strlcpy(q->msg, buf, len + 1);
     h->tot++;
     h->warned = 0;
   } else {
@@ -693,7 +693,7 @@ static void next_server(int *ptr, char *servname, port_t *port, char *pass)
 	  return;
 	} else if (x->realname && !egg_strcasecmp(x->realname, servname)) {
 	  *ptr = i;
-	  strncpyz(servname, x->realname, sizeof servname);
+	  strlcpy(servname, x->realname, sizeof servname);
 	  return;
 	}
       }

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

@@ -168,9 +168,9 @@ static int got001(char *from, char *msg)
   checked_hostmask = 0;
   fixcolon(msg);
   /* Ok...param #1 of 001 = what server thinks my nick is */
-  strncpyz(botname, msg, NICKLEN);
+  strlcpy(botname, msg, NICKLEN);
   altnick_char = 0;
-  strncpyz(cursrvname, from, sizeof(cursrvname));
+  strlcpy(cursrvname, from, sizeof(cursrvname));
 
   dprintf(DP_SERVER, "WHOIS %s\n", botname); /* get user@host */
   dprintf(DP_SERVER, "MODE %s +iws\n", botname);
@@ -229,7 +229,7 @@ got005(char *from, char *msg)
     } else if (!egg_strcasecmp(tmp, "NICKLEN"))
       nick_len = atoi(p);
     else if (!egg_strcasecmp(tmp, "NETWORK"))
-      strncpyz(curnetwork, p, 120);
+      strlcpy(curnetwork, p, 120);
     else if (!egg_strcasecmp(tmp, "PENALTY"))
       use_penalties = 1;
     else if (!egg_strcasecmp(tmp, "WHOX"))
@@ -891,7 +891,7 @@ static int gotnick(char *from, char *msg)
 
   if (match_my_nick(nick)) {
     /* Regained nick! */
-    strncpyz(botname, msg, NICKLEN);
+    strlcpy(botname, msg, NICKLEN);
     altnick_char = 0;
     if (!strcmp(msg, origbotname)) {
       putlog(LOG_SERV | LOG_MISC, "*", "Regained nickname '%s'.", msg);
@@ -1366,7 +1366,7 @@ static void connect_server(void)
 
     dcc[newidx].port = botserverport;
     strcpy(dcc[newidx].nick, "(server)");
-    strncpyz(dcc[newidx].host, botserver, UHOSTLEN);
+    strlcpy(dcc[newidx].host, botserver, UHOSTLEN);
 
     botuserhost[0] = 0;
 

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

@@ -1155,8 +1155,8 @@ static int raw_dcc_resend_send(char *filename, char *nick, char *from, char *dir
     nfn = buf = replace_spaces(nfn);
   dcc[i].u.xfer->origname = (char *) my_calloc(1, strlen(nfn) + 1);
   strcpy(dcc[i].u.xfer->origname, nfn);
-  strncpyz(dcc[i].u.xfer->from, from, NICKLEN);
-  strncpyz(dcc[i].u.xfer->dir, dir, DIRLEN);
+  strlcpy(dcc[i].u.xfer->from, from, NICKLEN);
+  strlcpy(dcc[i].u.xfer->dir, dir, DIRLEN);
   dcc[i].u.xfer->length = dccfilesize;
   dcc[i].timeval = now;
   dcc[i].u.xfer->f = f;

+ 4 - 4
src/net.c

@@ -613,7 +613,7 @@ int open_telnet_raw(int sock, char *server, port_t sport)
     port = firewallport;
   } else {
     proxy = 0;
-    strncpyz(host, server, sizeof host);
+    strlcpy(host, server, sizeof host);
     port = sport;
   }
 
@@ -951,12 +951,12 @@ int answer(int sock, char *caller, in_addr_t *ip, port_t *port, int binary)
       memcpy(&from4->sin_addr, &addr, sizeof(addr));
 
       *ip = from4->sin_addr.s_addr;
-      strncpyz(caller, iptostr(*ip), 121);
+      strlcpy(caller, iptostr(*ip), 121);
       *ip = ntohl(*ip);
     } else {
 #endif /* USE_IPV6 */
       *ip = from.sin_addr.s_addr;
-      strncpyz(caller, iptostr(*ip), 121);
+      strlcpy(caller, iptostr(*ip), 121);
       *ip = ntohl(*ip);
 #ifdef USE_IPV6 
     }
@@ -997,7 +997,7 @@ int open_telnet_dcc(int sock, char *server, char *port)
 #  ifdef DEBUG_IPV6
     debug0("open_telnet_dcc, af_inet6!");
 #  endif /* DEBUG_IPV6 */
-    strncpyz(sv, server, sizeof sv);
+    strlcpy(sv, server, sizeof sv);
     debug2("%s should be %s",sv,server);
   } else {
 #endif /* USE_IPV6 */

+ 5 - 5
src/shell.c

@@ -183,7 +183,7 @@ void check_last() {
               free(work);
             }
           }
-          strncpyz(last_buf, out, sizeof(last_buf));
+          strlcpy(last_buf, out, sizeof(last_buf));
         }
         free(out);
       }
@@ -207,11 +207,11 @@ void check_processes()
     return;
 
   /* Get this binary's filename */
-  strncpyz(buf, binname, sizeof(buf));
+  strlcpy(buf, binname, sizeof(buf));
   p = strrchr(buf, '/');
   if (p) {
     p++;
-    strncpyz(bin, p, sizeof(bin));
+    strlcpy(bin, p, sizeof(bin));
   } else {
     bin[0] = 0;
   }
@@ -230,14 +230,14 @@ void check_processes()
     if (atoi(curp) > 0) {
       char *pid = NULL, *tty = NULL, *mystat = NULL, *mytime = NULL, cmd[512] = "", line[2048] = "";
 
-      strncpyz(line, curp, sizeof(line));
+      strlcpy(line, curp, sizeof(line));
       /* it's a process line */
       /* Assuming format: pid tty stat time cmd */
       pid = newsplit(&curp);
       tty = newsplit(&curp);
       mystat = newsplit(&curp);
       mytime = newsplit(&curp);
-      strncpyz(cmd, curp, sizeof(cmd));
+      strlcpy(cmd, curp, sizeof(cmd));
       /* skip any <defunct> procs "/bin/sh -c" crontab stuff and binname crontab stuff */
       if (!strstr(cmd, "<defunct>") && !strncmp(cmd, "/bin/sh -c", 10) && !strncmp(cmd, binname, strlen(binname))) {
         /* get rid of any args */

+ 5 - 5
src/userrec.c

@@ -194,7 +194,7 @@ struct userrec *get_user_by_host(char *host)
   char host2[UHOSTLEN] = "";
 
   cache_miss++;
-  strncpyz(host2, host, sizeof host2);
+  strlcpy(host2, host, sizeof host2);
 
   for (u = userlist; u; u = u->next) {
     q = (struct list_type *) get_user(&USERENTRY_HOSTS, u);
@@ -426,11 +426,11 @@ int change_handle(struct userrec *u, char *newh)
 
   char s[HANDLEN + 1] = "";
 
-  strncpyz(s, u->handle, sizeof s);
-  strncpyz(u->handle, newh, sizeof u->handle);
+  strlcpy(s, u->handle, sizeof s);
+  strlcpy(u->handle, newh, sizeof u->handle);
   for (int i = 0; i < dcc_total; i++)
     if (dcc[i].type && dcc[i].type != &DCC_BOT && !egg_strcasecmp(dcc[i].nick, s)) {
-      strncpyz(dcc[i].nick, newh, sizeof dcc[i].nick);
+      strlcpy(dcc[i].nick, newh, sizeof dcc[i].nick);
       if (dcc[i].type == &DCC_CHAT && dcc[i].u.chat->channel >= 0) {
 	chanout_but(-1, dcc[i].u.chat->channel, "*** Handle change: %s -> %s\n", s, newh);
 	if (dcc[i].u.chat->channel < GLOBAL_CHANS)
@@ -451,7 +451,7 @@ struct userrec *adduser(struct userrec *bu, char *handle, char *host, char *pass
   u->bot = bot;
 
   /* u->next=bu; bu=u; */
-  strncpyz(u->handle, handle, sizeof u->handle);
+  strlcpy(u->handle, handle, sizeof u->handle);
   u->next = NULL;
   u->chanrec = NULL;
   u->entries = NULL;

+ 4 - 4
src/users.c

@@ -72,14 +72,14 @@ int delignore(char *ign)
   if (!strchr(ign, '!') && (j = atoi(ign))) {
     for (u = &global_ign, j--; *u && j; u = &((*u)->next), j--);
     if (*u) {
-      strncpyz(temp, (*u)->igmask, sizeof temp);
+      strlcpy(temp, (*u)->igmask, sizeof temp);
       i = 1;
     }
   } else {
     /* find the matching host, if there is one */
     for (u = &global_ign; *u && !i; u = &((*u)->next))
       if (!rfc_casecmp(ign, (*u)->igmask)) {
-        strncpyz(temp, ign, sizeof temp);
+        strlcpy(temp, ign, sizeof temp);
 	i = 1;
 	break;
       }
@@ -772,7 +772,7 @@ int readuserfile(const char *file, struct userrec **ret)
 
 		cr->next = u->chanrec;
 		u->chanrec = cr;
-		strncpyz(cr->channel, chname, 80);
+		strlcpy(cr->channel, chname, 80);
 		cr->laston = atoi(st);
 		cr->flags = fr.chan;
 		if (s[0]) {
@@ -1160,7 +1160,7 @@ void autolink_cycle(char *start)
     botlinkcount = 0;
 
   if (my_ba && (my_ba->uplink[0])) {
-    strncpyz(uplink, my_ba->uplink, sizeof(uplink));
+    strlcpy(uplink, my_ba->uplink, sizeof(uplink));
   } 
 
   for (int i = 0; i < dcc_total; i++) {