diff --git a/src/funcs.c b/src/funcs.c index 9bd054f..a5363e7 100644 --- a/src/funcs.c +++ b/src/funcs.c @@ -54,9 +54,12 @@ FILE_RCSID("@(#)$File: funcs.c,v 1.118 2020/12/08 21:26:00 christos Exp $") protected char * file_copystr(char *buf, size_t blen, size_t width, const char *str) { - if (++width > blen) - width = blen; - strlcpy(buf, str, width); + if (blen == 0) + return buf; + if (width >= blen) + width = blen - 1; + memcpy(buf, str, width); + buf[width] = '\0'; return buf; }