Skip to content

Commit

Permalink
Fix various bugs in xattr handling
Browse files Browse the repository at this point in the history
  • Loading branch information
netheril96 committed Apr 10, 2024
1 parent 602c025 commit 3ca3c2b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion sources/lite_format.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1057,7 +1057,7 @@ int FuseHighLevelOps::vutimens(const char* path, const fuse_timespec* ts, const
}
int FuseHighLevelOps::vlistxattr(const char* path, char* list, size_t size, const fuse_context* ctx)
{
int rc = root_.listxattr(path, list, size);
int rc = root_.listxattr(name_trans_.encrypt_full_path(path, nullptr).c_str(), list, size);
if (rc < 0)
{
return rc;
Expand Down
7 changes: 5 additions & 2 deletions test/test_common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,10 @@ namespace
std::vector<std::string> listxattr(FuseHighLevelOpsBase& ops, const char* path)
{
auto size = ops.vlistxattr(path, nullptr, 0, nullptr);
REQUIRE(size > 0);
if (size <= 0)
{
return {};
}
std::vector<char> buffer(size);
REQUIRE(ops.vlistxattr(path, buffer.data(), buffer.size(), nullptr) > 0);
std::vector<std::string> result;
Expand Down Expand Up @@ -283,7 +286,7 @@ void test_fuse_ops(FuseHighLevelOpsBase& ops, OSService& repo_root, bool case_in
CHECK(ops.vsetxattr("/cbd", "org.securefs.test", "blah", 4, 0, 0, nullptr) >= 0);
CHECK(listxattr(ops, "/cbd")
== std::vector<std::string>{"com.apple.FinderInfo", "org.securefs.test"});
CHECK(ops.vremovexattr("/cbd", "com.apple.FinderInfo", nullptr) > 0);
CHECK(ops.vremovexattr("/cbd", "com.apple.FinderInfo", nullptr) == 0);
CHECK(listxattr(ops, "/cbd") == std::vector<std::string>{"org.securefs.test"});
CHECK(getxattr(ops, "/cbd", "org.securefs.test") == "blah");
}
Expand Down

0 comments on commit 3ca3c2b

Please sign in to comment.