From 828abf7160fe466910aff3ca6ec257863fbc39a4 Mon Sep 17 00:00:00 2001 From: Michael Ortmann <41313082+michaelortmann@users.noreply.github.com> Date: Thu, 9 Jan 2025 00:49:02 +0100 Subject: [PATCH] Fix Tcl_TraceVar() / tcl_eggstr() --- src/tcl.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/tcl.c b/src/tcl.c index 949fc5842..f197d9a91 100644 --- a/src/tcl.c +++ b/src/tcl.c @@ -283,20 +283,24 @@ static char *tcl_eggstr(ClientData cdata, Tcl_Interp *irp, } s = (char *) Tcl_GetVar2(interp, name1, name2, 0); if (s != NULL) { - if (strlen(s) > abs(st->max)) - s[abs(st->max)] = 0; - if (st->str == botnetnick) + if (st->str == botnetnick) { + if (strlen(s) > abs(st->max)) + s[abs(st->max)] = 0; botnet_change(s); - else if (st->str == logfile_suffix) + } else if (st->str == logfile_suffix) { + if (strlen(s) > abs(st->max)) + s[abs(st->max)] = 0; logsuffix_change(s); - else if (st->str == firewall) { + } else if (st->str == firewall) { + if (strlen(s) > abs(st->max)) + s[abs(st->max)] = 0; splitc(firewall, s, ':'); if (!firewall[0]) strcpy(firewall, s); else firewallport = atoi(s); } else - strcpy(st->str, s); + strlcpy(st->str, s, abs(st->max) + 1); if ((st->flags) && (s[0])) { if (st->str[strlen(st->str) - 1] != '/') strcat(st->str, "/");