[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] there is yet another dns-pending-conn-clobbering bug



Update of /home/or/cvsroot/src/or
In directory moria.mit.edu:/home2/arma/work/onion/cvs/src/or

Modified Files:
	dns.c or.h routerlist.c test.c 
Log Message:
there is yet another dns-pending-conn-clobbering bug
somewhere


Index: dns.c
===================================================================
RCS file: /home/or/cvsroot/src/or/dns.c,v
retrieving revision 1.68
retrieving revision 1.69
diff -u -d -r1.68 -r1.69
--- dns.c	20 Mar 2004 09:30:30 -0000	1.68
+++ dns.c	28 Mar 2004 04:54:36 -0000	1.69
@@ -237,6 +237,19 @@
   }
 }
 
+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.
  */

Index: or.h
===================================================================
RCS file: /home/or/cvsroot/src/or/or.h,v
retrieving revision 1.257
retrieving revision 1.258
diff -u -d -r1.257 -r1.258
--- or.h	27 Mar 2004 05:45:52 -0000	1.257
+++ or.h	28 Mar 2004 04:54:36 -0000	1.258
@@ -801,6 +801,7 @@
 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);
 

Index: routerlist.c
===================================================================
RCS file: /home/or/cvsroot/src/or/routerlist.c,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -d -r1.40 -r1.41
--- routerlist.c	27 Mar 2004 00:13:27 -0000	1.40
+++ routerlist.c	28 Mar 2004 04:54:36 -0000	1.41
@@ -357,10 +357,10 @@
                               "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 @@
     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 @@
     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.",

Index: test.c
===================================================================
RCS file: /home/or/cvsroot/src/or/test.c,v
retrieving revision 1.65
retrieving revision 1.66
diff -u -d -r1.65 -r1.66
--- test.c	20 Mar 2004 01:21:19 -0000	1.65
+++ test.c	28 Mar 2004 04:54:36 -0000	1.66
@@ -611,7 +611,7 @@
 }
 
 /* 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 @@
   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