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 segfault for bad write in lzbench.cpp #122

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

Conversation

richarddd
Copy link

Fix segfault for writing beyond the size of cpu_brand_str

@tansy
Copy link
Contributor

tansy commented Oct 10, 2023

I'm surprised as it was my PR.
In line 753 there is a string allocated that is 1 character longer than cpu string, to fit null-terminator.

char* cpu_brand_str = (char*)calloc(1, 3*sizeof(mx)+1);

But as you noticed, index of last element is 3*sizeof(mx) and string's length is 3*sizeof(mx)+1.

How did you find it, add brand strings are, generally, shorter and won't go this far to cause overflow?

@tansy tansy mentioned this pull request Oct 14, 2023
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.

None yet

2 participants