[tor-bugs] #20224 [Metrics/CollecTor]: Fix `BridgeDescriptorMappingsLimit` config option
Tor Bug Tracker & Wiki
blackhole at torproject.org
Fri Sep 23 07:57:04 UTC 2016
#20224: Fix `BridgeDescriptorMappingsLimit` config option
-----------------------------------+-----------------
Reporter: karsten | Owner:
Type: defect | Status: new
Priority: Low | Milestone:
Component: Metrics/CollecTor | Version:
Severity: Normal | Keywords:
Actual Points: | Parent ID:
Points: | Reviewer:
Sponsor: |
-----------------------------------+-----------------
The `BridgeDescriptorMappingsLimit` option doesn't work as expected with
its default value `inf` or with other sufficiently large values. Here's
where that configuration value is used
(https://gitweb.torproject.org/collector.git/tree/src/main/java/org/torproject/collector/bridgedescs/SanitizedBridgesWriter.java#n183):
{{{
this.bridgeSanitizingCutOffTimestamp = formatter.format(
System.currentTimeMillis() - 24L * 60L * 60L * 1000L
* limitBridgeSanitizingInterval);
}}}
For `limitBridgeSanitizingInterval = Integer.MAX_VALUE`, we'd try to
format `1474617184667 - 86400000 * 2147483647 = -1.855E+017` milliseconds
since the epoch. In theory, that large negative value should still fit
into the `long`, but somehow it gets formatted as `5877475-11-25
07:53:04`, which is in the future rather than in the past.
Anyway, I stopped digging what the exact bug might be, and instead suggest
this possible fix:
{{{
diff --git
a/src/main/java/org/torproject/collector/bridgedescs/SanitizedBridgesWriter.java
b/src/main/java/org/torproject/collector/bridgedescs/SanitizedBridgesWriter.java
index b61cd30..b8674a3 100644
---
a/src/main/java/org/torproject/collector/bridgedescs/SanitizedBridgesWriter.java
+++
b/src/main/java/org/torproject/collector/bridgedescs/SanitizedBridgesWriter.java
@@ -180,9 +180,9 @@ public class SanitizedBridgesWriter extends
CollecTorMain {
SimpleDateFormat formatter = new SimpleDateFormat(
"yyyy-MM-dd HH:mm:ss");
formatter.setTimeZone(TimeZone.getTimeZone("UTC"));
- this.bridgeSanitizingCutOffTimestamp = formatter.format(
+ this.bridgeSanitizingCutOffTimestamp =
formatter.format(Math.max(-1L,
System.currentTimeMillis() - 24L * 60L * 60L * 1000L
- * limitBridgeSanitizingInterval);
+ * limitBridgeSanitizingInterval));
} else {
this.bridgeSanitizingCutOffTimestamp = "1999-12-31 23:59:59";
}
}}}
--
Ticket URL: <https://trac.torproject.org/projects/tor/ticket/20224>
Tor Bug Tracker & Wiki <https://trac.torproject.org/>
The Tor Project: anonymity online
More information about the tor-bugs
mailing list