Parcourir la source

* Fixed cmd_chanset not displaying ALL invalid channel flags, although, there are still *many* errors like with with the chanset code. (#136)

svn: 2310
Bryan Drewery il y a 21 ans
Parent
commit
299a1a8232

+ 1 - 0
doc/UPDATES

@@ -55,6 +55,7 @@ Lines prefixed with '-' were disabled before release and are not finished, or ar
 * Trace detection cannot be set to 'ignore', lowest setting is now: 'die'
 * Fixed cmd_slowjoin (#129)
 * Automatic host adding by localhubs now sanity checks if the hosts will conflict with other bots/users. (#137)
+* Fixed cmd_chanset not displaying ALL invalid channel flags, although, there are still *many* errors like with with the chanset code. (#136)
 
 1.2.4
 * Fixed cmd_botset not displaying botnick.

+ 2 - 0
src/eggdrop.h

@@ -43,6 +43,8 @@
 #define MAX_BOTS     500
 #define SERVLEN      60
 
+#define RESULT_LEN 	1024
+
 /*
  *     The 'configure' script should make this next part automatic,
  *     so you shouldn't need to adjust anything below.

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

@@ -223,7 +223,7 @@ static void got_cjoin(char *botnick, char *code, char *par)
   if (chan)
     return;
 sdprintf("OPTIONS: %s", options);
-  char result[1024] = "";
+  char result[RESULT_LEN] = "";
 
   if (channel_add(result, chname, options) == ERROR) /* drummer */
     putlog(LOG_BOTS, "@", "Invalid channel or channel options from %s for %s: %s", botnick, chname, result);

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

@@ -495,7 +495,7 @@ static void cmd_chinfo(int idx, char *par)
 static void cmd_slowjoin(int idx, char *par)
 {
   int intvl = 0, delay = 0, count = 1;
-  char *chname = NULL, *p = NULL, buf[2048] = "", buf2[1048] = "";
+  char *chname = NULL, *p = NULL, buf[2048] = "", buf2[RESULT_LEN] = "";
   struct chanset_t *chan = NULL;
   tand_t *bot = NULL;
 
@@ -902,7 +902,7 @@ static void cmd_down(int idx, char *par)
 
 static void pls_chan(int idx, char *par, char *bot)
 {
-  char *chname = NULL, result[1024] = "", buf[2048] = "";
+  char *chname = NULL, result[RESULT_LEN] = "", buf[2048] = "";
   struct chanset_t *chan = NULL;
 
   if (!bot)
@@ -1253,7 +1253,7 @@ static void cmd_chaninfo(int idx, char *par)
 
 static void cmd_chanset(int idx, char *par)
 {
-  char *chname = NULL, result[1024] = "";
+  char *chname = NULL, result[RESULT_LEN] = "";
   struct chanset_t *chan = NULL;
   int all = 0;
 

+ 34 - 30
src/mod/channels.mod/tclchan.c

@@ -160,12 +160,12 @@ static int FindElement(char *resultBuf, const char *list, size_t listLength,
     if (p == limit) {
         if (openBraces != 0) {
             if (resultBuf) {
-                simple_sprintf(resultBuf, "unmatched open brace in list");
+                simple_snprintf(resultBuf, RESULT_LEN, "unmatched open brace in list");
             }
             return ERROR;
         } else if (inQuotes) {
             if (resultBuf) {
-                simple_sprintf(resultBuf, "unmatched open quote in list");
+                simple_snprintf(resultBuf, RESULT_LEN, "unmatched open quote in list");
             }
             return ERROR;
         }
@@ -257,7 +257,7 @@ int SplitList(char *resultBuf, const char *list, int *argcPtr, const char ***arg
         if (i >= size) {
             free((char *) argv);
             if (resultBuf)
-                simple_sprintf(resultBuf, "internal error in SplitList");
+                simple_snprintf(resultBuf, RESULT_LEN, "internal error in SplitList");
             return ERROR;
         }
 
@@ -290,7 +290,7 @@ int channel_modify(char *result, struct chanset_t *chan, int items, char **item)
   int old_status = chan->status,
       old_mode_mns_prot = chan->mode_mns_prot,
       old_mode_pls_prot = chan->mode_pls_prot;
-  char s[121] = "";
+  char s[121] = "", result_extra[RESULT_LEN / 2] = "";
 
   for (register int i = 0; i < items; i++) {
 /* Chanchar template
@@ -298,7 +298,7 @@ int channel_modify(char *result, struct chanset_t *chan, int items, char **item)
       i++;
       if (i >= items) {
         if (result)
-          simple_sprintf(result, "channel temp needs argument");
+          simple_snprintf(result, RESULT_LEN, "channel temp needs argument");
         return ERROR;
       }
       strlcpy(chan->temp, item[i], sizeof(chan->temp));
@@ -308,7 +308,7 @@ int channel_modify(char *result, struct chanset_t *chan, int items, char **item)
       i++;
       if (i >= items) {
 	if (result)
-	  simple_sprintf(result, "channel chanmode needs argument");
+	  simple_snprintf(result, RESULT_LEN, "channel chanmode needs argument");
 	return ERROR;
       }
       strlcpy(s, item[i], 121);
@@ -319,7 +319,7 @@ int channel_modify(char *result, struct chanset_t *chan, int items, char **item)
       i++;
       if (i >= items) {
 	if (result)
-	  simple_sprintf(result, "topic needs argument");
+	  simple_snprintf(result, RESULT_LEN, "topic needs argument");
 	return ERROR;
       }
       p = replace(item[i], "{", "[");
@@ -329,7 +329,7 @@ int channel_modify(char *result, struct chanset_t *chan, int items, char **item)
       i++;
       if (i >= items) {
 	if (result)
-	  simple_sprintf(result, "addedby needs argument");
+	  simple_snprintf(result, RESULT_LEN, "addedby needs argument");
 	return ERROR;
       }
       strlcpy(chan->added_by, item[i], NICKLEN);
@@ -337,7 +337,7 @@ int channel_modify(char *result, struct chanset_t *chan, int items, char **item)
       i++;
       if (i >= items) {
 	if (result)
-	  simple_sprintf(result, "addedts needs argument");
+	  simple_snprintf(result, RESULT_LEN, "addedts needs argument");
 	return ERROR;
       }
       chan->added_ts = atoi(item[i]);
@@ -345,7 +345,7 @@ int channel_modify(char *result, struct chanset_t *chan, int items, char **item)
       i++;
       if (i >= items) {
 	if (result)
-	  simple_sprintf(result, "channel idle-kick needs argument");
+	  simple_snprintf(result, RESULT_LEN, "channel idle-kick needs argument");
 	return ERROR;
       }
       chan->idle_kick = atoi(item[i]);
@@ -353,7 +353,7 @@ int channel_modify(char *result, struct chanset_t *chan, int items, char **item)
       i++;
       if (i >= items) {
         if (result)
-          simple_sprintf(result, "channel limit needs argument");
+          simple_snprintf(result, RESULT_LEN, "channel limit needs argument");
         return ERROR;
       }
       chan->limitraise = atoi(item[i]);
@@ -364,7 +364,7 @@ int channel_modify(char *result, struct chanset_t *chan, int items, char **item)
       i++;
       if (i >= items) {
 	if (result)
-	  simple_sprintf(result, "channel stopnethack-mode needs argument");
+	  simple_snprintf(result, RESULT_LEN, "channel stopnethack-mode needs argument");
 	return ERROR;
       }
       chan->stopnethack_mode = atoi(item[i]);
@@ -372,7 +372,7 @@ int channel_modify(char *result, struct chanset_t *chan, int items, char **item)
       i++;
       if (i >= items) {
         if (result)
-          simple_sprintf(result, "channel revenge-mode needs argument");
+          simple_snprintf(result, RESULT_LEN, "channel revenge-mode needs argument");
         return ERROR;
       }
       chan->revenge_mode = atoi(item[i]);
@@ -380,7 +380,7 @@ int channel_modify(char *result, struct chanset_t *chan, int items, char **item)
       i++;
       if (i >= items) {
         if (result)
-          simple_sprintf(result, "channel ban-time needs argument");
+          simple_snprintf(result, RESULT_LEN, "channel ban-time needs argument");
         return ERROR;
       }
       chan->ban_time = atoi(item[i]);
@@ -388,7 +388,7 @@ int channel_modify(char *result, struct chanset_t *chan, int items, char **item)
       i++;
       if (i >= items) {
         if (result)
-          simple_sprintf(result, "channel exempt-time needs argument");
+          simple_snprintf(result, RESULT_LEN, "channel exempt-time needs argument");
         return ERROR;
       }
       chan->exempt_time = atoi(item[i]);
@@ -396,7 +396,7 @@ int channel_modify(char *result, struct chanset_t *chan, int items, char **item)
       i++;
       if (i >= items) {
         if (result)
-          simple_sprintf(result, "channel invite-time needs argument");
+          simple_snprintf(result, RESULT_LEN, "channel invite-time needs argument");
         return ERROR;
       }
       chan->invite_time = atoi(item[i]);
@@ -404,7 +404,7 @@ int channel_modify(char *result, struct chanset_t *chan, int items, char **item)
       i++;
       if (i >= items) {
         if (result)
-          simple_sprintf(result, "channel closed-ban needs argument");
+          simple_snprintf(result, RESULT_LEN, "channel closed-ban needs argument");
         return ERROR;
       }
       chan->closed_ban = atoi(item[i]);
@@ -412,7 +412,7 @@ int channel_modify(char *result, struct chanset_t *chan, int items, char **item)
       i++;
       if (i >= items) {
         if (result)
-          simple_sprintf(result, "channel closed-invite needs argument");
+          simple_snprintf(result, RESULT_LEN, "channel closed-invite needs argument");
         return ERROR;
       }
       chan->closed_invite = atoi(item[i]);
@@ -420,7 +420,7 @@ int channel_modify(char *result, struct chanset_t *chan, int items, char **item)
       i++;
       if (i >= items) {
         if (result)
-          simple_sprintf(result, "channel closed-private needs argument");
+          simple_snprintf(result, RESULT_LEN, "channel closed-private needs argument");
         return ERROR;
       }
       chan->closed_private = atoi(item[i]);
@@ -428,7 +428,7 @@ int channel_modify(char *result, struct chanset_t *chan, int items, char **item)
       i++;
       if (i >= items) {
         if (result)
-          simple_sprintf(result, "channel voice-ident needs argument");
+          simple_snprintf(result, RESULT_LEN, "channel voice-ident needs argument");
         return ERROR;
       }
       chan->voice_non_ident = atoi(item[i]);
@@ -436,7 +436,7 @@ int channel_modify(char *result, struct chanset_t *chan, int items, char **item)
       i++;
       if (i >= items) {
         if (result)
-          simple_sprintf(result, "channel bad-cookie needs argument");
+          simple_snprintf(result, RESULT_LEN, "channel bad-cookie needs argument");
         return ERROR;
       }
       chan->bad_cookie = deflag_translate(item[i]);
@@ -444,7 +444,7 @@ int channel_modify(char *result, struct chanset_t *chan, int items, char **item)
       i++;
       if (i >= items) {
         if (result)
-          simple_sprintf(result, "channel manop needs argument");
+          simple_snprintf(result, RESULT_LEN, "channel manop needs argument");
         return ERROR;
       }
       chan->manop = deflag_translate(item[i]);
@@ -452,7 +452,7 @@ int channel_modify(char *result, struct chanset_t *chan, int items, char **item)
       i++;
       if (i >= items) {
         if (result)
-          simple_sprintf(result, "channel mdop needs argument");
+          simple_snprintf(result, RESULT_LEN, "channel mdop needs argument");
         return ERROR;
       }
       chan->mdop = deflag_translate(item[i]);
@@ -460,7 +460,7 @@ int channel_modify(char *result, struct chanset_t *chan, int items, char **item)
       i++;
       if (i >= items) {
         if (result)
-          simple_sprintf(result, "channel mop needs argument");
+          simple_snprintf(result, RESULT_LEN, "channel mop needs argument");
         return ERROR;
       }
       chan->mop = deflag_translate(item[i]);
@@ -469,7 +469,7 @@ int channel_modify(char *result, struct chanset_t *chan, int items, char **item)
  *    i++;
  *    if (i >= items) {
  *      if (result)
- *        simple_sprintf(result, "channel temp needs argument");
+ *        simple_snprintf(result, RESULT_LEN, "channel temp needs argument");
  *      return ERROR;
  *    }
  *    chan->temp = atoi(item[i]);
@@ -626,13 +626,13 @@ int channel_modify(char *result, struct chanset_t *chan, int items, char **item)
 	ptime = &chan->flood_nick_time;
       } else {
 	if (result)
-	  simple_sprintf(result, "illegal channel flood type: %s", item[i]);
+	  simple_snprintf(result, RESULT_LEN, "illegal channel flood type: %s", item[i]);
 	return ERROR;
       }
       i++;
       if (i >= items) {
 	if (result)
-	  simple_sprintf(result, "%s needs argument", item[i - 1]);
+	  simple_snprintf(result, RESULT_LEN, "%s needs argument", item[i - 1]);
 	return ERROR;
       }
       p = strchr(item[i], ':');
@@ -647,7 +647,8 @@ int channel_modify(char *result, struct chanset_t *chan, int items, char **item)
       }
     } else {
       if (result && item[i][0]) /* ignore "" */
-        simple_sprintf(result, "illegal channel option: %s", item[i]);
+        simple_snprintf(result, RESULT_LEN, "illegal channel option: ");
+        simple_snprintf(result_extra, sizeof(result_extra), "%s %s", result_extra[0] ? result_extra : "", item[i]);
       error = 1;
     }
   }
@@ -677,6 +678,9 @@ int channel_modify(char *result, struct chanset_t *chan, int items, char **item)
       recheck_channel_modes(chan);
     }
   }
+  if (result && result[0] && result_extra[0])
+    strcat(result, result_extra);
+
   if (error)
     return ERROR;
   return OK;
@@ -759,13 +763,13 @@ int channel_add(char *result, char *newname, char *options)
 {
   if (!newname || !newname[0] || !strchr(CHANMETA, newname[0])) {
     if (result)
-      simple_sprintf(result, "invalid channel prefix");
+      simple_snprintf(result, RESULT_LEN, "invalid channel prefix");
     return ERROR;
   }
 
   if (strchr(newname, ',') != NULL) {
     if (result)
-      simple_sprintf(result, "invalid channel name");
+      simple_snprintf(result, RESULT_LEN, "invalid channel name");
     return ERROR;
   }
 

+ 1 - 1
src/users.c

@@ -694,7 +694,7 @@ int readuserfile(const char *file, struct userrec **ret)
         } else if (!strcmp(code, "+")) {	/* add channel record */
          if (s[0] && lasthand[0] == '*' && lasthand[1] == CHANS_NAME[1]) {
            char *options = NULL, *chan = NULL, *my_ptr = NULL;
-           char resultbuf[2048] = "";
+           char resultbuf[RESULT_LEN] = "";
 
            options = my_ptr = strdup(s);