diff options
author | 2020-02-20 15:47:06 +0000 | |
---|---|---|
committer | 2020-02-21 00:07:17 +0000 | |
commit | 2c5eb697ef7c3230c85a92a17c9f53d6e19b1a12 (patch) | |
tree | 51420f3e27d4bcc2e16b20ae7da535893fa5b633 /jni/node.cpp | |
parent | cbf94b2ccb15f4f35eccab77ed243b1c830ba25d (diff) |
Fix sensitive logging
Removed file paths and other unnecessary info from logs
Added more consistent logging
Test: No file paths in logs. Example logs
V libfuse : unique: 126, opcode: GETATTR (3), nodeid: 523136724464, insize: 56, pid: 2841
D FuseDaemon: pf_getattr : node = [/storage/emulated/523136724464/]
V libfuse : unique: 126, success, outsize: 120
Bug: 149470210
Change-Id: Iee7c2ac085608c0fcd6ecdf9d64a1ae62ebc676b
Diffstat (limited to 'jni/node.cpp')
-rw-r--r-- | jni/node.cpp | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/jni/node.cpp b/jni/node.cpp index 8898b7b5b..6c530cbcd 100644 --- a/jni/node.cpp +++ b/jni/node.cpp @@ -41,20 +41,33 @@ namespace mediaprovider { namespace fuse { // Assumes that |node| has at least one child. -void node::BuildPathForNodeRecursive(node* node, std::string* path) { - if (node->parent_) BuildPathForNodeRecursive(node->parent_, path); +void node::BuildPathForNodeRecursive(bool safe, const node* node, std::stringstream* path) { + if (node->parent_) { + BuildPathForNodeRecursive(safe, node->parent_, path); + } - (*path) += node->GetName() + "/"; + if (safe && node->parent_) { + (*path) << reinterpret_cast<uintptr_t>(node); + } else { + (*path) << node->GetName(); + } + (*path) << "/"; } std::string node::BuildPath() const { std::lock_guard<std::recursive_mutex> guard(*lock_); - std::string path; + std::stringstream path; + + BuildPathForNodeRecursive(false, this, &path); + return path.str(); +} + +std::string node::BuildSafePath() const { + std::lock_guard<std::recursive_mutex> guard(*lock_); + std::stringstream path; - path.reserve(PATH_MAX); - if (parent_) BuildPathForNodeRecursive(parent_, &path); - path += name_; - return path; + BuildPathForNodeRecursive(true, this, &path); + return path.str(); } const node* node::LookupAbsolutePath(const node* root, const std::string& absolute_path) { |