Make sure that strlcpy() returns the right value when the bufsize is 0.
authorWayne Davison <wayned@samba.org>
Tue, 20 Jan 2004 00:59:26 +0000 (00:59 +0000)
committerWayne Davison <wayned@samba.org>
Tue, 20 Jan 2004 00:59:26 +0000 (00:59 +0000)
lib/compat.c

index 6dd2328..879f548 100644 (file)
 {
        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