summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorWayne Davison <wayned@samba.org>2004-01-20 00:59:26 +0000
committerWayne Davison <wayned@samba.org>2004-01-20 00:59:26 +0000
commit72d45525d278776caacb293eba6282698592e874 (patch)
treecccc77f028bee7526516ae1fc65fa33b4e093b9f /lib
parent1fb8ec4b0d871f44eeb025b2ea2a1fbfa961234b (diff)
downloadrsync-72d45525d278776caacb293eba6282698592e874.tar.gz
rsync-72d45525d278776caacb293eba6282698592e874.tar.bz2
rsync-72d45525d278776caacb293eba6282698592e874.zip
Make sure that strlcpy() returns the right value when the bufsize is 0.
Diffstat (limited to 'lib')
-rw-r--r--lib/compat.c10
1 files changed, 6 insertions, 4 deletions
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