[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] [metrics-utils/master] Fix parsing of accept/reject lines with port ranges.



Author: Karsten Loesing <karsten.loesing@xxxxxxx>
Date: Fri, 12 Nov 2010 16:24:26 +0100
Subject: Fix parsing of accept/reject lines with port ranges.
Commit: e54493cec2b95fbfd8fced5681513e529c07238b

Note that exonerator.py still has the same bug!
---
 exonerator/ChangeLog       |    8 ++++++++
 exonerator/ExoneraTor.java |   12 ++++++++++++
 2 files changed, 20 insertions(+), 0 deletions(-)
 create mode 100644 exonerator/ChangeLog

diff --git a/exonerator/ChangeLog b/exonerator/ChangeLog
new file mode 100644
index 0000000..158f577
--- /dev/null
+++ b/exonerator/ChangeLog
@@ -0,0 +1,8 @@
+ExoneraTor change log:
+
+Changes in version 0.0.2 - 2010-11-??
+  - Fix parsing of accept/reject lines with port ranges.
+
+Changes in version 0.0.1 - 2010-09-22
+  - Initial release
+
diff --git a/exonerator/ExoneraTor.java b/exonerator/ExoneraTor.java
index eba3cca..f207a7b 100644
--- a/exonerator/ExoneraTor.java
+++ b/exonerator/ExoneraTor.java
@@ -291,8 +291,20 @@ public final class ExoneraTor {
                       !rulePort.equals("*"))
                     continue; // with no port given, we only consider
                               // reject :* rules as matching
+                  if (targetPort != null && !rulePort.equals("*") &&
+                      rulePort.contains("-")) {
+                    int fromPort = Integer.parseInt(
+                        rulePort.split("-")[0]);
+                    int toPort = Integer.parseInt(rulePort.split("-")[1]);
+                    int targetPortInt = Integer.parseInt(targetPort);
+                    if (targetPortInt < fromPort ||
+                        targetPortInt > toPort) {
+                      continue; // port not contained in interval
+                    }
+                  }
                   if (targetPort != null) {
                     if (!rulePort.equals("*") &&
+                        !rulePort.contains("-") &&
                         !targetPort.equals(rulePort))
                       continue; // ports do not match
                   }
-- 
1.7.1