[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] [ernie/master] Fix integer overflow bug in torperf stats.
Author: Karsten Loesing <karsten.loesing@xxxxxxx>
Date: Sat, 27 Mar 2010 09:14:08 +0100
Subject: Fix integer overflow bug in torperf stats.
Commit: f261fb922cf1b98c792542eb0c2d554999e07e8a
---
src/TorperfProcessor.java | 13 ++++++++++---
1 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/src/TorperfProcessor.java b/src/TorperfProcessor.java
index d2bb050..b851249 100644
--- a/src/TorperfProcessor.java
+++ b/src/TorperfProcessor.java
@@ -23,6 +23,13 @@ public class TorperfProcessor {
break;
}
String key = line.substring(0, line.lastIndexOf(","));
+ if (line.substring(line.lastIndexOf(",") + 1).startsWith("-")) {
+ /* If completion time is negative, this is because we had an
+ * integer overflow bug. Fix this. */
+ long newValue = Long.parseLong(line.substring(
+ line.lastIndexOf(",") + 1)) + 100000000L;
+ line = key + "," + newValue;
+ }
rawObs.put(key, line);
}
br.close();
@@ -51,7 +58,7 @@ public class TorperfProcessor {
if (pop.isDirectory()) {
for (File f : pop.listFiles()) {
filesInInputDir.add(f);
- }
+ }
} else {
String source = pop.getName().substring(0,
pop.getName().indexOf("."));
@@ -69,9 +76,9 @@ public class TorperfProcessor {
long startSec = Long.parseLong(parts[0]);
String dateTime = formatter.format(
new Date(startSec * 1000L));
- long completeMillis = Long.parseLong(parts[16].substring(5))
+ long completeMillis = Long.parseLong(parts[16])
* 1000L + Long.parseLong(parts[17]) / 1000L
- - Long.parseLong(parts[0].substring(5)) * 1000L
+ - Long.parseLong(parts[0]) * 1000L
+ Long.parseLong(parts[1]) / 1000L;
String key = source + "," + dateTime;
String value = key + "," + completeMillis;
--
1.6.5