Browse Source

Do not call tor_tls_server_info_callback(NULL) from tests.

This isn't valid behavior, and it causes a crash when you run
the unit tests at --debug.

I've added an IF_BUG_ONCE() check for this case.
Nick Mathewson 7 years ago
parent
commit
69dce09031
2 changed files with 4 additions and 2 deletions
  1. 4 0
      src/common/tortls.c
  2. 0 2
      src/test/test_tortls.c

+ 4 - 0
src/common/tortls.c

@@ -1489,6 +1489,10 @@ tor_tls_server_info_callback(const SSL *ssl, int type, int val)
   tor_tls_t *tls;
   (void) val;
 
+  IF_BUG_ONCE(ssl == NULL) {
+    return; // LCOV_EXCL_LINE
+  }
+
   tor_tls_debug_state_callback(ssl, type, val);
 
   if (type != SSL_CB_ACCEPT_LOOP)

+ 0 - 2
src/test/test_tortls.c

@@ -1831,8 +1831,6 @@ test_tortls_server_info_callback(void *ignored)
   tls->magic = TOR_TLS_MAGIC;
   tls->ssl = ssl;
 
-  tor_tls_server_info_callback(NULL, 0, 0);
-
   SSL_set_state(ssl, SSL3_ST_SW_SRVR_HELLO_A);
   mock_clean_saved_logs();
   tor_tls_server_info_callback(ssl, SSL_CB_ACCEPT_LOOP, 0);