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(server): Fix undefined behvior on Linux hosts #4915

Merged
merged 1 commit into from Apr 8, 2021

Conversation

Krzmbrzl
Copy link
Member

@Krzmbrzl Krzmbrzl commented Apr 5, 2021

The fields of the rlimit struct were assumed to be of type long int when
printing via the qWarning function. This seems to be correct on e.g.
Ubuntu but at least on Alpine Linux this is not true.

In that case the wrong format specifiers are being used for printing
these values, which causes undefined behavior.

The fix is to always copy the values into variables of type long long
unsigned int and then printing these. The code also adds an assertion
making sure that within this copy operation the values won't overflow
the variable's size.

Fixes #4897

Checks

@TredwellGit
Copy link
Contributor

This seems to be correct on e.g. Ubuntu but at least on Alpine Linux this is not true.

To be specific this is a difference between glibc which Ubuntu uses and musl which Alpine uses.

The fields of the rlimit struct were assumed to be of type long int when
printing via the qWarning function. This assumption is correct for glibc
(used by e.g. Ubuntu) but it is not true for musl (used by e.g. Alpine
Linux).

In that case the wrong format specifiers are being used for printing
these values, which causes undefined behavior.

The fix is to always copy the values into variables of type long long
unsigned int and then printing these. The code also adds an assertion
making sure that within this copy operation the values won't overflow
the variable's size.

Fixes mumble-voip#4897
@Krzmbrzl
Copy link
Member Author

Krzmbrzl commented Apr 8, 2021

Everything has been resolved. This PR is ready for merge.

@Krzmbrzl Krzmbrzl merged commit e8f5c70 into mumble-voip:master Apr 8, 2021
@Krzmbrzl Krzmbrzl deleted the fix-rlimit-printing branch April 8, 2021 09:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A bug (error) in the software linux server
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Can't compile Murmur master or 1.4.0 on Alpine Linux
3 participants