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

Replace strcpy/strcat use with strlcpy/strlcat #49

Open
morgant opened this issue Sep 3, 2024 · 0 comments
Open

Replace strcpy/strcat use with strlcpy/strlcat #49

morgant opened this issue Sep 3, 2024 · 0 comments
Assignees
Labels

Comments

@morgant
Copy link
Owner

morgant commented Sep 3, 2024

As noted in Issue #48 (see this comment), when building mlvwm with clang under OpenBSD amd64/7.5-stable, I get the following warnings:

mlvwm.c:386(mlvwm.o:(Done)): warning: strcpy() is almost always misused, please use strlcpy()
functions.c:322(functions.o:(ChangeDesk)): warning: sprintf() is often misused, please use snprintf()

There are quite a number of uses of strpy() in mlvwm.c's Done() implementation.

As noted in a comment on Issue #6, I had intended to replace strcat() with strlcat() as part of that move from sprintf() to snprintf(), but held off as strlcat() is generally BSD-specific and not included in Linux's libc. This is true of strlcpy() too.

This is pretty well covered in WikiBook's C Programming/C Reference/nonstandard/strlcpy. Briefly, strlcpy() & strlcat() are implemented for Linux in libbsd, but there may be some minor variations in implementation across other UNIX-like OSes.

I do intend to migrate to strlcpy() & strlcat() using libbsd, but I want to resolve existing issues building/running on Linux distros first, specifically: Arch Linux (Issue #40, Issue #37), Debian (Issue #38), Slackware (Issue #29), and Ubuntu (Issue #1).

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

No branches or pull requests

1 participant