Răsfoiți Sursa

Merge branch 'maint'

* maint:
  par can't be NULL
  Remove unused value.
  Remove unused value.
  Fix logic error resulting in NULL dereference. Not a possible case currently.
  Remove unused value.
  Fix redundant channel lookup.
  No need to lookup the user here until TCL is readded.
  Remove unused strlen values.
  Fix possible NULL dereference processing AWAY messages.
  No need to lookup the user here until TCL is readded.
  No need to set xk here, it is done below.
  Fix handling of olddata for set: string.
  Fix unlikely crash when setting boolean values.
  Fix conversion of cmdpasses from 1.3 format.
  Remove unneeded value.
  Fix logic error resulting in NULL dereference. Not a possible case currently.
Bryan Drewery 11 ani în urmă
părinte
comite
f2590a9637

+ 1 - 0
doc/UPDATES

@@ -17,6 +17,7 @@ maint
     a binary that would rely on having a specific compiler version installed
     and avoids issues when updating the local compiler. This also fixes
     building a binary with GCC on FreeBSD and using it on a clang-only system.
+  * Fix conversion of command passes from ancient 1.3 format.
 
 1.4.5
   * Remove ahbl as it now positively identifies all hosts as abusive

+ 3 - 5
src/cmds.cc

@@ -979,7 +979,7 @@ static void cmd_channels(int idx, char *par) {
       show_channels(idx, NULL);
   }
 
-  if ((dcc[idx].user->flags & USER_MASTER) && !(par && par[0]))
+  if ((dcc[idx].user->flags & USER_MASTER) && !par[0])
     dprintf(idx, "You can also %schannels <user|%%group>\n", (dcc[idx].u.chat->channel >= 0) ? settings.dcc_prefix : "");
 }
 
