[tor-commits] [stem/master] Allowing extra-info dirreq-v*-share to be above 100%

atagar at torproject.org atagar at torproject.org
Tue Jul 10 15:26:25 UTC 2012


commit 611e75dbeb5a81a655ca0f8ec1b4495850c3459a
Author: Damian Johnson <atagar at torproject.org>
Date:   Tue Jul 10 08:22:55 2012 -0700

    Allowing extra-info dirreq-v*-share to be above 100%
    
    Spotted an extra-info descriptor with dirreq-v2-share and dirreq-v3-share
    values over 100%...
    https://lists.torproject.org/pipermail/tor-dev/2012-June/003679.html
    
    Karsten suggested simply removing the restriction on this field's upper bound
    since it's soon going away.
---
 stem/descriptor/extrainfo_descriptor.py      |    7 +++++--
 test/unit/descriptor/extrainfo_descriptor.py |    1 -
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/stem/descriptor/extrainfo_descriptor.py b/stem/descriptor/extrainfo_descriptor.py
index 366279c..be2a6dc 100644
--- a/stem/descriptor/extrainfo_descriptor.py
+++ b/stem/descriptor/extrainfo_descriptor.py
@@ -488,8 +488,11 @@ class ExtraInfoDescriptor(stem.descriptor.Descriptor):
           if not value.endswith("%"): raise ValueError()
           percentage = float(value[:-1]) / 100
           
-          if validate and (percentage > 1 or percentage < 0):
-            raise ValueError()
+          # Bug lets these be above 100%, however they're soon going away...
+          # https://lists.torproject.org/pipermail/tor-dev/2012-June/003679.html
+          
+          if validate and percentage < 0:
+            raise ValueError("Negative percentage value: %s" % line)
           
           if keyword == "dirreq-v2-share":
             self.dir_v2_share = percentage
diff --git a/test/unit/descriptor/extrainfo_descriptor.py b/test/unit/descriptor/extrainfo_descriptor.py
index a3590ee..c40ac94 100644
--- a/test/unit/descriptor/extrainfo_descriptor.py
+++ b/test/unit/descriptor/extrainfo_descriptor.py
@@ -305,7 +305,6 @@ class TestExtraInfoDescriptor(unittest.TestCase):
         ("", None),
         (" ", None),
         ("100", None),
-        ("100.1%", 1.001),
         ("-5%", -0.05),
       )
       



More information about the tor-commits mailing list