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

Vulnerability? Bug? Null write in the get_cmdln_options function in src/options.c. #26

Closed
decentL opened this issue Apr 27, 2020 · 5 comments

Comments

@decentL
Copy link

decentL commented Apr 27, 2020

Hi,

In src/options.c, line 337.

// malloc() may fail, and str will be NULL.
str=(char*)malloc(strlen(pwd_entry->pw_dir)+14);
// write to Null
snprintf(str,strlen(pwd_entry->pw_dir)+14,"%s/.bwm-ng.conf",pwd_entry->pw_dir);

I think this is a vulnerability, and maybe we can patch it as following?

str=(char*)malloc(strlen(pwd_entry->pw_dir)+14);
if(!str) return

Thanks for any consideration!

Peiyu Liu,
NESA lab,
Zhejiang University

@vgropp
Copy link
Owner

vgropp commented Apr 30, 2020

it should terminate with an error and not just return and continue

@ofalk
Copy link
Contributor

ofalk commented Jul 27, 2020

Under which circumstances do you think malloc() can fail and how can one easily reproduce the behaviour?

@vgropp
Copy link
Owner

vgropp commented Sep 13, 2020

I think https://www.quora.com/What-are-the-possible-ways-malloc-might-fail-Consider-malloc-code-doesnt-have-any-bugs sounds like a wrap up
but it will be not very easy to reproduce it

@vgropp vgropp closed this as completed in 9774f23 Sep 29, 2020
@ofalk
Copy link
Contributor

ofalk commented Sep 29, 2020

Thx for merging!

@vgropp
Copy link
Owner

vgropp commented Sep 29, 2020

Thx for contributing!

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

No branches or pull requests

3 participants