]> jfr.im git - irc/quakenet/newserv.git/blobdiff - helpmod2/hcommands.c
GLINES: fix null pointer deref in trustgline / trustungline
[irc/quakenet/newserv.git] / helpmod2 / hcommands.c
index 0204e853ee01976804b76c72331926b1f6009286..f5b879f87dd6f44f8e54bfedb5b2f5a9237b7a2c 100644 (file)
@@ -773,25 +773,26 @@ static void helpmod_cmd_welcome (huser *sender, channel* returntype, char* ostr,
     }
 }
 
+static void helpmod_list_aliases(huser *sender, channel *returntype, char *buf, int *p_i, alias_tree node)
+{
+    if (*p_i > 256)
+    {
+        helpmod_reply(sender, returntype, "%s", buf);
+        *p_i = 0;
+    }
+    if (!node)
+        return;
+    sprintf(buf+*p_i,"%.200s ",node->name->content);
+    *p_i+=(1+strlen(node->name->content));
+    helpmod_list_aliases(sender, returntype, buf, p_i, node->left);
+    helpmod_list_aliases(sender, returntype, buf, p_i, node->right);
+}
+
 static void helpmod_cmd_aliases (huser *sender, channel* returntype, char* ostr, int argc, char *argv[])
 {
     char buf[512];
     int i = 0;
-    void helpmod_list_aliases(alias_tree node)
-    {
-       if (i > 256)
-       {
-           helpmod_reply(sender, returntype, "%s", buf);
-           i = 0;
-       }
-       if (!node)
-           return;
-        sprintf(buf+i,"%.200s ",node->name->content);
-       i+=(1+strlen(node->name->content));
-        helpmod_list_aliases(node->left);
-       helpmod_list_aliases(node->right);
-    }
-    helpmod_list_aliases(aliases);
+    helpmod_list_aliases(sender, returntype, buf, &i, aliases);
     if (i)
        helpmod_reply(sender, returntype, "%s", buf);
 }
@@ -1081,7 +1082,7 @@ void helpmod_cmd_term (huser *sender, channel* returntype, char* ostr, int argc,
             char *name = argv[1], *description;
             SKIP_WORD; SKIP_WORD;
             description = ostr;
-            htrm = hterm_add(source, name, description);
+            hterm_add(source, name, description);
             helpmod_reply(sender, returntype, "Term %s added succesfully", name);
         }
     }
@@ -1888,7 +1889,6 @@ static void helpmod_cmd_stats (huser *sender, channel* returntype, char* ostr, i
 static void helpmod_cmd_chanstats (huser *sender, channel* returntype, char* ostr, int argc, char *argv[])
 {
     hchannel *hchan;
-    hstat_channel *channel_stats;
     hstat_channel_entry *stat_entry;
 
     time_t timer = time(NULL);
@@ -1952,8 +1952,6 @@ static void helpmod_cmd_chanstats (huser *sender, channel* returntype, char* ost
             }
         }
 
-    channel_stats = hchan->stats;
-
     if (!days && !weeks)
         return;
 
@@ -2388,7 +2386,7 @@ static void helpmod_cmd_ticket (huser *sender, channel* returntype, char* ostr,
         helpmod_reply(sender, returntype, "Cannot issue a ticket: User %s is considered improper and not worthy of a ticket", argv[1]);
         return;
     }
-    if (huser_get_level(husr) > H_PEON)
+    if (huser_get_level(husr) > H_FRIEND)
     {
         helpmod_reply(sender, returntype, "Cannot issue a ticket: User %s does not require a ticket", argv[1]);
         return;
@@ -2684,7 +2682,6 @@ static void helpmod_cmd_checkchannel(huser *sender, channel* returntype, char* o
     /* third pass - find status boundaries */
     {
        for (;o_limit < nick_count && numeric_array[o_limit] & CUMODE_OP; o_limit++);
-        v_limit = o_limit;
        for(v_limit = o_limit; (v_limit < nick_count) && numeric_array[v_limit] & CUMODE_VOICE; v_limit++);
     }
 
@@ -3180,7 +3177,7 @@ static void helpmod_cmd_text (huser *sender, channel* returntype, char* ostr, in
        DIR *dir;
        struct dirent *dent;
        char buffer[384], **lines, *start;
-        int nwritten, bufpos = 0, nlines = 0,i;
+        int bufpos = 0, nlines = 0,i;
 
        dir = opendir(HELPMOD_TEXT_DIR);
        assert(dir != NULL);
@@ -3231,8 +3228,7 @@ static void helpmod_cmd_text (huser *sender, channel* returntype, char* ostr, in
                buffer[bufpos] = ' ';
                bufpos++;
            }
-           sprintf(buffer + bufpos, "%s%n", lines[i], &nwritten);
-           bufpos+=nwritten;
+           bufpos+=sprintf(buffer + bufpos, "%s", lines[i]);
 
            if (bufpos > (384 - (HED_FILENAME_LENGTH+1)))
            {
@@ -3305,6 +3301,7 @@ static void helpmod_cmd_text (huser *sender, channel* returntype, char* ostr, in
        if ((in = fopen(fname_buffer, "rt")) != NULL)
        {
            helpmod_reply(sender, returntype, "Can not add text: Text %s already exists", argv[1]);
+            fclose(in);
             return;
        }
        else
@@ -3746,10 +3743,11 @@ void hcommands_add(void)
     hcommand_add("devoice", H_TRIAL, helpmod_cmd_devoice, "Sets mode -v on channels");
 
     hcommand_add("invite", H_PEON, helpmod_cmd_invite, "Invites you to a channel");
+    /* disabled ticketing - meeb 2017-03-22
     hcommand_add("ticket", H_TRIAL, helpmod_cmd_ticket, "Gives a ticket to be used with invite");
     hcommand_add("resolve", H_STAFF, helpmod_cmd_resolve, "Resolves (deletes) a ticket");
     hcommand_add("tickets", H_STAFF, helpmod_cmd_tickets, "Lists all valid tickets for a channel");
-    hcommand_add("showticket", H_STAFF, helpmod_cmd_showticket, "Shows the ticket for the user");
+    hcommand_add("showticket", H_STAFF, helpmod_cmd_showticket, "Shows the ticket for the user"); */
 
     hcommand_add("termstats", H_OPER, helpmod_cmd_termstats, "Lists usage statistics for terms");
     hcommand_add("checkchannel", H_STAFF, helpmod_cmd_checkchannel, "Shows channel information for any channel");