diff options
Diffstat (limited to 'common/compat.c')
-rw-r--r-- | common/compat.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/common/compat.c b/common/compat.c index 6f9c58d..53de9bf 100644 --- a/common/compat.c +++ b/common/compat.c @@ -136,15 +136,18 @@ strtob(const char* str) size_t strlcpy(char *dst, const char *src, size_t len) { - size_t ret = strlen(dst); + size_t ret = strlen(src); + size_t copied; - while (len > 1) { + while (ret > 0 && len > 1) { *dst++ = *src++; - len--; + --len; + --ret; + ++copied; } if (len > 0) *dst = '\0'; - return (ret); + return copied; } #endif /* HAVE_STRLCPY */ |