Browse Source

Merge remote-tracking branch 'sebastian/bug15211'

Nick Mathewson 10 years ago
parent
commit
833b6d30be
4 changed files with 15 additions and 6 deletions
  1. 6 0
      changes/bug15211
  2. 5 3
      src/common/compat_pthreads.c
  3. 2 2
      src/or/control.c
  4. 2 1
      src/or/rendservice.c

+ 6 - 0
changes/bug15211

@@ -0,0 +1,6 @@
+  o Minor bugfixes:
+    - Remove side-effects from tor_assert() calls. This was harmless,
+      because we never disable assertions, but it is bad style and
+      unnecessary. Fixes bug 15211; bugfix on 0.2.5.5, 0.2.2.36, and
+      0.2.0.10.
+

+ 5 - 3
src/common/compat_pthreads.c

@@ -276,14 +276,16 @@ void
 tor_threads_init(void)
 tor_threads_init(void)
 {
 {
   if (!threads_initialized) {
   if (!threads_initialized) {
+    int ret;
     pthread_mutexattr_init(&attr_recursive);
     pthread_mutexattr_init(&attr_recursive);
     pthread_mutexattr_settype(&attr_recursive, PTHREAD_MUTEX_RECURSIVE);
     pthread_mutexattr_settype(&attr_recursive, PTHREAD_MUTEX_RECURSIVE);
-    tor_assert(0==pthread_attr_init(&attr_detached));
+    ret = pthread_attr_init(&attr_detached);
+    tor_assert(ret == 0);
 #ifndef PTHREAD_CREATE_DETACHED
 #ifndef PTHREAD_CREATE_DETACHED
 #define PTHREAD_CREATE_DETACHED 1
 #define PTHREAD_CREATE_DETACHED 1
 #endif
 #endif
-    tor_assert(0==pthread_attr_setdetachstate(&attr_detached,
-                                              PTHREAD_CREATE_DETACHED));
+    ret = pthread_attr_setdetachstate(&attr_detached, PTHREAD_CREATE_DETACHED);
+    tor_assert(ret == 0);
     threads_initialized = 1;
     threads_initialized = 1;
     set_main_thread();
     set_main_thread();
   }
   }

+ 2 - 2
src/or/control.c

@@ -3102,8 +3102,8 @@ handle_control_authchallenge(control_connection_t *conn, uint32_t len,
     tor_free(client_nonce);
     tor_free(client_nonce);
     return -1;
     return -1;
   }
   }
-
-  tor_assert(!crypto_rand(server_nonce, SAFECOOKIE_SERVER_NONCE_LEN));
+  int fail = crypto_rand(server_nonce, SAFECOOKIE_SERVER_NONCE_LEN);
+  tor_assert(!fail);
 
 
   /* Now compute and send the server-to-controller response, and the
   /* Now compute and send the server-to-controller response, and the
    * server's nonce. */
    * server's nonce. */

+ 2 - 1
src/or/rendservice.c

@@ -3320,7 +3320,8 @@ rend_services_introduce(void)
       intro = tor_malloc_zero(sizeof(rend_intro_point_t));
       intro = tor_malloc_zero(sizeof(rend_intro_point_t));
       intro->extend_info = extend_info_from_node(node, 0);
       intro->extend_info = extend_info_from_node(node, 0);
       intro->intro_key = crypto_pk_new();
       intro->intro_key = crypto_pk_new();
-      tor_assert(!crypto_pk_generate_key(intro->intro_key));
+      int fail = crypto_pk_generate_key(intro->intro_key);
+      tor_assert(!fail);
       intro->time_published = -1;
       intro->time_published = -1;
       intro->time_to_expire = -1;
       intro->time_to_expire = -1;
       intro->time_expiring = -1;
       intro->time_expiring = -1;