Skip to content

Replace strcpy/strcat use with strlcpy/strlcat #49

Description

@morgant

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).

Activity

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

Metadata

Metadata

Assignees

Labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions