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

(WIP) Fix snprintf with overlapping source and dest strings #1062

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from

Conversation

michaelortmann
Copy link
Member

@michaelortmann michaelortmann commented Nov 5, 2020

Found by: Will Buckner and michaelortmann
Patch by: michaelortmann
Fixes: #1061

One-line summary:
Fix snprintf with overlapping source and dest strings

Additional description (if needed):
This looks like another bug in the code:

egg_snprintf(newnicks, sizeof newnicks, ",%s", nick);

shouldnt nick be appended instead? %s,%s instead of ,%s?
Another line looks glitchy:
((9 + strlen(chan) + strlen(newnicks) + strlen(newnick) +

Here strlen(newnick) is calculated. But later:
if (newnick)

there is a check for newnick is NULL.
This doesnt make sense, does it?
We really need to come up with a good test for function parse_q() to make sure, the code works as expected. I think this function is buggy in its current state.
If there is indeed a bug it would effect eggdrop when optimize_kicks == 2 is set.
The alleged bug was introduced when optimize-kicks was added to eggdrop:
643554c#diff-917cd0562d3c81d827ab3b993432429b4433293a25e4090c1bda6823b705e4f2R539 in eggdrop 1.5.2

Test cases demonstrating functionality (if applicable):
I dont have real world test yet. Thats why this PR is still marked as WIP.

@michaelortmann michaelortmann changed the title (WIP) Fix string concatenation (WIP) Fix snprintf with overlapping source and dest strings Nov 5, 2020
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.

snprintf with overlapping source and dest strings
1 participant