Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crashfix: maskname() buffer size #1435

Merged
merged 7 commits into from
Oct 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 13 additions & 22 deletions src/cmds.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
85 changes: 29 additions & 56 deletions src/flags.c
Original file line number Diff line number Diff line change
Expand Up @@ -203,63 +203,36 @@ 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[512];
int i;

s[0] = 0;
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, "); /* 8 */
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");
Expand Down
83 changes: 28 additions & 55 deletions src/mod/channels.mod/channels.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down