Fix read_xattr() for solaris.
[rsync/rsync.git] / lib / sysxattrs.c
index 7845d59..76b6802 100644 (file)
@@ -145,8 +145,8 @@ static ssize_t read_xattr(int attrfd, void *buf, size_t buflen)
                ret = -1;
        } else {
                size_t bufpos;
-               for (bufpos = 0; bufpos < buflen; ) {
-                       ssize_t cnt = read(attrfd, buf + bufpos, buflen - bufpos);
+               for (bufpos = 0; bufpos < sb.st_size; ) {
+                       ssize_t cnt = read(attrfd, buf + bufpos, sb.st_size - bufpos);
                        if (cnt <= 0) {
                                if (cnt < 0 && errno == EINTR)
                                        continue;
@@ -254,6 +254,8 @@ ssize_t sys_llistxattr(const char *path, char *list, size_t size)
                        continue;
 
                if ((ret += len+1) > size) {
+                       if (size == 0)
+                               continue;
                        ret = -1;
                        errno = ERANGE;
                        break;