From 6ad5cd42257f703ce2c3e9a3436a826c0b6cf321 Mon Sep 17 00:00:00 2001 From: Ian Lee Date: Thu, 12 May 2016 17:03:10 +0100 Subject: [PATCH 1/2] Revert "unordered_map value type, is of std::pair, hence a copy from const Key to Key is never shallow." This reverts commit 6985c8f64c173442e4e3d2d16251d594cea03b28. --- encfs/Context.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/encfs/Context.cpp b/encfs/Context.cpp index d766346..0a6bcd5 100644 --- a/encfs/Context.cpp +++ b/encfs/Context.cpp @@ -127,6 +127,14 @@ void EncFS_Context::eraseNode(const char *path, FileNode *pl) { it->second.pop_front(); + // if no more references to this file, remove the record all together + if (it->second.empty()) { + // attempts to make use of shallow copy to clear memory used to hold + // unencrypted filenames.. not sure this does any good.. + std::string storedName = it->first; + openFiles.erase(it); + storedName.assign(storedName.length(), '\0'); + } } } // namespace encfs From 4033ca85d2df04b4b12cf8f658fadb806aaf6aaa Mon Sep 17 00:00:00 2001 From: Ian Lee Date: Thu, 12 May 2016 17:10:19 +0100 Subject: [PATCH 2/2] The string copy will not be shallow, due to undordere_map returning a const std::string. --- encfs/Context.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/encfs/Context.cpp b/encfs/Context.cpp index 0a6bcd5..4cdcd36 100644 --- a/encfs/Context.cpp +++ b/encfs/Context.cpp @@ -129,11 +129,7 @@ void EncFS_Context::eraseNode(const char *path, FileNode *pl) { // if no more references to this file, remove the record all together if (it->second.empty()) { - // attempts to make use of shallow copy to clear memory used to hold - // unencrypted filenames.. not sure this does any good.. - std::string storedName = it->first; openFiles.erase(it); - storedName.assign(storedName.length(), '\0'); } }