From 7d1de8bd48c0ea1e0ddd9f103d6fb1c7c3855c93 Mon Sep 17 00:00:00 2001 From: Ralph Boehme Date: Thu, 28 Jun 2018 21:47:54 +0200 Subject: [PATCH] s3: lib/xattr_tdb: fix listing xattrs If there's no record in the xattr.tdb, dbwrap_fetch() will return NT_STATUS_NOT_FOUND. That should not result in an error in callers of xattr_tdb_load_attrs(). Signed-off-by: Ralph Boehme Reviewed-by: Stefan Metzmacher --- source3/lib/xattr_tdb.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/source3/lib/xattr_tdb.c b/source3/lib/xattr_tdb.c index 34afbe29291..f3a2e19bf5d 100644 --- a/source3/lib/xattr_tdb.c +++ b/source3/lib/xattr_tdb.c @@ -115,6 +115,9 @@ static NTSTATUS xattr_tdb_load_attrs(TALLOC_CTX *mem_ctx, make_tdb_data(id_buf, sizeof(id_buf)), &data); if (!NT_STATUS_IS_OK(status)) { + if (NT_STATUS_EQUAL(status, NT_STATUS_NOT_FOUND)) { + return status; + } return NT_STATUS_INTERNAL_DB_CORRUPTION; } @@ -316,14 +319,21 @@ ssize_t xattr_tdb_listattr(struct db_context *db_ctx, status = xattr_tdb_load_attrs(frame, db_ctx, id, &attribs); - if (!NT_STATUS_IS_OK(status)) { - DEBUG(10, ("xattr_tdb_fetch_attrs failed: %s\n", + if (!NT_STATUS_IS_OK(status) && + !NT_STATUS_EQUAL(status, NT_STATUS_NOT_FOUND)) + { + DEBUG(0, ("xattr_tdb_fetch_attrs failed: %s\n", nt_errstr(status))); errno = EINVAL; TALLOC_FREE(frame); return -1; } + if (NT_STATUS_EQUAL(status, NT_STATUS_NOT_FOUND)) { + TALLOC_FREE(frame); + return 0; + } + DEBUG(10, ("xattr_tdb_listattr: Found %d xattrs\n", attribs->num_eas)); -- 2.47.3