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 read_lang() crash on malformed language file #1681

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

Conversation

michaelortmann
Copy link
Member

@michaelortmann michaelortmann commented Aug 27, 2024

Found by: michaelortmann
Patch by: michaelortmann
Fixes:

One-line summary:
Fix read_lang() crash on malformed language file

Additional description (if needed):
eggdrop crashes on malformed (missing ,) language file
Example:
Edit language/core.english.lang
Change (remove ,)
0x132,inactive
Into
0x132inactive

$ ./eggdrop -t BotA.conf 
* Please report problem to https://github.com/eggheads/eggdrop/issues
* Check doc/BUG-REPORT on how to do so.
Segmentation fault (core dumped)

While fixing the parser to not crash, memory allocation also got optimized.
Before:

$ ltrace ./eggdrop -t BotA.conf 2>&1|grep realloc|wc -l
.die
686

After:

$ ltrace ./eggdrop -t BotA.conf 2>&1|grep realloc|wc -l
.die
75

Test cases demonstrating functionality (if applicable):
The new code has been battletested with lowering initial read_lang() char lbuf[256]; size of 256 to make it grow the ltext buffer with realloc().

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.

1 participant