Browse Source

* Port [3228] to 1.2.14
* Fix bots sharing wrong channel keys over botnet.



svn: 3229

Bryan Drewery 19 years ago
parent
commit
89ebb76260
2 changed files with 8 additions and 11 deletions
  1. 1 0
      doc/UPDATES
  2. 7 11
      src/mod/irc.mod/irc.c

+ 1 - 0
doc/UPDATES

@@ -19,6 +19,7 @@ Lines prefixed with '-' were disabled before release and are not finished, or ar
 * Bots now use the shell username instead of botnick when ident does not work.
 * Localhubs now auto add *!~username@... hosts instead of *!~nick@... hosts for their leafs.
 * Make bot chmod() itself when accessing its binary.
+* Fix bots sharing wrong channel keys over botnet.
 
 1.2.13 - http://wraith.shatow.net/milestone/1.2.13
 * Fix cmd_chanset accepting invalid flags

+ 7 - 11
src/mod/irc.mod/irc.c

@@ -477,25 +477,19 @@ getin_request(char *botnick, char *code, char *par)
       return;
     }
 
-    char s[256] = "", *p = NULL, *p2 = NULL, *p3 = NULL;
+    char s[256] = "", *p = NULL, *p2 = NULL;
     bool sendi = 0;
 
     strcpy(s, getchanmode(chan));
     p = (char *) &s;
     p2 = newsplit(&p);
-    p3 = newsplit(&p);
 
     if (strchr(p2, 'l')) {
       if (!me_op(chan)) {
         putlog(LOG_GETIN, "*", "inreq from %s/%s for %s - I haven't got ops", botnick, nick, chan->dname);
         return;
       } else {
-        int lim = chan->channel.members + 5, curlim;
-
-        if (!*p)
-          curlim = atoi(p3);
-        else
-          curlim = atoi(p);
+        int lim = chan->channel.members + 5, curlim = chan->channel.maxmembers;
         if (curlim > 0 && curlim < lim) {
           char s2[16] = "";
 
@@ -565,11 +559,13 @@ getin_request(char *botnick, char *code, char *par)
       }
     }
     if (strchr(p2, 'k')) {
+      char *key = chan->channel.key[0] ? chan->channel.key : chan->key_prot;
       sendi = 0;
-      tmp = (char *) my_calloc(1, strlen(chan->dname) + strlen(p3) + 7);
-      simple_sprintf(tmp, "gi K %s %s", chan->dname, p3);
+      size_t siz = strlen(chan->dname) + strlen(key ? key : 0) + 6 + 1;
+      tmp = (char *) my_calloc(1, siz);
+      simple_snprintf(tmp, siz, "gi K %s %s", chan->dname, key ? key : "");
       putbot(botnick, tmp);
-      putlog(LOG_GETIN, "*", "inreq from %s/%s for %s - Sent key (%s)", botnick, nick, chan->dname, p3);
+      putlog(LOG_GETIN, "*", "inreq from %s/%s for %s - Sent key (%s)", botnick, nick, chan->dname, key ? key : "");
       free(tmp);
     }
     if (strchr(p2, 'i')) {