From c6be0c9ec489dc325ede8d19ff11a14832904ddd Mon Sep 17 00:00:00 2001 From: Michael Ortmann <41313082+michaelortmann@users.noreply.github.com> Date: Sun, 12 Mar 2023 01:29:55 +0100 Subject: [PATCH 1/7] Fix maskname() buffer size --- src/flags.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/flags.c b/src/flags.c index e6266fe59..004fb0a44 100644 --- a/src/flags.c +++ b/src/flags.c @@ -203,8 +203,8 @@ char *masktype(int x) char *maskname(int x) { - static char s[275]; /* Change this if you change the levels */ - int i = 0; /* 6+8+7+13+6+6+6+17+5+7+8+7+9+15+17+17+24+24+(8*9)+1 */ + static char s[6+8+7+13+6+6+6+17+5+7+14+7+9+15+17+17+24+24+(8*9)+1]; /* Change this if you change the levels */ + int i = 0; s[0] = 0; if (x & LOG_MSGS) @@ -228,7 +228,7 @@ char *maskname(int x) if (x & LOG_FILES) i += my_strcpy(s + i, "files, "); /* 7 */ if (x & LOG_SERV) - i += my_strcpy(s + i, "server input, "); /* 8 */ + i += my_strcpy(s + i, "server input, "); /* 14 */ if (x & LOG_DEBUG) i += my_strcpy(s + i, "debug, "); /* 7 */ if (x & LOG_WALL) From fb9c9ed980f61fbae21c4db6224904a7b199ec90 Mon Sep 17 00:00:00 2001 From: Michael Ortmann <41313082+michaelortmann@users.noreply.github.com> Date: Sun, 12 Mar 2023 01:57:53 +0100 Subject: [PATCH 2/7] Cleanup --- src/flags.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/flags.c b/src/flags.c index 004fb0a44..5365eaa0f 100644 --- a/src/flags.c +++ b/src/flags.c @@ -206,7 +206,6 @@ char *maskname(int x) static char s[6+8+7+13+6+6+6+17+5+7+14+7+9+15+17+17+24+24+(8*9)+1]; /* Change this if you change the levels */ int i = 0; - s[0] = 0; if (x & LOG_MSGS) i += my_strcpy(s, "msgs, "); /* 6 */ if (x & LOG_PUBLIC) From 82911c1291dd0f8063e39bbafd5e936dad778384 Mon Sep 17 00:00:00 2001 From: Michael Ortmann Date: Sat, 7 Oct 2023 18:48:32 +0200 Subject: [PATCH 3/7] Cleanup --- src/flags.c | 84 ++++++++++++++++++----------------------------------- 1 file changed, 29 insertions(+), 55 deletions(-) diff --git a/src/flags.c b/src/flags.c index 5365eaa0f..c86627794 100644 --- a/src/flags.c +++ b/src/flags.c @@ -203,62 +203,36 @@ char *masktype(int x) char *maskname(int x) { - static char s[6+8+7+13+6+6+6+17+5+7+14+7+9+15+17+17+24+24+(8*9)+1]; /* Change this if you change the levels */ - int i = 0; + static char s[512]; + int i; - if (x & LOG_MSGS) - i += my_strcpy(s, "msgs, "); /* 6 */ - if (x & LOG_PUBLIC) - i += my_strcpy(s + i, "public, "); /* 8 */ - if (x & LOG_JOIN) - i += my_strcpy(s + i, "joins, "); /* 7 */ - if (x & LOG_MODES) - i += my_strcpy(s + i, "kicks/modes, "); /* 13 */ - if (x & LOG_CMDS) - i += my_strcpy(s + i, "cmds, "); /* 6 */ - if (x & LOG_MISC) - i += my_strcpy(s + i, "misc, "); /* 6 */ - if (x & LOG_BOTS) - i += my_strcpy(s + i, "bots, "); /* 6 */ - if (x & LOG_BOTMSG) - i += my_strcpy(s + i, "linked bot msgs, "); /* 17 */ - if ((x & LOG_RAW) && raw_log) - i += my_strcpy(s + i, "raw, "); /* 5 */ - if (x & LOG_FILES) - i += my_strcpy(s + i, "files, "); /* 7 */ - if (x & LOG_SERV) - i += my_strcpy(s + i, "server input, "); /* 14 */ - if (x & LOG_DEBUG) - i += my_strcpy(s + i, "debug, "); /* 7 */ - if (x & LOG_WALL) - i += my_strcpy(s + i, "wallops, "); /* 9 */ - if ((x & LOG_SRVOUT) && raw_log) - i += my_strcpy(s + i, "server output, "); /* 15 */ - if ((x & LOG_BOTNETIN) && raw_log) - i += my_strcpy(s + i, "botnet incoming, "); /* 17 */ - if ((x & LOG_BOTNETOUT) && raw_log) - i += my_strcpy(s + i, "botnet outgoing, "); /* 17 */ - if ((x & LOG_BOTSHRIN) && raw_log) - i += my_strcpy(s + i, "incoming share traffic, "); /* 24 */ - if ((x & LOG_BOTSHROUT) && raw_log) - i += my_strcpy(s + i, "outgoing share traffic, "); /* 24 */ - if (x & LOG_LEV1) - i += my_strcpy(s + i, "level 1, "); /* 9 */ - if (x & LOG_LEV2) - i += my_strcpy(s + i, "level 2, "); /* 9 */ - if (x & LOG_LEV3) - i += my_strcpy(s + i, "level 3, "); /* 9 */ - if (x & LOG_LEV4) - i += my_strcpy(s + i, "level 4, "); /* 9 */ - if (x & LOG_LEV5) - i += my_strcpy(s + i, "level 5, "); /* 9 */ - if (x & LOG_LEV6) - i += my_strcpy(s + i, "level 6, "); /* 9 */ - if (x & LOG_LEV7) - i += my_strcpy(s + i, "level 7, "); /* 9 */ - if (x & LOG_LEV8) - i += my_strcpy(s + i, "level 8, "); /* 9 */ - if (i) + if ((i = snprintf(s, sizeof s, "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s", + (x & LOG_MSGS) ? "msgs, " : "", + (x & LOG_PUBLIC) ? "public, " : "", + (x & LOG_JOIN) ? "joins, " : "", + (x & LOG_MODES) ? "kicks/modes, " : "", + (x & LOG_CMDS) ? "cmds, " : "", + (x & LOG_MISC) ? "misc, " : "", + (x & LOG_BOTS) ? "bots, " : "", + (x & LOG_BOTMSG) ? "linked bot msgs, " : "", + ((x & LOG_RAW) && raw_log) ? "raw, " : "", + (x & LOG_FILES) ? "files, " : "", + (x & LOG_SERV) ? "server input, " : "", + (x & LOG_DEBUG) ? "debug, " : "", + (x & LOG_WALL) ? "wallops, " : "", + ((x & LOG_SRVOUT) && raw_log) ? "server output, " : "", + ((x & LOG_BOTNETIN) && raw_log) ? "botnet incoming, " : "", + ((x & LOG_BOTNETOUT) && raw_log) ? "botnet outgoing, " : "", + ((x & LOG_BOTSHRIN) && raw_log) ? "incoming share traffic, " : "", + ((x & LOG_BOTSHROUT) && raw_log) ? "outgoing share traffic, " : "", + (x & LOG_LEV1) ? "level 1, " : "", + (x & LOG_LEV2) ? "level 2, " : "", + (x & LOG_LEV3) ? "level 3, " : "", + (x & LOG_LEV4) ? "level 4, " : "", + (x & LOG_LEV5) ? "level 5, " : "", + (x & LOG_LEV6) ? "level 6, " : "", + (x & LOG_LEV7) ? "level 7, " : "", + (x & LOG_LEV8) ? "level 8, " : ""))) s[i - 2] = 0; else strcpy(s, "none"); From 39e469443ee88264d31e931bbf76dccf40f82b01 Mon Sep 17 00:00:00 2001 From: Michael Ortmann Date: Sat, 7 Oct 2023 19:52:15 +0200 Subject: [PATCH 4/7] clanup this one also --- src/cmds.c | 35 +++++++++++++---------------------- 1 file changed, 13 insertions(+), 22 deletions(-) diff --git a/src/cmds.c b/src/cmds.c index 44ccf76b6..47923b2ef 100644 --- a/src/cmds.c +++ b/src/cmds.c @@ -2605,30 +2605,21 @@ char *stripmasktype(int x) static char *stripmaskname(int x) { - static char s[161]; - int i = 0; + static char s[128]; + int i; - s[i] = 0; - if (x & STRIP_COLOR) - i += my_strcpy(s + i, "color, "); - if (x & STRIP_BOLD) - i += my_strcpy(s + i, "bold, "); - if (x & STRIP_REVERSE) - i += my_strcpy(s + i, "reverse, "); - if (x & STRIP_UNDERLINE) - i += my_strcpy(s + i, "underline, "); - if (x & STRIP_ANSI) - i += my_strcpy(s + i, "ansi, "); - if (x & STRIP_BELLS) - i += my_strcpy(s + i, "bells, "); - if (x & STRIP_ORDINARY) - i += my_strcpy(s + i, "ordinary, "); - if (x & STRIP_ITALICS) - i += my_strcpy(s + i, "italics, "); - if (!i) - strcpy(s, "none"); - else + if ((i = snprintf(s, sizeof s, "%s%s%s%s%s%s%s%s", + (x & STRIP_COLOR) ? "color, " : "", + (x & STRIP_BOLD) ? "bold, " : "", + (x & STRIP_REVERSE) ? "reverse, " : "", + (x & STRIP_UNDERLINE) ? "underline, " : "", + (x & STRIP_ANSI) ? "ansi, " : "", + (x & STRIP_BELLS) ? "bells, " : "", + (x & STRIP_ORDINARY) ? "ordinary, " : "", + (x & STRIP_ITALICS) ? "italics, " : ""))) s[i - 2] = 0; + else + strcpy(s, "none"); return s; } From 9999ad3d4389f5c6f0b9e4951867fcee42d023c2 Mon Sep 17 00:00:00 2001 From: Michael Ortmann Date: Sat, 7 Oct 2023 20:25:06 +0200 Subject: [PATCH 5/7] Fix status reporting for channel setting revengebot and whitespace at end of line --- src/mod/channels.mod/channels.c | 83 +++++++++++---------------------- 1 file changed, 28 insertions(+), 55 deletions(-) diff --git a/src/mod/channels.mod/channels.c b/src/mod/channels.mod/channels.c index a2975ad09..dc202dc22 100644 --- a/src/mod/channels.mod/channels.c +++ b/src/mod/channels.mod/channels.c @@ -620,61 +620,34 @@ static void channels_report(int idx, int details) dprintf(idx, "%s\n", s); if (details) { - s[0] = 0; - i = 0; - - if (channel_enforcebans(chan)) - i += my_strcpy(s + i, "enforcebans "); - if (channel_dynamicbans(chan)) - i += my_strcpy(s + i, "dynamicbans "); - if (!channel_nouserbans(chan)) - i += my_strcpy(s + i, "userbans "); - if (channel_autoop(chan)) - i += my_strcpy(s + i, "autoop "); - if (channel_bitch(chan)) - i += my_strcpy(s + i, "bitch "); - if (channel_greet(chan)) - i += my_strcpy(s + i, "greet "); - if (channel_protectops(chan)) - i += my_strcpy(s + i, "protectops "); - if (channel_protecthalfops(chan)) - i += my_strcpy(s + i, "protecthalfops "); - if (channel_protectfriends(chan)) - i += my_strcpy(s + i, "protectfriends "); - if (channel_dontkickops(chan)) - i += my_strcpy(s + i, "dontkickops "); - if (channel_logstatus(chan)) - i += my_strcpy(s + i, "statuslog "); - if (channel_revenge(chan)) - i += my_strcpy(s + i, "revenge "); - if (channel_revenge(chan)) - i += my_strcpy(s + i, "revengebot "); - if (channel_secret(chan)) - i += my_strcpy(s + i, "secret "); - if (channel_shared(chan)) - i += my_strcpy(s + i, "shared "); - if (!channel_static(chan)) - i += my_strcpy(s + i, "dynamic "); - if (channel_autovoice(chan)) - i += my_strcpy(s + i, "autovoice "); - if (channel_autohalfop(chan)) - i += my_strcpy(s + i, "autohalfop "); - if (channel_cycle(chan)) - i += my_strcpy(s + i, "cycle "); - if (channel_seen(chan)) - i += my_strcpy(s + i, "seen "); - if (channel_dynamicexempts(chan)) - i += my_strcpy(s + i, "dynamicexempts "); - if (!channel_nouserexempts(chan)) - i += my_strcpy(s + i, "userexempts "); - if (channel_dynamicinvites(chan)) - i += my_strcpy(s + i, "dynamicinvites "); - if (!channel_nouserinvites(chan)) - i += my_strcpy(s + i, "userinvites "); - if (channel_inactive(chan)) - i += my_strcpy(s + i, "inactive "); - if (channel_nodesynch(chan)) - my_strcpy(s + i, "nodesynch "); + if ((i = snprintf(s, sizeof s, "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s", + channel_enforcebans(chan) ? "enforcebans " : "", + channel_dynamicbans(chan) ? "dynamicbans " : "", + !channel_nouserbans(chan) ? "userbans " : "", + channel_autoop(chan) ? "autoop " : "", + channel_bitch(chan) ? "bitch " : "", + channel_greet(chan) ? "greet " : "", + channel_protectops(chan) ? "protectops " : "", + channel_protecthalfops(chan) ? "protecthalfops " : "", + channel_protectfriends(chan) ? "protectfriends " : "", + channel_dontkickops(chan) ? "dontkickops " : "", + channel_logstatus(chan) ? "statuslog " : "", + channel_revenge(chan) ? "revenge " : "", + channel_revengebot(chan) ? "revengebot " : "", + channel_secret(chan) ? "secret " : "", + channel_shared(chan) ? "shared " : "", + !channel_static(chan) ? "dynamic " : "", + channel_autovoice(chan) ? "autovoice " : "", + channel_autohalfop(chan) ? "autohalfop " : "", + channel_cycle(chan) ? "cycle " : "", + channel_seen(chan) ? "seen " : "", + channel_dynamicexempts(chan) ? "dynamicexempts " : "", + !channel_nouserexempts(chan) ? "userexempts " : "", + channel_dynamicinvites(chan) ? "dynamicinvites " : "", + !channel_nouserinvites(chan) ? "userinvites " : "", + channel_inactive(chan) ? "inactive " : "", + channel_nodesynch(chan) ? "nodesynch " : ""))) + s[i - 2] = 0; dprintf(idx, " Options: %s\n", s); From 55118b05d6002100765e713e935a9a4693dda2e7 Mon Sep 17 00:00:00 2001 From: Michael Ortmann Date: Sat, 7 Oct 2023 20:29:54 +0200 Subject: [PATCH 6/7] Increase channel mod version --- src/mod/channels.mod/channels.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mod/channels.mod/channels.c b/src/mod/channels.mod/channels.c index dc202dc22..a9ba9d6d1 100644 --- a/src/mod/channels.mod/channels.c +++ b/src/mod/channels.mod/channels.c @@ -989,7 +989,7 @@ char *channels_start(Function *global_funcs) "-autohalfop " "-nodesynch " "-static "); - module_register(MODULE_NAME, channels_table, 1, 2); + module_register(MODULE_NAME, channels_table, 1, 3); if (!module_depend(MODULE_NAME, "eggdrop", 108, 0)) { module_undepend(MODULE_NAME); return "This module requires Eggdrop 1.8.0 or later."; From 403f89f75cffd47641d6969f9e53e42ccc4e6e9a Mon Sep 17 00:00:00 2001 From: Michael Ortmann Date: Tue, 10 Oct 2023 00:36:13 +0200 Subject: [PATCH 7/7] Revert mod version bump --- src/mod/channels.mod/channels.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mod/channels.mod/channels.c b/src/mod/channels.mod/channels.c index a9ba9d6d1..dc202dc22 100644 --- a/src/mod/channels.mod/channels.c +++ b/src/mod/channels.mod/channels.c @@ -989,7 +989,7 @@ char *channels_start(Function *global_funcs) "-autohalfop " "-nodesynch " "-static "); - module_register(MODULE_NAME, channels_table, 1, 3); + module_register(MODULE_NAME, channels_table, 1, 2); if (!module_depend(MODULE_NAME, "eggdrop", 108, 0)) { module_undepend(MODULE_NAME); return "This module requires Eggdrop 1.8.0 or later.";