[tor-commits] [tor/release-0.2.4] FIx undefined behavior in dirvote.c

arma at torproject.org arma at torproject.org
Fri Jul 19 03:36:14 UTC 2013


commit 15cd79f83232d8be84992f809cd1951939d1d5ee
Author: Nick Mathewson <nickm at torproject.org>
Date:   Wed Jul 3 12:01:37 2013 -0400

    FIx undefined behavior in dirvote.c
    
     Fix a bug in the voting algorithm that could yield incorrect results
     when a non-naming authority declared too many flags. Fixes bug 9200;
     bugfix on 0.2.0.3-alpha.
    
    Found by coverity scan.
---
 changes/bug9200  |    5 +++++
 src/or/dirvote.c |    3 ++-
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/changes/bug9200 b/changes/bug9200
new file mode 100644
index 0000000..7b64dd1
--- /dev/null
+++ b/changes/bug9200
@@ -0,0 +1,5 @@
+  o Major bugfixes:
+    - Fix a bug in the voting algorithm that could yield incorrect results
+      when a non-naming authority declared too many flags. Fixes bug 9200;
+      bugfix on 0.2.0.3-alpha.
+
diff --git a/src/or/dirvote.c b/src/or/dirvote.c
index 0c386e6..7537fb8 100644
--- a/src/or/dirvote.c
+++ b/src/or/dirvote.c
@@ -1727,7 +1727,8 @@ networkstatus_compute_consensus(smartlist_t *votes,
           if (rs->flags & (U64_LITERAL(1) << i))
             ++flag_counts[flag_map[v_sl_idx][i]];
         }
-        if (rs->flags & (U64_LITERAL(1) << named_flag[v_sl_idx])) {
+        if (named_flag[v_sl_idx] >= 0 &&
+            (rs->flags & (U64_LITERAL(1) << named_flag[v_sl_idx]))) {
           if (chosen_name && strcmp(chosen_name, rs->status.nickname)) {
             log_notice(LD_DIR, "Conflict on naming for router: %s vs %s",
                        chosen_name, rs->status.nickname);





More information about the tor-commits mailing list