~ubuntu-branches/ubuntu/quantal/tor/quantal

« back to all changes in this revision

Viewing changes to src/or/networkstatus.c

  • Committer: Package Import Robot
  • Author(s): Peter Palfrader
  • Date: 2012-08-07 23:13:18 UTC
  • mfrom: (22.1.12 sid)
  • Revision ID: package-import@ubuntu.com-20120807231318-9suzjzhez9xj8arz
Tags: 0.2.3.20-rc-1
* New upstream version, including a couple security fixes:
  - Avoid read-from-freed-memory and double-free bugs that could occur
    when a DNS request fails while launching it. Fixes bug 6480.
  - Avoid an uninitialized memory read when reading a vote or consensus
    document that has an unrecognized flavor name. This read could
    lead to a remote crash bug. Fixes bug 6530.
  - Try to leak less information about what relays a client is
    choosing to a side-channel attacker.
* Suggest the tor-arm controller.
* Improve long descriptions with Roger's help.
* Use https:// instead of git:// for the Vcs-Git URL.

Show diffs side-by-side

added added

removed removed

Lines of Context:
128
128
{
129
129
  int i;
130
130
  const smartlist_t *networkstatus_v2_list = networkstatus_get_v2_list();
131
 
  SMARTLIST_FOREACH(networkstatus_v2_list, networkstatus_v2_t *, ns,
132
 
     SMARTLIST_FOREACH(ns->entries, routerstatus_t *, rs,
133
 
       {
 
131
  SMARTLIST_FOREACH_BEGIN(networkstatus_v2_list, networkstatus_v2_t *, ns) {
 
132
    SMARTLIST_FOREACH_BEGIN(ns->entries, routerstatus_t *, rs) {
134
133
         if (!router_get_by_descriptor_digest(rs->descriptor_digest))
135
134
           rs->need_to_mirror = 1;
136
 
       }));;
 
135
    } SMARTLIST_FOREACH_END(rs);
 
136
  } SMARTLIST_FOREACH_END(ns);
137
137
 
138
138
  for (i=0; i < N_CONSENSUS_FLAVORS; ++i)
139
139
    download_status_reset(&consensus_dl_status[i]);
177
177
    return 0;
178
178
  }
179
179
  tor_free(filename);
180
 
  SMARTLIST_FOREACH(entries, const char *, fn, {
 
180
  SMARTLIST_FOREACH_BEGIN(entries, const char *, fn) {
181
181
      char buf[DIGEST_LEN];
182
182
      if (maybe_delete) {
183
183
        filename = get_datadir_fname2("cached-status", fn);
201
201
        tor_free(s);
202
202
      }
203
203
      tor_free(filename);
204
 
    });
 
204
  } SMARTLIST_FOREACH_END(fn);
205
205
  SMARTLIST_FOREACH(entries, char *, fn, tor_free(fn));
206
206
  smartlist_free(entries);
207
207
  networkstatus_v2_list_clean(time(NULL));
881
881
 
882
882
  {
883
883
    time_t live_until = ns->published_on + V2_NETWORKSTATUS_ROUTER_LIFETIME;
884
 
    SMARTLIST_FOREACH(ns->entries, routerstatus_t *, rs,
885
 
    {
 
884
    SMARTLIST_FOREACH_BEGIN(ns->entries, routerstatus_t *, rs) {
886
885
      signed_descriptor_t *sd =
887
886
        router_get_by_descriptor_digest(rs->descriptor_digest);
888
887
      if (sd) {
891
890
      } else {
892
891
        rs->need_to_mirror = 1;
893
892
      }
894
 
    });
 
893
    } SMARTLIST_FOREACH_END(rs);
895
894
  }
896
895
 
897
896
  log_info(LD_DIR, "Setting networkstatus %s %s (published %s)",
2014
2013
  named_server_map = strmap_new();
2015
2014
  strmap_free(unnamed_server_map, NULL);
2016
2015
  unnamed_server_map = strmap_new();
2017
 
  SMARTLIST_FOREACH(current_consensus->routerstatus_list,
2018
 
                                                   const routerstatus_t *, rs,
2019
 
    {
 
2016
  SMARTLIST_FOREACH_BEGIN(current_consensus->routerstatus_list,
 
2017
                          const routerstatus_t *, rs) {
2020
2018
      if (rs->is_named) {
2021
2019
        strmap_set_lc(named_server_map, rs->nickname,
2022
2020
                      tor_memdup(rs->identity_digest, DIGEST_LEN));
2024
2022
      if (rs->is_unnamed) {
2025
2023
        strmap_set_lc(unnamed_server_map, rs->nickname, (void*)1);
2026
2024
      }
2027
 
    });
 
2025
  } SMARTLIST_FOREACH_END(rs);
2028
2026
}
2029
2027
 
2030
2028
/** Given a list <b>routers</b> of routerinfo_t *, update each status field
2082
2080
  } SMARTLIST_FOREACH_JOIN_END(rs, router);
2083
2081
 
2084
2082
  /* Now update last_listed_as_valid_until from v2 networkstatuses. */
2085
 
  SMARTLIST_FOREACH(networkstatus_v2_list, networkstatus_v2_t *, ns, {
 
2083
  SMARTLIST_FOREACH_BEGIN(networkstatus_v2_list, networkstatus_v2_t *, ns) {
2086
2084
    time_t live_until = ns->published_on + V2_NETWORKSTATUS_ROUTER_LIFETIME;
2087
2085
    SMARTLIST_FOREACH_JOIN(ns->entries, const routerstatus_t *, rs,
2088
2086
                         routers, routerinfo_t *, ri,
2095
2093
          ri->cache_info.last_listed_as_valid_until = live_until;
2096
2094
      }
2097
2095
    } SMARTLIST_FOREACH_JOIN_END(rs, ri);
2098
 
  });
 
2096
  } SMARTLIST_FOREACH_END(ns);
2099
2097
 
2100
2098
  router_dir_info_changed();
2101
2099
}
2162
2160
  }
2163
2161
 
2164
2162
  statuses = smartlist_new();
2165
 
  SMARTLIST_FOREACH(rl->routers, routerinfo_t *, ri, {
 
2163
  SMARTLIST_FOREACH_BEGIN(rl->routers, routerinfo_t *, ri) {
2166
2164
    node_t *node = node_get_mutable_by_id(ri->cache_info.identity_digest);
2167
2165
    if (!node)
2168
2166
      continue;
2175
2173
    /* then generate and write out status lines for each of them */
2176
2174
    set_routerstatus_from_routerinfo(&rs, node, ri, now, 0, 0, 0, 0);
2177
2175
    smartlist_add(statuses, networkstatus_getinfo_helper_single(&rs));
2178
 
  });
 
2176
  } SMARTLIST_FOREACH_END(ri);
2179
2177
 
2180
2178
  answer = smartlist_join_strings(statuses, "", 0, NULL);
2181
2179
  SMARTLIST_FOREACH(statuses, char *, cp, tor_free(cp));