about summary refs log tree commit diff
diff options
context:
space:
mode:
authorGuillaume Maudoux <guillaume.maudoux@uclouvain.be>2019-03-01T00·29+0100
committerGuillaume Maudoux <layus.on@gmail.com>2019-03-09T23·56+0100
commit5c56570726bc3c546b5cd24da96ceed23b9fdc90 (patch)
tree019957e835a99920ab7a027268433d7a8d0a8272
parentfc02b1b3eee7632049040a96b056d769a088b2ea (diff)
Also obfuscate the number of memory roots
-rw-r--r--src/nix-daemon/nix-daemon.cc18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/nix-daemon/nix-daemon.cc b/src/nix-daemon/nix-daemon.cc
index 014378d27e74..63b5eb87d9d2 100644
--- a/src/nix-daemon/nix-daemon.cc
+++ b/src/nix-daemon/nix-daemon.cc
@@ -478,15 +478,29 @@ static void performOp(TunnelLogger * logger, ref<Store> store,
         Roots roots = store->findRoots();
         logger->stopWork();
         size_t total_length = 0;
-        for (auto & root : roots)
-            total_length += root.second.size();
+        bool hasMemoryLink;
+        for (auto & [target, links] : roots) {
+            hasMemoryLink = false;
+            for (auto & link : links) {
+                if (link.rfind("{memory:", 0) == 0) {
+                    if (hasMemoryLink) continue;
+                    ++total_length;
+                    hasMemoryLink = true;
+                } else {
+                    ++total_length;
+                }
+            }
+        }
         to << total_length;
         int n = 0;
         for (auto & [target, links] : roots) {
+            bool hasMemoryLink = false;
             for (auto & link : links) {
                 // Obfuscate 'memory' roots as they expose information about other users,
                 if (link.rfind("{memory:", 0) == 0) {
+                    if (hasMemoryLink) continue;
                     to << fmt("{memory:%d}", n++) << target;
+                    hasMemoryLink = true;
                 } else {
                     to << link << target;
                 }