summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Lawrence <paullawrence@google.com>2023-08-30 10:16:49 -0700
committerPaul Lawrence <paullawrence@google.com>2024-02-23 15:02:53 +0000
commit0c4d487458c704432bcf0a99c1a9a8f8d72602b9 (patch)
tree528769ab8bd6d74146e71662e7e34ac64691d304
parent51527e26a48a13c73100f6380d6179215e4fa78e (diff)
downloadMediaProvider-0c4d487458c704432bcf0a99c1a9a8f8d72602b9.tar.gz
Correctly handle non-NULL terminated fuse_dirents
Bug: 297092865 Test: Entries appear correctly in storage/emulated/0/Android/data Change-Id: I6397f368d295891b935e974858733b46e84218ff Merged-In: I6397f368d295891b935e974858733b46e84218ff
-rw-r--r--jni/FuseDaemon.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/jni/FuseDaemon.cpp b/jni/FuseDaemon.cpp
index 9f889a120..2e6fb8658 100644
--- a/jni/FuseDaemon.cpp
+++ b/jni/FuseDaemon.cpp
@@ -1984,8 +1984,9 @@ static void pf_readdir_postfilter(fuse_req_t req, fuse_ino_t ino, uint32_t error
struct fuse_dirent* dirent_out = (struct fuse_dirent*)((char*)dirents_out + fro->size);
struct stat stats;
int err;
- std::string child_path = path + "/";
- child_path.append(dirent_in->name, dirent_in->namelen);
+
+ std::string child_name(dirent_in->name, dirent_in->namelen);
+ std::string child_path = path + "/" + child_name;
in += sizeof(*dirent_in) + round_up(dirent_in->namelen, sizeof(uint64_t));
err = stat(child_path.c_str(), &stats);
@@ -1993,9 +1994,9 @@ static void pf_readdir_postfilter(fuse_req_t req, fuse_ino_t ino, uint32_t error
((stats.st_mode & 0001) || ((stats.st_mode & 0010) && req->ctx.gid == stats.st_gid) ||
((stats.st_mode & 0100) && req->ctx.uid == stats.st_uid) ||
fuse->mp->isUidAllowedAccessToDataOrObbPath(req->ctx.uid, child_path) ||
- strcmp(dirent_in->name, ".nomedia") == 0)) {
+ child_name == ".nomedia")) {
*dirent_out = *dirent_in;
- strcpy(dirent_out->name, dirent_in->name);
+ strcpy(dirent_out->name, child_name.c_str());
fro->size += sizeof(*dirent_out) + round_up(dirent_out->namelen, sizeof(uint64_t));
}
}