]> jfr.im git - irc/quakenet/newserv.git/commitdiff
Fix 2 crash bugs:
authorPaul <redacted>
Thu, 13 Oct 2005 19:42:00 +0000 (20:42 +0100)
committerPaul <redacted>
Thu, 13 Oct 2005 19:42:00 +0000 (20:42 +0100)
1. newsearch (Channel ) would crash
2. newsearch (Channel a b c d...) would overflow

newsearch/newsearch.c

index da72ebca0f6e94f07e0eb0915ef9fa0c2d80299a..1b7701c04e003ced3d10f78c9323e62880fbf0c3 100644 (file)
@@ -213,6 +213,10 @@ struct searchNode *search_parse(int type, char *input) {
        if (*ch==' ') {
          *ch='\0';
          j++;
+          if(j >= (sizeof(argvector) / sizeof(*argvector))) {
+            parseError = "Too many arguments";
+            return NULL;
+          }
          i=-1;
        }
       } else {
@@ -228,6 +232,9 @@ struct searchNode *search_parse(int type, char *input) {
       parseError = "Bracket mismatch!";
       return NULL;
     }
+
+    if (*(ch-1) == 0) /* if the last character was a space */
+      j--; /* remove an argument */
     
     if (!(cmd=findcommandintree(searchTree,argvector[0],1))) {
       parseError = "Unknown command";