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

Cleanup irc.mod / string copy #1134

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

Conversation

michaelortmann
Copy link
Member

@michaelortmann michaelortmann commented Feb 26, 2021

Found by: michaelortmann
Patch by: michaelortmann
Fixes:

One-line summary:
Cleanup irc.mod / string copy

Additional description (if needed):

Test cases demonstrating functionality (if applicable):
No functional change.

@thommey
Copy link
Member

thommey commented Aug 22, 2021

This isn't a simple cleanup, it's a change in behavior. newsplit modifies its argument string to split it, removing this buffer makes the functions modify the input.

@michaelortmann
Copy link
Member Author

thats fine. the parameter is modifyable. we dont need to copy before newsplit(). other functions in chan.c call newsplit() on the parameter without such copy also. example: https://github.com/eggheads/eggdrop/blob/develop/src/mod/irc.mod/chan.c#L1192

@thommey
Copy link
Member

thommey commented Aug 13, 2023

It still has side-effects I have seen in the past, e.g. raw console log being mangled.
It might be warranted to always give the bind handler a copy of this string instead of the real raw string.

@michaelortmann
Copy link
Member Author

Some bind functions dont copy the origmsg and modify it. Some copy it before modifying. I see no problems in modifying without copy, so would strip all local copies. You seen problems without copy, so you would like to copy for all binds in advance. We could indeed argue to strip all local copies in favor of letting the bind call make the copy before calling the bind. In each case, i would like to see a general solution instead of the current state where sometimes its copied and sometimes its not.

Anyway, for now i opted to simplify this PR, to just replace strncpy value with strlcpy sizeof.

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.

2 participants