summaryrefslogtreecommitdiff
path: root/jni/node.cpp
diff options
context:
space:
mode:
author Zimuzo Ezeozue <zezeozue@google.com> 2020-02-21 19:41:33 +0000
committer Zimuzo Ezeozue <zezeozue@google.com> 2020-02-21 19:47:00 +0000
commitebac1c810842d30677d57efc3af88bb18f9fbd51 (patch)
treeac8f611960dbf7ebb62abc034f742fa3bed69a67 /jni/node.cpp
parent338bd1adbe7320ed1605ed4c7249362f16be258d (diff)
Reland "Fix sensitive logging""
This reverts commit 338bd1adbe7320ed1605ed4c7249362f16be258d and fixes broken BuildPath() 'always' appending a '/' to the end of a segment, e.g /sdcard/foo/ (even when foo is a file) Reason for revert: Fix forward with ag/10380778 enabled to catch regression Change-Id: I86af9c7b4e173505140e58df4744fa94e0ded001
Diffstat (limited to 'jni/node.cpp')
-rw-r--r--jni/node.cpp33
1 files changed, 25 insertions, 8 deletions
diff --git a/jni/node.cpp b/jni/node.cpp
index 8898b7b5b..618777442 100644
--- a/jni/node.cpp
+++ b/jni/node.cpp
@@ -41,20 +41,37 @@ 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) const {
+ 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();
+ }
+
+ if (node != this) {
+ // Must not add a '/' to the last segment
+ (*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) {