On Fri, Jan 03, 2025 at 03:45:07PM +0100, Roland Illig wrote: > No, strlcpy is fine for string handling, as it expects (null-terminated) > strings and also produces them. > > It's only strncpy (and probably strncat) that are problematic, as these > two are hard to use correctly for handling strings.
The question is wether the source strings are 0 terminated or not. If they are, strlcpy() is good. If they are not guaranteed to be (like sometimes when copying from fixed size descriptors) you need to use strncpy() and manually terminate the result. You can not swap them randomly, they serve different purposes. See the last WARNING: section in strlcpy(3). Martin