[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] fix some xxxs.
Update of /home/or/cvsroot/tor/src/or
In directory moria:/tmp/cvs-serv7484/src/or
Modified Files:
dirserv.c or.h routerlist.c routerparse.c
Log Message:
fix some xxxs.
Index: dirserv.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/dirserv.c,v
retrieving revision 1.321
retrieving revision 1.322
diff -u -p -d -r1.321 -r1.322
--- dirserv.c 2 Apr 2006 23:01:01 -0000 1.321
+++ dirserv.c 3 Apr 2006 06:23:24 -0000 1.322
@@ -736,7 +736,7 @@ format_versions_list(config_line_t *ln)
smartlist_split_string(versions, ln->value, ",",
SPLIT_SKIP_SPACE|SPLIT_IGNORE_BLANK, 0);
}
- sort_version_list(versions);
+ sort_version_list(versions, 1);
result = smartlist_join_strings(versions,",",0,NULL);
SMARTLIST_FOREACH(versions,char *,s,tor_free(s));
smartlist_free(versions);
Index: or.h
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/or.h,v
retrieving revision 1.818
retrieving revision 1.819
diff -u -p -d -r1.818 -r1.819
--- or.h 1 Apr 2006 22:00:49 -0000 1.818
+++ or.h 3 Apr 2006 06:23:24 -0000 1.819
@@ -2435,7 +2435,7 @@ version_status_t version_status_join(ver
int tor_version_parse(const char *s, tor_version_t *out);
int tor_version_as_new_as(const char *platform, const char *cutoff);
int tor_version_compare(tor_version_t *a, tor_version_t *b);
-void sort_version_list(smartlist_t *lst);
+void sort_version_list(smartlist_t *lst, int remove_duplicates);
void assert_addr_policy_ok(addr_policy_t *t);
networkstatus_t *networkstatus_parse_from_string(const char *s);
Index: routerlist.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/routerlist.c,v
retrieving revision 1.479
retrieving revision 1.480
diff -u -p -d -r1.479 -r1.480
--- routerlist.c 3 Apr 2006 06:22:54 -0000 1.479
+++ routerlist.c 3 Apr 2006 06:23:24 -0000 1.480
@@ -1481,8 +1481,6 @@ router_set_status(const char *digest, in
* This function should be called *after*
* routers_update_status_from_networkstatus; subsequently, you should call
* router_rebuild_store and control_event_descriptors_changed.
- *
- * XXXX never replace your own descriptor.
*/
int
router_add_to_routerlist(routerinfo_t *router, const char **msg,
@@ -1547,6 +1545,13 @@ router_add_to_routerlist(routerinfo_t *r
rs->need_to_mirror = 0;
});
+ /* Probably, there's no way to actually pass this function our own
+ * descriptor, but in case there is, don't replace our own descriptor. */
+ if (router_is_me(router)) {
+ routerinfo_free(router);
+ return 0;
+ }
+
/* If we have a router with this name, and the identity key is the same,
* choose the newer one. If the identity key has changed, and one of the
* routers is named, drop the unnamed ones. (If more than one are named,
@@ -2606,6 +2611,8 @@ compute_recommended_versions(time_t now,
SMARTLIST_FOREACH(networkstatus_list, networkstatus_t *, ns,
{
const char *vers;
+ smartlist_t *versions;
+ int i;
if (! ns->recommends_versions)
continue;
if (ns->received_on + SELF_OPINION_INTERVAL < now)
@@ -2614,13 +2621,13 @@ compute_recommended_versions(time_t now,
vers = client ? ns->client_versions : ns->server_versions;
if (!vers)
continue;
- /* XXX Attack: a single dirserver can make a version recommended
- * by repeating it many times in his recommended list. -RD */
- smartlist_split_string(combined, vers, ",",
+ versions = smartlist_create();
+ smartlist_split_string(versions, vers, ",",
SPLIT_SKIP_SPACE|SPLIT_IGNORE_BLANK, 0);
+ sort_version_list(versions, 1);
});
- sort_version_list(combined);
+ sort_version_list(combined, 0);
current = NULL;
n_seen = 0;
@@ -2733,7 +2740,6 @@ routers_update_all_from_networkstatus(vo
}
});
if (n_recent > 2 && n_recommended < n_recent/2) {
-/* XXX Should this be n_recommended <= n_recent/2 ? -RD */
if (consensus == VS_NEW || consensus == VS_NEW_IN_SERIES) {
if (!have_warned_about_new_version) {
char *rec = compute_recommended_versions(now, !is_server);
Index: routerparse.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/routerparse.c,v
retrieving revision 1.179
retrieving revision 1.180
diff -u -p -d -r1.179 -r1.180
--- routerparse.c 27 Mar 2006 02:25:34 -0000 1.179
+++ routerparse.c 3 Apr 2006 06:23:24 -0000 1.180
@@ -1926,8 +1926,24 @@ _compare_tor_version_str_ptr(const void
/** Sort a list of string-representations of versions in ascending order. */
void
-sort_version_list(smartlist_t *versions)
+sort_version_list(smartlist_t *versions, int remove_duplicates)
{
+ int i;
+
smartlist_sort(versions, _compare_tor_version_str_ptr);
+ if (!remove_duplicates)
+ return;
+
+ for (i = 1; i < smartlist_len(versions); ++i) {
+ void *a, *b;
+ a = smartlist_get(versions, i-1);
+ b = smartlist_get(versions, i);
+ /* use version_cmp so we catch multiple representations of the same
+ * version */
+ if (_compare_tor_version_str_ptr(a,b) == 0) {
+ tor_free(smartlist_get(versions, i));
+ smartlist_del(versions, i--);
+ }
+ }
}