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

Fix Tcl_TraceVar() / tcl_eggstr() modifying original tcl variable #1733

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

michaelortmann
Copy link
Member

Found by: DasBrain
Patch by: michaelortmann
Fixes: #1544

One-line summary:
Fix Tcl_TraceVar() / tcl_eggstr()

Additional description (if needed):
This bug affects eggdrop since the dawn of time.

Eggdrop uses Tcl_TraceVar() when a tcl variable is set. In callback function tcl_eggstr() it truncates strings to their maximum length. The Bug is, that it modifies the original string here:

s[abs(st->max)] = 0;

This PR fixes this, by modifying the destination string, when the original is copied to the destination here:

strcpy(st->str, s);
via replacing that strcpy() with a strlcpy().

There are a few special variables / handlers here:

eggdrop/src/tcl.c

Lines 288 to 298 in 0f5599e

if (st->str == botnetnick)
botnet_change(s);
else if (st->str == logfile_suffix)
logsuffix_change(s);
else if (st->str == firewall) {
splitc(firewall, s, ':');
if (!firewall[0])
strcpy(firewall, s);
else
firewallport = atoi(s);
} else

It would make this PR too complex to also look into those and fix those cases. So this PR will fix all variables but the following 3:

botnetnick
logfile_suffix
firewall

Test cases demonstrating functionality (if applicable):
eggdrop.conf:

set dasbrain's-awesome-configuration-template-name tcl9eggdrop
putlog "DBG: dasbrain's-awesome-configuration-template-name: ${dasbrain's-awesome-configuration-template-name}"
set username ${dasbrain's-awesome-configuration-template-name}
putlog "DBG: Username: $username"
putlog "DBG: dasbrain's-awesome-configuration-template-name: ${dasbrain's-awesome-configuration-template-name}"

Before:

DBG: dasbrain's-awesome-configuration-template-name: tcl9eggdrop
DBG: Username: tcl9eggdro
DBG: dasbrain's-awesome-configuration-template-name: tcl9eggdro

After:

DBG: dasbrain's-awesome-configuration-template-name: tcl9eggdrop
DBG: Username: tcl9eggdro
DBG: dasbrain's-awesome-configuration-template-name: tcl9eggdrop

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Username truncation affects the original variable.
1 participant