diff options
author | Nick Mathewson <nickm@torproject.org> | 2018-09-18 15:06:36 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2018-10-14 15:25:16 -0400 |
commit | 965549aa07d94a9f9e510cdb7a215bf9a3ed7bb8 (patch) | |
tree | 4a8a4fa21a4fba053eade245a341c39ed9c29a1d | |
parent | 7ace8d5a61f75fb77e3619deed417edd5610a4f1 (diff) | |
download | tor-965549aa07d94a9f9e510cdb7a215bf9a3ed7bb8.tar.gz tor-965549aa07d94a9f9e510cdb7a215bf9a3ed7bb8.zip |
Use assertions so GCC LTO doesn't worry about TLS channel conversion
Part of #27772
-rw-r--r-- | src/core/mainloop/connection.c | 11 | ||||
-rw-r--r-- | src/core/or/channel.c | 2 | ||||
-rw-r--r-- | src/core/or/channelpadding.c | 2 | ||||
-rw-r--r-- | src/core/or/scheduler_kist.c | 4 |
4 files changed, 14 insertions, 5 deletions
diff --git a/src/core/mainloop/connection.c b/src/core/mainloop/connection.c index 0c3abc8442..7e2c4ce406 100644 --- a/src/core/mainloop/connection.c +++ b/src/core/mainloop/connection.c @@ -656,14 +656,15 @@ connection_free_minimal(connection_t *conn) tor_free(or_conn->nickname); if (or_conn->chan) { /* Owww, this shouldn't happen, but... */ + channel_t *base_chan = TLS_CHAN_TO_BASE(or_conn->chan); + tor_assert(base_chan); log_info(LD_CHANNEL, "Freeing orconn at %p, saw channel %p with ID " "%"PRIu64 " left un-NULLed", - or_conn, TLS_CHAN_TO_BASE(or_conn->chan), - ( - TLS_CHAN_TO_BASE(or_conn->chan)->global_identifier)); - if (!CHANNEL_FINISHED(TLS_CHAN_TO_BASE(or_conn->chan))) { - channel_close_for_error(TLS_CHAN_TO_BASE(or_conn->chan)); + or_conn, base_chan, + base_chan->global_identifier); + if (!CHANNEL_FINISHED(base_chan)) { + channel_close_for_error(base_chan); } or_conn->chan->conn = NULL; diff --git a/src/core/or/channel.c b/src/core/or/channel.c index 0c204ddfb6..79c52235dc 100644 --- a/src/core/or/channel.c +++ b/src/core/or/channel.c @@ -3423,6 +3423,8 @@ channel_rsa_id_group_set_badness(struct channel_list_s *lst, int force) /* it would be more efficient to do a slice, but this case is rare */ smartlist_t *or_conns = smartlist_new(); SMARTLIST_FOREACH_BEGIN(channels, channel_t *, channel) { + tor_assert(channel); // Suppresses some compiler warnings. + if (!common_ed25519_identity) common_ed25519_identity = &channel->ed25519_identity; diff --git a/src/core/or/channelpadding.c b/src/core/or/channelpadding.c index 7c3a77f62c..d3d6890c0b 100644 --- a/src/core/or/channelpadding.c +++ b/src/core/or/channelpadding.c @@ -296,6 +296,7 @@ channelpadding_send_disable_command(channel_t *chan) channelpadding_negotiate_t disable; cell_t cell; + tor_assert(chan); tor_assert(BASE_CHAN_TO_TLS(chan)->conn->link_proto >= MIN_LINK_PROTO_FOR_CHANNEL_PADDING); @@ -328,6 +329,7 @@ channelpadding_send_enable_command(channel_t *chan, uint16_t low_timeout, channelpadding_negotiate_t enable; cell_t cell; + tor_assert(chan); tor_assert(BASE_CHAN_TO_TLS(chan)->conn->link_proto >= MIN_LINK_PROTO_FOR_CHANNEL_PADDING); diff --git a/src/core/or/scheduler_kist.c b/src/core/or/scheduler_kist.c index 41c346ac71..f112ea6357 100644 --- a/src/core/or/scheduler_kist.c +++ b/src/core/or/scheduler_kist.c @@ -116,6 +116,7 @@ static unsigned int kist_lite_mode = 1; static inline size_t channel_outbuf_length(channel_t *chan) { + tor_assert(chan); /* In theory, this can not happen because we can not scheduler a channel * without a connection that has its outbuf initialized. Just in case, bug * on this so we can understand a bit more why it happened. */ @@ -194,6 +195,8 @@ update_socket_info_impl, (socket_table_ent_t *ent)) { #ifdef HAVE_KIST_SUPPORT int64_t tcp_space, extra_space; + tor_assert(ent); + tor_assert(ent->chan); const tor_socket_t sock = TO_CONN(BASE_CHAN_TO_TLS((channel_t *) ent->chan)->conn)->s; struct tcp_info tcp; @@ -451,6 +454,7 @@ MOCK_IMPL(int, channel_should_write_to_kernel, * kernel */ MOCK_IMPL(void, channel_write_to_kernel, (channel_t *chan)) { + tor_assert(chan); log_debug(LD_SCHED, "Writing %lu bytes to kernel for chan %" PRIu64, (unsigned long)channel_outbuf_length(chan), chan->global_identifier); |