From 5b924051b44fe39a9154f98f345d2987a4ea6f09 Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Tue, 4 Apr 2023 10:22:09 +0200 Subject: [PATCH 1/2] libsmb: fix regression on smbc_getxattr and fix doc Bug: https://bugzilla.samba.org/show_bug.cgi?id=14808 Signed-off-by: Remi Collet Reviewed-by: Jeremy Allison Reviewed-by: Volker Lendecke (cherry picked from commit 4fc166628fda160d1cd38c140a9664defc5844ab) --- source3/include/libsmbclient.h | 2 +- source3/libsmb/libsmb_xattr.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/source3/include/libsmbclient.h b/source3/include/libsmbclient.h index ef8b327e374..056444d008c 100644 --- a/source3/include/libsmbclient.h +++ b/source3/include/libsmbclient.h @@ -2419,7 +2419,7 @@ int smbc_getxattr(const char *url, * required to hold the attribute value will be returned, * but nothing will be placed into the value buffer. * - * @return 0 on success, < 0 on error with errno set: + * @return size on success, < 0 on error with errno set: * - EINVAL The client library is not properly initialized * or one of the parameters is not of a correct * form diff --git a/source3/libsmb/libsmb_xattr.c b/source3/libsmb/libsmb_xattr.c index 1e8d2718a22..1f820521193 100644 --- a/source3/libsmb/libsmb_xattr.c +++ b/source3/libsmb/libsmb_xattr.c @@ -2182,9 +2182,9 @@ SMBC_getxattr_ctx(SMBCCTX *context, TALLOC_FREE(frame); /* * static function cacl_get returns a value greater than zero - * on success. Map this to zero meaning success. + * which is needed buffer size needed when size_t is 0. */ - return ret < 0 ? -1 : 0; + return ret; } /* Unsupported attribute name */ -- 2.42.0 From 63e525b96be6a4331a9311ebbcf8b984455365f8 Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Tue, 4 Apr 2023 12:16:09 +0200 Subject: [PATCH 2/2] libsmb: Fix test for smbc_getxattr Bug: https://bugzilla.samba.org/show_bug.cgi?id=14808 Signed-off-by: Remi Collet Reviewed-by: Jeremy Allison Reviewed-by: Volker Lendecke Autobuild-User(master): Volker Lendecke Autobuild-Date(master): Sun Apr 9 10:44:38 UTC 2023 on atb-devel-224 (cherry picked from commit 0cd66fe6bd4ac2aa0b302ddf3eb5068fc9c522ec) --- source4/torture/libsmbclient/libsmbclient.c | 25 ++++++++++++++++----- 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/source4/torture/libsmbclient/libsmbclient.c b/source4/torture/libsmbclient/libsmbclient.c index 55ea26f5bc8..72af8fc01c9 100644 --- a/source4/torture/libsmbclient/libsmbclient.c +++ b/source4/torture/libsmbclient/libsmbclient.c @@ -1542,17 +1542,30 @@ static bool torture_libsmbclient_getxattr(struct torture_context *tctx) ret)); /* - * Ensure getting a valid attribute returns 0. + * Ensure getting a valid attribute computes its size. + */ + ret = smbc_getxattr(getxattr_name, "system.*", NULL, 0); + torture_assert_goto(tctx, + ret >= 0, + ok, + done, + talloc_asprintf(tctx, + "smbc_getxattr(foobar, NULL) on '%s' should " + "get >=0, got %d\n", + getxattr_name, + ret)); + + /* + * Ensure getting a valid attribute returns its size. */ ret = smbc_getxattr(getxattr_name, "system.*", value, sizeof(value)); - torture_assert_int_equal_goto(tctx, - ret, - 0, + torture_assert_goto(tctx, + ret >= 0, ok, done, talloc_asprintf(tctx, - "smbc_getxattr(foobar) on '%s' should " - "get -1, got %d\n", + "smbc_getxattr(foobar, value) on '%s' should " + "get >=0, got %d\n", getxattr_name, ret)); -- 2.42.0