vfs_xattr_tdb: handle case of zero size.
authorUri Simchoni <uri@samba.org>
Thu, 13 Apr 2017 09:50:47 +0000 (12:50 +0300)
committerJeremy Allison <jra@samba.org>
Mon, 17 Apr 2017 22:43:20 +0000 (00:43 +0200)
With getxattr(), passing a zero buffer size is a
way of obtaining actual xattr size.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=12737

Signed-off-by: Uri Simchoni <uri@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/modules/vfs_xattr_tdb.c

index b32fbc1e9eb1047dea4baef324ecc1bcf3e2ca3c..58acf446d2e6e571d579429a2f507c87975e8e58 100644 (file)
@@ -85,6 +85,12 @@ static ssize_t xattr_tdb_getxattr(struct vfs_handle_struct *handle,
                TALLOC_FREE(frame);
                return -1;
        }
+
+       if (size == 0) {
+               TALLOC_FREE(frame);
+               return xattr_size;
+       }
+
        if (blob.length > size) {
                TALLOC_FREE(frame);
                errno = ERANGE;
@@ -125,6 +131,12 @@ static ssize_t xattr_tdb_fgetxattr(struct vfs_handle_struct *handle,
                TALLOC_FREE(frame);
                return -1;
        }
+
+       if (size == 0) {
+               TALLOC_FREE(frame);
+               return xattr_size;
+       }
+
        if (blob.length > size) {
                TALLOC_FREE(frame);
                errno = ERANGE;