浏览代码

Avoid crashing if we call num_usable_bridges() when bridges are not enabled

This applies the changes in 23524 to num_usable_bridges(), because it has
replaced any_bridge_descriptors_known().

The original changes file still applies.
teor 6 年之前
父节点
当前提交
d7833c9d27
共有 1 个文件被更改,包括 6 次插入2 次删除
  1. 6 2
      src/or/entrynodes.c

+ 6 - 2
src/or/entrynodes.c

@@ -3145,9 +3145,13 @@ num_bridges_usable,(void))
 {
   int n_options = 0;
 
-  tor_assert(get_options()->UseBridges);
+  if (BUG(!get_options()->UseBridges)) {
+    return 0;
+  }
   guard_selection_t *gs  = get_guard_selection_info();
-  tor_assert(gs->type == GS_TYPE_BRIDGE);
+  if (BUG(gs->type != GS_TYPE_BRIDGE)) {
+    return 0;
+  }
 
   SMARTLIST_FOREACH_BEGIN(gs->sampled_entry_guards, entry_guard_t *, guard) {
     if (guard->is_reachable == GUARD_REACHABLE_NO)