Skip to content

Commit dd9873d

Browse files
snprintf updates
Found by: michaelortmann Patch by: michaelortmann
1 parent b7e0944 commit dd9873d

1 file changed

Lines changed: 29 additions & 29 deletions

File tree

src/botnet.c

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ void answer_local_whom(int idx, int chan)
439439
dprintf(idx, "%s (+: %s, *: %s)\n", BOT_BOTNETUSERS, BOT_PARTYLINE,
440440
BOT_LOCALCHAN);
441441
else if (chan > 0) {
442-
simple_sprintf(idle, "assoc %d", chan);
442+
snprintf(idle, sizeof idle, "assoc %d", chan);
443443
if ((Tcl_Eval(interp, idle) != TCL_OK) || tcl_resultempty())
444444
dprintf(idx, "%s %s%d:\n", BOT_USERSONCHAN,
445445
(chan < GLOBAL_CHANS) ? "" : "*", chan % GLOBAL_CHANS);
@@ -774,8 +774,8 @@ void dump_links(int z)
774774
p = bot->uplink->bot;
775775
#ifndef NO_OLD_BOTNET
776776
if (b_numver(z) < NEAT_BOTNET)
777-
l = simple_sprintf(x, "nlinked %s %s %c%d\n", bot->bot,
778-
p, bot->share, bot->ver);
777+
l = snprintf(x, sizeof x, "nlinked %s %s %c%d\n", bot->bot,
778+
p, bot->share, bot->ver);
779779
else
780780
#endif
781781
l = simple_sprintf(x, "n %s %s %c%D\n", bot->bot, p,
@@ -790,10 +790,10 @@ void dump_links(int z)
790790
(dcc[i].u.chat->channel < GLOBAL_CHANS)) {
791791
#ifndef NO_OLD_BOTNET
792792
if (b_numver(z) < NEAT_BOTNET)
793-
l = simple_sprintf(x, "join %s %s %d %c%d %s\n",
794-
botnetnick, dcc[i].nick,
795-
dcc[i].u.chat->channel, geticon(i),
796-
dcc[i].sock, dcc[i].host);
793+
l = snprintf(x, sizeof x, "join %s %s %d %c%ld %s\n",
794+
botnetnick, dcc[i].nick,
795+
dcc[i].u.chat->channel, geticon(i),
796+
dcc[i].sock, dcc[i].host);
797797
else
798798
#endif
799799
l = simple_sprintf(x, "j !%s %s %D %c%D %s\n",
@@ -804,12 +804,12 @@ void dump_links(int z)
804804
#ifndef NO_OLD_BOTNET
805805
if (b_numver(z) < NEAT_BOTNET) {
806806
if (dcc[i].u.chat->away) {
807-
l = simple_sprintf(x, "away %s %d %s\n", botnetnick,
808-
dcc[i].sock, dcc[i].u.chat->away);
807+
l = snprintf(x, sizeof x, "away %s %ld %s\n", botnetnick,
808+
dcc[i].sock, dcc[i].u.chat->away);
809809
dprint(z, x, l);
810810
}
811-
l = simple_sprintf(x, "idle %s %d %d\n", botnetnick,
812-
dcc[i].sock, now - dcc[i].timeval);
811+
l = snprintf(x, sizeof x, "idle %s %ld %" PRId64 "\n", botnetnick,
812+
dcc[i].sock, (int64_t) (now - dcc[i].timeval));
813813
} else
814814
#endif
815815
l = simple_sprintf(x, "i %s %D %D %s\n", botnetnick,
@@ -822,10 +822,10 @@ void dump_links(int z)
822822
for (i = 0; i < parties; i++) {
823823
#ifndef NO_OLD_BOTNET
824824
if (b_numver(z) < NEAT_BOTNET)
825-
l = simple_sprintf(x, "join %s %s %d %c%d %s\n",
826-
party[i].bot, party[i].nick,
827-
party[i].chan, party[i].flag,
828-
party[i].sock, party[i].from);
825+
l = snprintf(x, sizeof x, "join %s %s %d %c%d %s\n",
826+
party[i].bot, party[i].nick,
827+
party[i].chan, party[i].flag,
828+
party[i].sock, party[i].from);
829829
else
830830
#endif
831831
l = simple_sprintf(x, "j %s %s %D %c%D %s\n",
@@ -837,12 +837,12 @@ void dump_links(int z)
837837
#ifndef NO_OLD_BOTNET
838838
if (b_numver(z) < NEAT_BOTNET) {
839839
if (party[i].status & PLSTAT_AWAY) {
840-
l = simple_sprintf(x, "away %s %d %s\n", party[i].bot,
841-
party[i].sock, party[i].away);
840+
l = snprintf(x, sizeof x, "away %s %d %s\n", party[i].bot,
841+
party[i].sock, party[i].away);
842842
dprint(z, x, l);
843843
}
844-
l = simple_sprintf(x, "idle %s %d %d\n", party[i].bot,
845-
party[i].sock, now - party[i].timer);
844+
l = snprintf(x, sizeof x, "idle %s %d %" PRId64 "\n", party[i].bot,
845+
party[i].sock, (int64_t) (now - party[i].timer));
846846
} else
847847
#endif
848848
l = simple_sprintf(x, "i %s %D %D %s\n", party[i].bot,
@@ -1682,9 +1682,9 @@ void check_botnet_pings()
16821682
bot = findbot(dcc[i].nick);
16831683
bots = bots_in_subtree(bot);
16841684
users = users_in_subtree(bot);
1685-
simple_sprintf(s, "%s: %s (lost %d bot%s and %d user%s)",
1686-
BOT_PINGTIMEOUT, dcc[i].nick, bots,
1687-
(bots != 1) ? "s" : "", users, (users != 1) ? "s" : "");
1685+
snprintf(s, sizeof s, "%s: %s (lost %d bot%s and %d user%s)",
1686+
BOT_PINGTIMEOUT, dcc[i].nick, bots,
1687+
(bots != 1) ? "s" : "", users, (users != 1) ? "s" : "");
16881688
putlog(LOG_BOTS, "*", "%s.", s);
16891689
botnet_send_unlinked(i, dcc[i].nick, s);
16901690
killsock(dcc[i].sock);
@@ -1709,10 +1709,10 @@ void check_botnet_pings()
17091709
bot = findbot(dcc[i].nick);
17101710
bots = bots_in_subtree(bot);
17111711
users = users_in_subtree(bot);
1712-
simple_sprintf(s, "%s %s (%s) (lost %d bot%s and %d user%s)",
1713-
BOT_DISCONNECTED, dcc[i].nick, BOT_BOTNOTLEAFLIKE,
1714-
bots, (bots != 1) ? "s" : "", users, (users != 1) ?
1715-
"s" : "");
1712+
snprintf(s, sizeof s, "%s %s (%s) (lost %d bot%s and %d user%s)",
1713+
BOT_DISCONNECTED, dcc[i].nick, BOT_BOTNOTLEAFLIKE,
1714+
bots, (bots != 1) ? "s" : "", users, (users != 1) ?
1715+
"s" : "");
17161716
putlog(LOG_BOTS, "*", "%s.", s);
17171717
botnet_send_unlinked(i, dcc[i].nick, s);
17181718
killsock(dcc[i].sock);
@@ -1736,9 +1736,9 @@ void zapfbot(int idx)
17361736
bot = findbot(dcc[idx].nick);
17371737
bots = bots_in_subtree(bot);
17381738
users = users_in_subtree(bot);
1739-
simple_sprintf(s, "%s: %s (lost %d bot%s and %d user%s)", BOT_BOTDROPPED,
1740-
dcc[idx].nick, bots, (bots != 1) ? "s" : "", users,
1741-
(users != 1) ? "s" : "");
1739+
snprintf(s, sizeof s, "%s: %s (lost %d bot%s and %d user%s)", BOT_BOTDROPPED,
1740+
dcc[idx].nick, bots, (bots != 1) ? "s" : "", users,
1741+
(users != 1) ? "s" : "");
17421742
putlog(LOG_BOTS, "*", "%s.", s);
17431743
botnet_send_unlinked(idx, dcc[idx].nick, s);
17441744
killsock(dcc[idx].sock);

0 commit comments

Comments
 (0)