From: Wayne Davison Date: Tue, 20 Jan 2004 00:59:26 +0000 (+0000) Subject: Make sure that strlcpy() returns the right value when the bufsize is 0. X-Git-Url: https://mattmccutchen.net/rsync/rsync.git/commitdiff_plain/72d45525d278776caacb293eba6282698592e874 Make sure that strlcpy() returns the right value when the bufsize is 0. --- diff --git a/lib/compat.c b/lib/compat.c index 6dd2328a..879f5487 100644 --- a/lib/compat.c +++ b/lib/compat.c @@ -116,10 +116,12 @@ { size_t len = strlen(s); size_t ret = len; - if (bufsize <= 0) return 0; - if (len >= bufsize) len = bufsize-1; - memcpy(d, s, len); - d[len] = 0; + if (bufsize > 0) { + if (len >= bufsize) + len = bufsize-1; + memcpy(d, s, len); + d[len] = 0; + } return ret; } #endif