bug fixes (from code coverage tests)
authorEntrope <entrope@clan-dk.org>
Mon, 8 Mar 2004 17:41:48 +0000 (17:41 +0000)
committerEntrope <entrope@clan-dk.org>
Mon, 8 Mar 2004 17:41:48 +0000 (17:41 +0000)
* Fix typo in CSMSG_ADDED_USER message.

* Fix memory leak in !bans when no bans are shown.

* Fix SAY, EMOTE to user targets.

* Require unsuspended channel for OPCHAN (i.e. ChanServ is in-channel).

* Fix typo in TOPICSNARF help description.

* Fix mod_chanmode argc when reopping services.

* Fix memory leak when rehashing with with an uplink bind address.

* Fix typo in OSMSG_NICK_UNRESERVED message.

* Make *OpServ.op actually op non-ops, instead of just ops.

* Fix kick message translations when shutting down a channel.

* Fix use-after-free if an oper does ?part #badchan.

* Make mod_chanmode_apply() more sensitive to invalid mode changes.

* In create_helper(), let AddChannelUser() decide whether to op the user.

* Remove "Mod" and "Game" from "set_shows" in srvx.conf.example.

* Do not print the status "." in tests when full debug mode is on.
git-archimport-id: srvx@srvx.net--2004-srvx/srvx--devo--1.3--patch-24

src/chanserv.c
src/chanserv.help
src/hash.c
src/helpfile.c
src/main.c
src/opserv.c
src/proto-common.c
src/proto-p10.c
srvx.conf.example
tests/test-driver.pl