@@ -1436,7 +1436,6 @@ static void cmd_botcmd(int idx, char *par)
     rand_leaf = 1;
     for (tbot = tandbot; tbot; tbot = tbot->next) {
       if (bot_hublevel(tbot->u) == 999) {
-        group_match = false;
         if (group) {
           group_match = bd::String(var_get_bot_data(tbot->u, "groups", true)).split(',').find(group) != bd::String::npos;
         } else {
@@ -1460,7 +1459,6 @@ static void cmd_botcmd(int idx, char *par)
     all_localhub = 1;
     for (tbot = tandbot; tbot; tbot = tbot->next) {
       if (bot_hublevel(tbot->u) == 999 && tbot->localhub) {
-        group_match = false;
         if (group) {
           group_match = bd::String(var_get_bot_data(tbot->u, "groups", true)).split(',').find(group) != bd::String::npos;
         } else {
@@ -2908,7 +2906,7 @@ static void cmd_last(int idx, char *par) {
 
   char user[20] = "";
 
-  if (par && par[0]) {
+  if (par[0]) {
     strlcpy(user, par, sizeof(user));
   } else if (conf.username) {
     strlcpy(user, conf.username, sizeof(user));
@@ -3436,7 +3434,7 @@ static void cmd_nopass(int idx, char *par)
   size_t userssiz = 1;
   bool dopass = 0;
 
-  putlog(LOG_CMDS, "*", "#%s# nopass %s", dcc[idx].nick, (par && par[0]) ? par : "");
+  putlog(LOG_CMDS, "*", "#%s# nopass %s", dcc[idx].nick, par[0] ? par : "");
 
   if (par[0])
     dopass = 1;

+ 1 - 3
src/dccutil.cc

@@ -1017,8 +1017,6 @@ identd_open(const char *sourceIp, const char *destIp, int identd)
       if (dcc[idx].type == &DCC_IDENTD_CONNECT)
         return;                   /* it's already open :) */
 
-    idx = -1;
-
     identd_hack = 1;
 #ifdef USE_IPV6
     i = open_listen_by_af(&port, AF_INET6);
@@ -1159,7 +1157,7 @@ int check_cmd_pass(const char *cmd, char *pass)
 
         simple_snprintf(ctmp, sizeof(ctmp), "%s %s", cmd, epass);
         free(epass);
-        set_cmd_pass(tmp, 1);
+        set_cmd_pass(ctmp, 1);
         return 1;
       }
 

+ 2 - 2
src/flags.cc

@@ -461,9 +461,9 @@ real_chk_op(const struct flag_record fr, const struct chanset_t *chan, bool botb
 int
 chk_autoop(const struct flag_record fr, const struct chanset_t *chan)
 {
-  if (glob_bot(fr))
+  if (glob_bot(fr) || !chan)
     return 0;
-  if (!chan || (!channel_take(chan) && !privchan(fr, chan, PRIV_OP) && chk_op(fr, chan) && !chk_deop(fr, chan))) {
+  if (!channel_take(chan) && !privchan(fr, chan, PRIV_OP) && chk_op(fr, chan) && !chk_deop(fr, chan)) {
     if (channel_autoop(chan) || chan_autoop(fr) || glob_autoop(fr))
       return 1;
   }

+ 3 - 1
src/mod/irc.mod/chan.cc

@@ -3152,7 +3152,9 @@ static int gotquit(char *from, char *msg)
   struct userrec *u = NULL;
 
   strlcpy(from2, from, sizeof(from2));
+#ifdef TCL
   u = get_user_by_host(from2);
+#endif
   nick = splitnick(&from);
   fixcolon(msg);
   /* Fred1: Instead of expensive wild_match on signoff, quicker method.
@@ -3386,7 +3388,7 @@ static int gotnotice(char *from, char *msg)
   
   bool ignoring = match_ignore(from);
   char *to = newsplit(&msg), *realto = (*to == '@') ? to + 1 : to;
-  struct chanset_t *chan = findchan(realto); 
+  struct chanset_t *chan = NULL;
 
   chan = findchan(realto);
   if (!chan)

+ 5 - 2
src/mod/irc.mod/irc.cc

@@ -921,7 +921,11 @@ getin_request(char *botnick, char *code, char *par)
 static void
 request_op(struct chanset_t *chan)
 {
-  if (!chan || (chan && (channel_pending(chan) || !shouldjoin(chan) || !channel_active(chan) || me_op(chan)))) {
+  if (!chan) {
+    return;
+  }
+
+  if (channel_pending(chan) || !shouldjoin(chan) || !channel_active(chan) || me_op(chan)) {
     chan->channel.do_opreq = 0;
     return;
   }
@@ -1606,7 +1610,6 @@ check_expired_chanstuff(struct chanset_t *chan)
       if (m->user && m->user->bot) {
         ++bot_ops;
       }
-      m = n;
     }
     // Update minutely
     chan->channel.splitmembers = splitmembers;

+ 1 - 1
src/mod/irc.mod/mode.cc

@@ -1260,7 +1260,7 @@ gotmode(char *from, char *msg)
 
           /* manop */
           if (chan->manop && u && !u->bot) {
-            n = i = 0;
+            i = 0;
 
             switch (role) {
               case 0:

+ 1 - 3
src/mod/server.mod/server.cc

@@ -449,7 +449,7 @@ static void calc_penalty(char * msg, size_t len)
         penalty += 5;
     }
   } else if (!strcasecmp(cmd, "AWAY")) {
-    if (strlen(msg) > 0)
+    if (msg && strlen(msg) > 0)
       penalty += 2;
     else
       penalty += 1;
@@ -575,7 +575,6 @@ static bool fast_deq(int which)
       }    
   }
   to = newsplit(&msg);
-  len = strlen(to);
   victims = to;
   while (m) {
     nm = m->next;
@@ -585,7 +584,6 @@ static bool fast_deq(int which)
     nextmsg = nextmsgstr;
     nextcmd = newsplit(&nextmsg);
     nextto = newsplit(&nextmsg);
-    len = strlen(nextto);
     if ( strcmp(to, nextto) /* we don't stack to the same recipients */
         && !strcmp(cmd, nextcmd) && !strcmp(msg, nextmsg)
         && ((strlen(cmd) + victims.length() + strlen(nextto)

+ 2 - 0
src/mod/server.mod/servmsg.cc

@@ -595,7 +595,9 @@ static bool detect_flood(char *floodnick, char *floodhost, char *from, int which
     lastmsgs[which] = 0;
     lastmsgtime[which] = 0;
     lastmsghost[which][0] = 0;
+#ifdef TCL
     u = get_user_by_host(from);
+#endif
     /* Private msg */
     simple_snprintf(h, sizeof(h), "*!*@%s", p);
     putlog(LOG_MISC, "*", "Flood from @%s!  Placing on ignore!", p);

+ 3 - 3
src/set.cc

@@ -288,7 +288,7 @@ sdprintf("var (mem): %s -> %s", var->name, datain ? datain : "(NULL)");
   } else if (var->flags & VAR_BOOL) {
     bool olddata = *(bool*)(var->mem);
     bool num = 0;
-    if (data[0] == '0')
+    if (data == NULL || data[0] == '0')
       num = 0;
     else if (data[0] == '1')
       num = 1;
@@ -317,7 +317,7 @@ sdprintf("var (mem): %s -> %s", var->name, datain ? datain : "(NULL)");
       }
     }
   } else if (var->flags & (VAR_STRING|VAR_WORD)) {
-    char *olddata = ((char*) var->mem) ? strdup((char*) var->mem) : NULL;
+    char *olddata = ((char*) var->mem)[0] ? strdup((char*) var->mem) : NULL;
 
     if (data)
       strlcpy((char *) var->mem, data, var->size);
@@ -735,7 +735,7 @@ void var_parse_my_botset()
   /* look for local vars inside our own USERENTRY_SET and set them in our cfg struct */
   set_noshare = 1;                      /* why bother sharing out our LOCAL settings? */
   parsing_botset = 1;
-  xk = x = (struct xtra_key *) get_user(&USERENTRY_SET, conf.bot->u);
+  x = (struct xtra_key *) get_user(&USERENTRY_SET, conf.bot->u);
   for (i = 0; vars[i].name; i++) {
     xk = x;	/* reset pointer to beginning */