Procházet zdrojové kódy

* Fix segfault on csircd with /KNOCK

Bryan Drewery před 16 roky
rodič
revize
02ce3e0d9f
2 změnil soubory, kde provedl 23 přidání a 6 odebrání
  1. 1 0
      doc/UPDATES
  2. 22 6
      src/mod/irc.mod/chan.c

+ 1 - 0
doc/UPDATES

@@ -44,6 +44,7 @@
 * No longer bundling Openssl code; It is now required to be installed to compile.
 * No longer bundling Openssl code; It is now required to be installed to compile.
 * Cleanup cmd_botcmd restrictions.
 * Cleanup cmd_botcmd restrictions.
 * Add 'chanset +rbl' which uses list of servers from 'set rbl-servers'. Only +r bots will enforce this.
 * Add 'chanset +rbl' which uses list of servers from 'set rbl-servers'. Only +r bots will enforce this.
+* Fix segfault with /KNOCK on csircd
 
 
 1.2.16.1
 1.2.16.1
 * Fix linux compile errors
 * Fix linux compile errors

+ 22 - 6
src/mod/irc.mod/chan.c

@@ -1616,23 +1616,39 @@ static int got341(char *from, char *msg)
 
 
 /* got 710: knock
 /* got 710: knock
  * <server> 710 <to> <channel> <from> :<reason?>
  * <server> 710 <to> <channel> <from> :<reason?>
- * :irc.umich.edu 710 #wraith #wraith bryand!bryan@oper.blessed.net :has asked for an invite.
+ * ratbox :irc.umich.edu 710 #wraith #wraith bryand!bryan@oper.blessed.net :has asked for an invite.
+ * csircd :irc.nac.net 710 * bryan_!bryan@pluto.xzibition.com has knocked on channel #wraith for an invite
+ *
  */
  */
 static int got710(char *from, char *msg)
 static int got710(char *from, char *msg)
 {
 {
   char *chname = NULL;
   char *chname = NULL;
   struct chanset_t *chan = NULL;
   struct chanset_t *chan = NULL;
+  char buf[UHOSTLEN] = "", *uhost = buf, *nick;
 
 
   chname = newsplit(&msg);
   chname = newsplit(&msg);
-  chan = findchan(chname);
+  if (!strcmp(chname, "*")) {
+    //csircd
+    uhost = newsplit(&msg);
+    //has knocked on channel #CHAN for an invite
+    newsplit(&msg); //has
+    newsplit(&msg); //knocked
+    newsplit(&msg); //on
+    newsplit(&msg); //channel
+    chname = newsplit(&msg);
+  } else {
+    //Hybrid/ratbox
+    newsplit(&msg); //not used
+    uhost = newsplit(&msg);
+  }
 
 
-  if (!channel_knock(chan) || !dovoice(chan))
+  if (!strchr(CHANMETA, chname[0]) || !strchr(uhost, '!'))
     return 0;
     return 0;
 
 
-  char buf[UHOSTLEN] = "", *uhost = buf, *nick;
+  chan = findchan(chname);
 
 
-  newsplit(&msg); //not used
-  uhost = newsplit(&msg);
+  if (!channel_knock(chan) || !dovoice(chan))
+    return 0;
 
 
   struct userrec *u = get_user_by_host(uhost);
   struct userrec *u = get_user_by_host(uhost);