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

Fixes for musl #19

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Fixes for musl #19

wants to merge 2 commits into from

Conversation

arnout
Copy link

@arnout arnout commented Aug 26, 2016

arnout added 2 commits August 27, 2016 01:11
Also, its argument is not const, so add const_cast. This is risky
because in fact basename() will modify the argument if it ends with /
but that's not the case here.

Signed-off-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
LONG_BIT is not a sysconf value, it is either 32 or 64. Using it as
a sysconf value will give weird results.

Also sysconf(_SC_LONG_BIT) is useless: it will always return a value
equal to LONG_BIT: it's either compiled 32-bit or 64-bit so a runtime
lookup doesn't make sense. For this reason, musl has removed the
definition of _SC_LONG_BIT.

Signed-off-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
@@ -99,7 +100,7 @@ static string sysfs_getbustype(const string & path)
{
devname =
string(fs.path + "/bus/") + string(namelist[i]->d_name) +
"/devices/" + basename(path.c_str());
"/devices/" + basename(const_cast<char*>(path.c_str()));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is wrong -- when you include libgen.h, you get a POSIX basename which is allowed to modify the memory of the arg passed in. which means this might crash.

might be better to have lshw define its own basename to guarantee portability.

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