Przeglądaj źródła

* More nicklen/handlen cleanups

Bryan Drewery 16 lat temu
rodzic
commit
3881a00742

+ 2 - 2
src/auth.c

@@ -45,7 +45,7 @@ bd::HashTable<bd::String, Auth*> Auth::ht_host(10);
 Auth::Auth(const char *_nick, const char *_host, struct userrec *u)
 {
   Status(AUTHING);
-  strlcpy(nick, _nick, nick_len + 1);
+  strlcpy(nick, _nick, NICKLEN);
   strlcpy(host, _host, UHOSTLEN);
   if (u) {
     user = u;
@@ -88,7 +88,7 @@ void Auth::Done()
 }
 
 void Auth::NewNick(const char *newnick) {
-  strlcpy(nick, newnick, nick_len + 1);
+  strlcpy(nick, newnick, NICKLEN);
 }
 
 Auth *Auth::Find(const char *_host)

+ 1 - 1
src/chan.h

@@ -211,7 +211,7 @@ struct chanset_t {
  *char temp[121];
  */
   char topic[121];
-  char added_by[NICKLEN];	/* who added the channel? */
+  char added_by[HANDLEN + 1];	/* who added the channel? */
   char floodwho[FLOOD_CHAN_MAX][128];
   char deopd[NICKLEN];		/* last person deop'd (must change	*/
   char dname[81];               /* what the users know the channel as like !eggdev */

+ 1 - 1
src/chanprog.c

@@ -58,7 +58,7 @@ char *def_chanset = "+enforcebans +dynamicbans +userbans -bitch +cycle -inactive
 struct chanset_t 	*chanset = NULL;	/* Channel list			*/
 struct chanset_t	*chanset_default = NULL;	/* Default channel list */
 char 			admin[121] = "";	/* Admin info			*/
-char			origbotnick[NICKLEN] = "";	/* from -B (placed into conf.bot->nick .. for backup when conf is cleared */
+char			origbotnick[HANDLEN + 1] = "";	/* from -B (placed into conf.bot->nick .. for backup when conf is cleared */
 char 			origbotname[NICKLEN] = "";	/* Nick to regain */
 char                    jupenick[NICKLEN] = "";
 char 			botname[NICKLEN] = "";	/* IRC nickname */

+ 1 - 1
src/chanprog.h

@@ -34,7 +34,7 @@ void load_internal_users();
 void setup_HQ(int);
 
 extern struct chanset_t		*chanset, *chanset_default;
-extern char			admin[], origbotnick[NICKLEN], origbotname[NICKLEN], jupenick[NICKLEN], botname[NICKLEN], *def_chanset;
+extern char			admin[], origbotnick[HANDLEN + 1], origbotname[NICKLEN], jupenick[NICKLEN], botname[NICKLEN], *def_chanset;
 extern port_t			my_port;
 extern bool			reset_chans, cookies_disabled;
 

+ 6 - 6
src/dcc.c

@@ -346,12 +346,12 @@ bot_version(int idx, char *par)
 void
 failed_link(int idx)
 {
-  char s[NICKLEN] = "", s1[512] = "";
+  char nick[NICKLEN] = "", s1[NICKLEN + 17 + 1] = "";
 
   if (dcc[idx].u.bot->linker[0]) {
-    simple_snprintf(s, sizeof s, "Couldn't link to %s.", dcc[idx].nick);
-    strlcpy(s1, dcc[idx].u.bot->linker, sizeof(s1));
-    add_note(s1, conf.bot->nick, s, -2, 0);
+    simple_snprintf(s1, sizeof s1, "Couldn't link to %s.", dcc[idx].nick);
+    strlcpy(nick, dcc[idx].u.bot->linker, sizeof(s1));
+    add_note(nick, conf.bot->nick, s1, -2, 0);
   }
   if (dcc[idx].u.bot->numver >= (-1))
     putlog(LOG_BOTS, "*", "Failed link to %s.", dcc[idx].nick);
@@ -359,10 +359,10 @@ failed_link(int idx)
     killsock(dcc[idx].sock);
     dcc[idx].sock = -1;
   }
-  strlcpy(s, dcc[idx].nick, sizeof(s));
+  strlcpy(nick, dcc[idx].nick, sizeof(nick));
   lostdcc(idx);
   if (conf.bot->hub || conf.bot->localhub)
-    autolink_cycle(s);            /* Check for more auto-connections */
+    autolink_cycle(nick);            /* Check for more auto-connections */
 }
 
 static void

+ 1 - 1
src/dcc.h

@@ -62,7 +62,7 @@ struct dcc_t {
   bool whowas;
   int dns_id;
   port_t port;
-  char simulbot[NICKLEN];       /* used for hub->leaf cmd simulation, holds bot that results should be sent to */
+  char simulbot[HANDLEN + 1];       /* used for hub->leaf cmd simulation, holds bot that results should be sent to */
   char hash[MD5_HASH_LENGTH + 1];                /* used for dcc authing */
   char shahash[SHA_HASH_LENGTH + 1];
   char nick[NICKLEN];

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

@@ -1211,7 +1211,7 @@ static void cmd_chaninfo(int idx, char *par)
     dprintf(idx, "No such channel.\n");
     return;
   } else {
-    char nick[NICKLEN] = "", date[81] = "";
+    char nick[HANDLEN + 1] = "", date[81] = "";
     int deflag = 0;
 
     if (chan->added_ts) {

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

@@ -356,7 +356,7 @@ int channel_modify(char *result, struct chanset_t *chan, int items, char **item,
 	  strlcpy(result, "addedby needs argument", RESULT_LEN);
 	return ERROR;
       }
-      strlcpy(chan->added_by, item[i], NICKLEN);
+      strlcpy(chan->added_by, item[i], sizeof(chan->added_by));
     } else if (!cmd && !strcmp(item[i], "addedts")) {
       i++;
       if (i >= items) {

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

@@ -186,7 +186,7 @@ static int msg_op(char *nick, char *host, struct userrec *u, char *par)
 
 static int msg_ident(char *nick, char *host, struct userrec *u, char *par)
 {
-  char s[UHOSTLEN] = "", s1[UHOSTLEN] = "", *pass = NULL, who[NICKLEN] = "";
+  char s[UHOSTLEN] = "", s1[UHOSTLEN] = "", *pass = NULL, who[HANDLEN + 1] = "";
   struct userrec *u2 = NULL;
 
   if (match_my_nick(nick) || (u && u->bot))
@@ -194,10 +194,9 @@ static int msg_ident(char *nick, char *host, struct userrec *u, char *par)
 
   pass = newsplit(&par);
   if (!par[0])
-    strlcpy(who, nick, sizeof(nick));
+    strlcpy(who, nick, sizeof(who));
   else {
     strlcpy(who, par, sizeof(who));
-    who[NICKMAX] = 0;
   }
   u2 = get_user_by_handle(userlist, who);
   if (u2 && rfc_casecmp(who, origbotname) && !u2->bot) {

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

@@ -115,7 +115,7 @@ static int gotfake433(char *nick)
 {
   //Failed to get jupenick on connect, try normal nick
   if (altnick_char == 0 && jupenick[0] && !rfc_casecmp(botname, jupenick)) {
-    strlcpy(botname, origbotname, NICKLEN);
+    strlcpy(botname, origbotname, sizeof(botname));
   } else //Rotate on failed normal nick
     rotate_nick(botname, origbotname);
   putlog(LOG_SERV, "*", "NICK IN USE: '%s' Trying '%s'", nick, botname);
@@ -192,7 +192,7 @@ void rehash_server(const char *servname, const char *nick)
     curservport = dcc[servidx].port;
 
   if (nick && nick[0]) {
-    strlcpy(botname, nick, NICKLEN);
+    strlcpy(botname, nick, sizeof(botname));
 
     dprintf(DP_SERVER, "WHOIS %s\n", botname); /* get user@host */
     dprintf(DP_SERVER, "USERHOST %s\n", botname); /* get user@ip */
@@ -953,7 +953,7 @@ static int got432(char *from, char *msg)
   } else {
     putlog(LOG_MISC, "*", "Server says my %snick '%s' is invalid.", is_jnick ? "jupe" : "", botname);
     if (jupenick[0] && !strcmp(botname, jupenick))
-      strlcpy(botname, origbotname, NICKLEN);
+      strlcpy(botname, origbotname, sizeof(botname));
     else
       rotate_nick(botname, origbotname);
 
@@ -991,7 +991,7 @@ static int got433(char *from, char *msg)
     } else {  //Else need to find a new nick
       // Failed to get jupenick, not on origbotname now, try for origbotname and rotate from there
       if (tried_jupenick) {
-        strlcpy(rnick, origbotname, NICKLEN);
+        strlcpy(rnick, origbotname, sizeof(rnick));
         tried_jupenick = 0;
       } else {
         // Was a failed attempt at a rotated nick, keep rotating on origbotname
@@ -1111,7 +1111,7 @@ static int gotnick(char *from, char *msg)
 
   if (match_my_nick(nick)) {
     /* Regained nick! */
-    strlcpy(botname, msg, NICKLEN);
+    strlcpy(botname, msg, sizeof(botname));
 
     tried_jupenick = 0;
     tried_nick = 0;