commit 5986188f93d897ba58dc56ad16d761b986471717 Author: Karsten Loesing karsten.loesing@gmx.net Date: Tue Dec 27 16:33:08 2011 +0100
Check bridge stats in sanitized bridge descriptors.
Make sure that there's always a bridge-stats-end line preceding the bridge-ips line.
We should add more such checks in the future. This is probably something to implement in metrics-lib once it's more stable. --- .../ernie/db/SanitizedBridgesWriter.java | 18 ++++++++++++++++-- 1 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/src/org/torproject/ernie/db/SanitizedBridgesWriter.java b/src/org/torproject/ernie/db/SanitizedBridgesWriter.java index 7376e5a..520fd1f 100644 --- a/src/org/torproject/ernie/db/SanitizedBridgesWriter.java +++ b/src/org/torproject/ernie/db/SanitizedBridgesWriter.java @@ -787,6 +787,7 @@ public class SanitizedBridgesWriter { String line = null; StringBuilder scrubbed = null; String hashedBridgeIdentity = null; + boolean hasParsedBridgeStatsEndLine = false; while ((line = br.readLine()) != null) {
/* When we have parsed both published and fingerprint line, look @@ -828,14 +829,27 @@ public class SanitizedBridgesWriter { this.haveWarnedAboutLimitedMapping = true; }
+ /* Write bridge-stats lines unmodified to the sanitized + * descriptor and make sure that there's always a bridge-stats-end + * line preceding the bridge-ips line. */ + } else if (line.startsWith("bridge-stats-end ")) { + scrubbed.append(line + "\n"); + hasParsedBridgeStatsEndLine = true; + } else if (line.startsWith("bridge-ips ")) { + if (!hasParsedBridgeStatsEndLine) { + this.logger.fine("bridge-ips line without preceding " + + "bridge-stats-end line in bridge descriptor. " + + "Skipping."); + return; + } + scrubbed.append(line + "\n"); + /* Write the following lines unmodified to the sanitized * descriptor. */ } else if (line.startsWith("write-history ") || line.startsWith("read-history ") || line.startsWith("geoip-start-time ") || line.startsWith("geoip-client-origins ") - || line.startsWith("bridge-stats-end ") - || line.startsWith("bridge-ips ") || line.startsWith("geoip-db-digest ")) { scrubbed.append(line + "\n");
tor-commits@lists.torproject.org