index dcdb6316dfc414c3e767a66123013bba64d75df2..7b3f372301783199a4b4e9f063185eadfe5091d1 100644 (file)
@@ -180,7 +180,7 @@ static const struct message_entry msgtab[] = {
     { "CSMSG_DELETED_YOU", "Your $b%d$b access has been deleted from $b%s$b." },
 
 /* User management */
-    { "CSMSG_ADDED_USER", "Added new %s to the %s user list with access %d." },
+    { "CSMSG_ADDED_USER", "Added %s to the %s user list with access %d." },
     { "CSMSG_DELETED_USER", "Deleted %s (with access %d) from the %s user list." },
     { "CSMSG_BAD_RANGE", "Invalid access range; minimum (%d) must be greater than maximum (%d)." },
     { "CSMSG_DELETED_USERS", "Deleted accounts matching $b%s$b with access from $b%d$b to $b%d$b from the %s user list." },
@@ -3541,6 +3541,8 @@ static CHANSERV_FUNC(cmd_bans)
     {
         table_send(cmd->parent->bot, user->nick, 0, NULL, tbl);
        reply("MSG_NONE");
+        free(tbl.contents[0]);
+        free(tbl.contents);
        return 0;
     }
 
@@ -4318,7 +4320,7 @@ static CHANSERV_FUNC(cmd_say)
     {
         REQUIRE_PARAMS(3);
         msg = unsplit_string(argv + 2, argc - 2, NULL);
-        send_target_message(1, argv[1], cmd->parent->bot, "%s", msg);
+        send_target_message(5, argv[1], cmd->parent->bot, "%s", msg);
     }
     else
     {
@@ -4341,7 +4343,7 @@ static CHANSERV_FUNC(cmd_emote)
     else if(GetUserH(argv[1]))
     {
         msg = unsplit_string(argv + 2, argc - 2, NULL);
-        send_target_message(1, argv[1], cmd->parent->bot, "\001ACTION %s\001", msg);
+        send_target_message(5, argv[1], cmd->parent->bot, "\001ACTION %s\001", msg);
     }
     else
     {
@@ -5766,8 +5768,10 @@ handle_join(struct modeNode *mNode)
             if(bData != cData->bans)
             {
                 /* Shuffle the ban to the head of the list. */
-                if(bData->next) bData->next->prev = bData->prev;
-                if(bData->prev) bData->prev->next = bData->next;
+                if(bData->next)
+                    bData->next->prev = bData->prev;
+                if(bData->prev)
+                    bData->prev->next = bData->next;
 
                 bData->prev = NULL;
                 bData->next = cData->bans;
@@ -7045,7 +7049,7 @@ init_chanserv(const char *nick)
     DEFINE_COMMAND(mdelpeon, 2, MODCMD_REQUIRE_CHANUSER, "access", "master", NULL);
 
     DEFINE_COMMAND(trim, 3, MODCMD_REQUIRE_CHANUSER, "access", "master", NULL);
-    DEFINE_COMMAND(opchan, 1, MODCMD_REQUIRE_REGCHAN, "access", "1", NULL);
+    DEFINE_COMMAND(opchan, 1, MODCMD_REQUIRE_REGCHAN|MODCMD_NEVER_CSUSPEND, "access", "1", NULL);
     DEFINE_COMMAND(clvl, 3, MODCMD_REQUIRE_CHANUSER, "access", "master", NULL);
     DEFINE_COMMAND(giveownership, 2, MODCMD_REQUIRE_CHANUSER, "access", "owner", "flags", "+loghostmask", NULL);
 
index 574f39da408db0316f1510ae5806f51af1fbccb2..e2b636ba6fe846450fadd4ccfb2be81e8eab7262 100644 (file)
         "ENFOPS:       Restrictions for opping users.",
         "ENFMODES:     Restrictions to change the default modes.",
         "ENFTOPIC:     Restrictions on changing the topic.",
-        "TOPICSNARF:   Topics set manually (by /TOPIC #channel ...) by users this level and bove change the default $b$C$b topic.",
+        "TOPICSNARF:   Topics set manually (by /TOPIC #channel ...) by users this level and above change the default $b$C$b topic.",
         "SETTERS:      Who may change channel settings (using $bSET$b).",
         "CTCPUSERS:    Who is allowed to send CTCPs to the channel.",
         "CTCPREACTION: What happens when a disallowed CTCP is sent to the channel.",
index 92067ed4132060b020251461e39eba15963e2de5..168a31730ec6e8d9bf56a0e11ec90b5a89cb1adb 100644 (file)
@@ -302,14 +302,14 @@ wipeout_channel(struct chanNode *cNode, time_t new_time, char **modes, unsigned
     /* deop anybody in the channel now, but count services to reop */
     for (nn=argc=0; nn<cNode->members.used; nn++) {
         struct modeNode *mn = cNode->members.list[nn];
-        if (mn->modes & MODE_CHANOP && IsService(mn->user) && IsLocal(mn->user))
+        if ((mn->modes & MODE_CHANOP) && IsService(mn->user) && IsLocal(mn->user))
             argc++;
     }
     if (argc) {
         extern struct userNode *opserv;
         struct mod_chanmode *change;
 
-        change = mod_chanmode_alloc(nn);
+        change = mod_chanmode_alloc(argc);
         change->modes_clear = 0;
         change->modes_set = orig_modes;
         change->new_limit = orig_limit;
@@ -322,6 +322,7 @@ wipeout_channel(struct chanNode *cNode, time_t new_time, char **modes, unsigned
                 argc++;
             }
         }
+        assert(argc == change->argc);
         if (change->argc > 0)
             mod_chanmode_announce(change->args[0].member->user, cNode, change);
         else
index de0b06bb210222f7c8015834cf1355646a5d7dc3..48f187f0f0152d80f950718c4dc06e8782571b7b 100644 (file)
@@ -535,7 +535,8 @@ vsend_message(const char *dest, struct userNode *src, struct handle_info *handle
                     switch (exp.type) {
                     case HF_STRING:
                         free_value = value = exp.value.str;
-                        if (!value) value = "";
+                        if (!value)
+                            value = "";
                         break;
                     case HF_TABLE:
                         /* Must send current line, then emit table. */
index 38b95be5105c8eff505b1bc66381014287c988bf..e778f75f839bba854904100d98a327523f052710 100644 (file)
@@ -161,14 +161,9 @@ uplink_insert(const char *key, void *data, UNUSED_ARG(void *extra))
     uplink->bind_addr_len = sizeof(*sin);
     if (str && getipbyname(str, &addr)) 
     {
-       sin = malloc(uplink->bind_addr_len);
-        sin->sin_port = 0;
+       sin = calloc(1, uplink->bind_addr_len);
        sin->sin_family = AF_INET;
        sin->sin_addr.s_addr = addr;
-#ifdef HAVE_SIN_LEN
-       sin->sin_len = 0;
-#endif
-       memset(sin->sin_zero, 0, sizeof(sin->sin_zero));
        uplink->bind_addr = sin;
     } 
     else 
@@ -235,6 +230,7 @@ uplink_compile(void)
        for(uplink = oldUplinks; uplink; uplink = next)
        {
            next = uplink->next;
+            free(uplink->bind_addr);
            free(uplink);
        }
     }
@@ -614,7 +610,7 @@ void main_shutdown(void)
     ioset_cleanup();
     for (ul = cManager.uplinks; ul; ul = ul_next) {
         ul_next = ul->next;
-        if (ul->bind_addr) free(ul->bind_addr);
+        free(ul->bind_addr);
         free(ul);
     }
     tools_cleanup();
index 22f6d8697049cd96113107691ce29a7a2a6e0528..fca715be2e54cd0d3dc8303598abcf1522c0c1fa 100644 (file)
@@ -160,7 +160,7 @@ static const struct message_entry msgtab[] = {
     { "OSMSG_RAW_PARSE_ERROR", "Error parsing raw line (not dumping to uplink)." },
     { "OSMSG_COLLIDED_NICK", "Now temporarily holding nick $b%s$b." },
     { "OSMSG_RESERVED_NICK", "Now reserving nick $b%s$b." },
-    { "OSMSG_NICK_UNRESERVED", "Nick $b%s$b is no longer reserve." },
+    { "OSMSG_NICK_UNRESERVED", "Nick $b%s$b is no longer reserved." },
     { "OSMSG_NOT_RESERVED", "Nick $b%s$b is not reserved." },
     { "OSMSG_ILLEGAL_REASON", "This channel is illegal." },
     { "OSMSG_ILLEGAL_KILL_REASON", "Joined an illegal modeless channel - do not repeat." },
@@ -1111,7 +1111,7 @@ static MODCMD_FUNC(cmd_op)
             continue;
         if (!(mn =  GetUserMode(channel, victim)))
             continue;
-        if (!(mn->modes & MODE_CHANOP))
+        if (mn->modes & MODE_CHANOP)
             continue;
         change->args[count].mode = MODE_CHANOP;
         change->args[count++].member = mn;
@@ -1803,7 +1803,7 @@ opserv_shutdown_channel(struct chanNode *channel, const char *reason)
         struct modeNode *mNode = channel->members.list[--nn];
         if (IsService(mNode->user))
             continue;
-        KickChannelUser(mNode->user, channel, opserv, reason);
+        KickChannelUser(mNode->user, channel, opserv, user_find_message(mNode->user, reason));
     }
     timeq_add(now + opserv_conf.purge_lock_delay, opserv_part_channel, channel);
 }
@@ -1827,6 +1827,12 @@ opserv_channel_check(struct chanNode *newchan)
     newchan->bad_channel = opserv_bad_channel(newchan->name);
 }
 
+static void
+opserv_channel_delete(struct chanNode *chan)
+{
+    timeq_del(0, opserv_part_channel, chan, TIMEQ_IGNORE_WHEN);
+}
+
 static int
 opserv_join_check(struct modeNode *mNode)
 {
@@ -1844,7 +1850,7 @@ opserv_join_check(struct modeNode *mNode)
         if (channel->name[0] != '#')
             DelUser(user, opserv, 1, "OSMSG_ILLEGAL_KILL_REASON");
         else if (!GetUserMode(channel, opserv))
-            opserv_shutdown_channel(channel, user_find_message(user, "OSMSG_ILLEGAL_REASON"));
+            opserv_shutdown_channel(channel, "OSMSG_ILLEGAL_REASON");
         else {
             send_message(user, opserv, "OSMSG_ILLEGAL_CHANNEL", channel->name);
             msg = user_find_message(user, "OSMSG_ILLEGAL_REASON");
@@ -4113,6 +4119,7 @@ init_opserv(const char *nick)
     reg_nick_change_func(opserv_alert_check_nick);
     reg_del_user_func(opserv_user_cleanup);
     reg_new_channel_func(opserv_channel_check);
+    reg_del_channel_func(opserv_channel_delete);
     reg_join_func(opserv_join_check);
     reg_auth_func(opserv_staff_alert);
 
index d5ebc8ac4a55e42409efec447cd77da134b6aa6c..93751e39d59ef7caa1e823f9dc793483e038c35f 100644 (file)
@@ -578,13 +578,20 @@ mod_chanmode_apply(struct userNode *who, struct chanNode *channel, struct mod_ch
                 break;
             }
             break;
-        default:
-            assert((change->args[ii].mode & (MODE_REMOVE|MODE_CHANOP|MODE_VOICE)) != 0);
+        case MODE_CHANOP:
+        case MODE_VOICE:
+        case MODE_VOICE|MODE_CHANOP:
+        case MODE_REMOVE|MODE_CHANOP:
+        case MODE_REMOVE|MODE_VOICE:
+        case MODE_REMOVE|MODE_VOICE|MODE_CHANOP:
             if (change->args[ii].mode & MODE_REMOVE)
                 change->args[ii].member->modes &= ~change->args[ii].mode;
             else
                 change->args[ii].member->modes |= change->args[ii].mode;
             break;
+        default:
+            assert(0 && "Invalid mode argument");
+            continue;
         }
     }
 }
index b96e115f816e84cfa01fdf5db7adb433bd82b531..7717c8d3d7e8dd1c3ecbb7ab3c2f74e646e42559 100644 (file)
@@ -875,20 +875,14 @@ static void
 create_helper(char *name, void *data)
 {
     struct create_desc *cd = data;
-    /* We can't assume the channel create was allowed because of the
-     * bad-word channel checking.
-     */
-    struct chanNode *cn;
-    struct modeNode *mn;
+
     if (!strcmp(name, "0")) {
         while (cd->user->channels.used > 0)
             DelChannelUser(cd->user, cd->user->channels.list[0]->channel, 0, 0);
         return;
     }
-    cn = AddChannel(name, cd->when, NULL, NULL);
-    mn = AddChannelUser(cd->user, cn);
-    if (mn && (cn->members.used == 1))
-        mn->modes = MODE_CHANOP;
+
+    AddChannelUser(cd->user, AddChannel(name, cd->when, NULL, NULL));
 }
 
 static CMD_FUNC(cmd_create)
index 5c999030b8bdc5ce18471eea9feca57e3c94dfbc..8b76a07e96738a750f4daaf1c173f58881ccc15c 100644 (file)
         // character to make ChanServ pay attention to you
         "trigger" "!";
         // what !set options should we show when user calls "!set" with no arguments?
-        "set_shows" ("DefaultTopic", "TopicMask", "Greeting", "UserGreeting", "Modes", "PubCmd", "StrictOp", "AutoOp", "EnfModes", "EnfTopic", "Protect", "Toys", "Setters", "TopicRefresh", "CtcpUsers", "CtcpReaction", "Mod", "Game",
+        "set_shows" ("DefaultTopic", "TopicMask", "Greeting", "UserGreeting", "Modes", "PubCmd", "StrictOp", "AutoOp", "EnfModes", "EnfTopic", "Protect", "Toys", "Setters", "TopicRefresh", "CtcpUsers", "CtcpReaction",
                 "Voice", "UserInfo", "DynLimit", "TopicSnarf", "NoDelete");
 
         // A list of !8ball responses
index 161f2611177bf801bc8bf442effcf86c5e25fd48..16c09bbf487edfcecd9d357d3e9b62a3c4fd6cc9 100755 (executable)
@@ -136,7 +136,7 @@ sub drv_heartbeat {
       $line = delete $heap->{line};
     } elsif (defined($line = <$script>)) {
       $heap->{lineno} = $.;
-      print ".";
+      print "." unless $heap->{irc_debug};
     } else {
       # close all connections
       foreach my $client (values %{$heap->{clients}}) {