Explorar o código

* Fixed a segfault with mode parsing. (#25)

svn: 2266
Bryan Drewery %!s(int64=21) %!d(string=hai) anos
pai
achega
a6b5556550
Modificáronse 2 ficheiros con 5 adicións e 1 borrados
  1. 1 0
      doc/UPDATES
  2. 4 1
      src/mod/irc.mod/mode.c

+ 1 - 0
doc/UPDATES

@@ -26,6 +26,7 @@ Lines prefixed with '-' were disabled before release and are not finished, or ar
 * Fixed another fatal bug with cmd_conf, this should fix it for good.
 * Added var 'manop-warn' to allow disabling the new manop NOTICE warnings when msg opping.
 * Added irc.ptptech.com to default servers/servers6
+* Fixed a segfault with mode parsing. (#25)
 
 1.2.4
 * Fixed cmd_botset not displaying botnick.

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

@@ -967,7 +967,7 @@ gotmode(char *from, char *msg)
     if ((channel_active(chan) || channel_pending(chan))) {
       int i = 0, modecnt = 0, ops = 0, deops = 0, bans = 0, unbans = 0;
       bool me_opped = 0;
-      char **modes = (char **) my_calloc(modesperline + 1, sizeof(char *));
+      char **modes = (char **) my_calloc(1, sizeof(char *));
       char *nick = NULL, *chg = NULL, s[UHOSTLEN] = "", sign = '+', *mp = NULL, *isserver = NULL;
       size_t z = strlen(msg);
       struct userrec *u = NULL;
@@ -1015,6 +1015,9 @@ gotmode(char *from, char *msg)
           fixcolon(mp);
 
           /* Just want o's and b's */
+          modes = (char **) my_realloc(modes, (modecnt * sizeof(char *)) + sizeof(char *));
+//      char **modes = (char **) my_calloc(modesperline + 1, sizeof(char *));
+
           modes[modecnt] = (char *) my_calloc(1, strlen(mp) + 4);
           simple_sprintf(modes[modecnt], "%c%c %s", sign, chg[0], mp ? mp : "");
           modecnt++;