Commit f241fdfc authored by Roger Dingledine's avatar Roger Dingledine
Browse files

there is yet another dns-pending-conn-clobbering bug

somewhere


svn:r1354
parent df57d3ff
......@@ -237,6 +237,19 @@ void connection_dns_remove(connection_t *conn)
}
}
void assert_connection_edge_not_dns_pending(connection_t *conn) {
struct pending_connection_t *pend;
struct cached_resolve *resolve;
SPLAY_FOREACH(resolve, cache_tree, &cache_root) {
for(pend = resolve->pending_connections;
pend;
pend = pend->next) {
assert(pend->conn != conn);
}
}
}
/* Cancel all pending connections. Then cancel the resolve itself,
* and remove the 'struct cached_resolve' from the cache.
*/
......
......@@ -801,6 +801,7 @@ void dns_init(void);
int connection_dns_finished_flushing(connection_t *conn);
int connection_dns_process_inbuf(connection_t *conn);
void connection_dns_remove(connection_t *conn);
void assert_connection_edge_not_dns_pending(connection_t *conn);
void dns_cancel_pending_resolve(char *question);
int dns_resolve(connection_t *exitconn);
......
......@@ -357,10 +357,10 @@ int router_get_router_hash(const char *s, char *digest)
"router ","router-signature");
}
/* return 0 if myversion is in versionlist. Else return -1.
/* return 1 if myversion is in versionlist. Else return 0.
* (versionlist contains a comma-separated list of versions.) */
int compare_recommended_versions(const char *myversion,
const char *versionlist) {
int is_recommended_version(const char *myversion,
const char *versionlist) {
int len_myversion = strlen(myversion);
char *comma;
const char *end = versionlist + strlen(versionlist);
......@@ -372,9 +372,9 @@ int compare_recommended_versions(const char *myversion,
if( ((comma ? comma : end) - versionlist == len_myversion) &&
!strncmp(versionlist, myversion, len_myversion))
/* only do strncmp if the length matches */
return 0; /* success, it's there */
return 1; /* success, it's there */
if(!comma)
return -1; /* nope */
return 0; /* nope */
versionlist = comma+1;
}
}
......@@ -391,7 +391,8 @@ int router_set_routerlist_from_directory(const char *s, crypto_pk_env_t *pkey)
log_fn(LOG_WARN, "Error resolving routerlist");
return -1;
}
if (compare_recommended_versions(VERSION, routerlist->software_versions) < 0) {
if (is_recommended_version(VERSION,
routerlist->software_versions) < 0) {
log(options.IgnoreVersion ? LOG_WARN : LOG_ERR,
"You are running Tor version %s, which will not work with this network.\n"
"Please use %s%s.",
......
......@@ -611,7 +611,7 @@ test_onion_handshake() {
}
/* from routers.c */
int compare_recommended_versions(char *myversion, char *start);
int is_recommended_version(char *myversion, char *start);
void
test_dir_format()
......@@ -766,15 +766,15 @@ test_dir_format()
tor_free(dir1); /* And more !*/
tor_free(dir2); /* And more !*/
/* make sure compare_recommended_versions() works */
test_eq(0, compare_recommended_versions("abc", "abc"));
test_eq(0, compare_recommended_versions("abc", "ab,abd,abde,abc,abcde"));
test_eq(0, compare_recommended_versions("abc", "ab,abd,abde,abcde,abc"));
test_eq(0, compare_recommended_versions("abc", "abc,abd,abde,abc,abcde"));
test_eq(0, compare_recommended_versions("a", "a,ab,abd,abde,abc,abcde"));
test_eq(-1, compare_recommended_versions("a", "ab,abd,abde,abc,abcde"));
test_eq(-1, compare_recommended_versions("abb", "ab,abd,abde,abc,abcde"));
test_eq(-1, compare_recommended_versions("a", ""));
/* make sure is_recommended_version() works */
test_eq(1, is_recommended_version("abc", "abc"));
test_eq(1, is_recommended_version("abc", "ab,abd,abde,abc,abcde"));
test_eq(1, is_recommended_version("abc", "ab,abd,abde,abcde,abc"));
test_eq(1, is_recommended_version("abc", "abc,abd,abde,abc,abcde"));
test_eq(1, is_recommended_version("a", "a,ab,abd,abde,abc,abcde"));
test_eq(0, is_recommended_version("a", "ab,abd,abde,abc,abcde"));
test_eq(0, is_recommended_version("abb", "ab,abd,abde,abc,abcde"));
test_eq(0, is_recommended_version("a", ""));
}
int
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment