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 #11: Build error -Wstringop-truncation. #12

Closed
wants to merge 1 commit into from

Conversation

jofemodo
Copy link

Replace strncpy by snprintf, that is a safer function and don't generate the compilation warning.

https://www.geeksforgeeks.org/why-strcpy-and-strncpy-are-not-safe-to-use/

Replace strncpy by snprintf, that is a safer function and don't generate the compilation warning.
@falkTX
Copy link
Member

falkTX commented Dec 16, 2019

The strncpy usage is completely valid though...
In your changes, the 3rd set misses the "format", which I would say is funny seeing it build without errors (as it abuses snprintf)
I will fix this later on, changing a function just because of a compiler warning does not seem a good choice personally

@jofemodo
Copy link
Author

I'm not missing the format but the specified format doesn't include any "%" replacement var ;-)

@jofemodo
Copy link
Author

Regarding the use of strncpy, it's not valid in at less 3 calls because the input string length is not limited, so you can not be sure that the resulting destination string include a NULL terminating char, what will generate a buffer overflow.
So, if you specify a long device name or jack name as argument, you will cause the mod-ttymidi to segfault.

@falkTX
Copy link
Member

falkTX commented Dec 16, 2019

This is now fixed

@falkTX falkTX closed this Dec 16, 2019
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