diff options
author | David Goulet <dgoulet@torproject.org> | 2019-07-25 10:27:41 -0400 |
---|---|---|
committer | David Goulet <dgoulet@torproject.org> | 2019-07-25 10:27:41 -0400 |
commit | 53ece8bd23f9f0d90c04d235c269cfdc3ecfb1e6 (patch) | |
tree | c9ef8661d75c1ce864d51876cc8aa7659008456f | |
parent | 530347972d847f314c8f9e18c822e142d251bd4e (diff) | |
parent | af26cd61015a2c127dbcf7e3db91da91adb415f9 (diff) | |
download | tor-53ece8bd23f9f0d90c04d235c269cfdc3ecfb1e6.tar.gz tor-53ece8bd23f9f0d90c04d235c269cfdc3ecfb1e6.zip |
Merge branch 'maint-0.4.1' into release-0.4.1
-rw-r--r-- | changes/bug31024 | 4 | ||||
-rw-r--r-- | changes/bug31027 | 3 | ||||
-rw-r--r-- | src/core/or/circuitpadding.c | 15 |
3 files changed, 17 insertions, 5 deletions
diff --git a/changes/bug31024 b/changes/bug31024 new file mode 100644 index 0000000000..888fb2a26b --- /dev/null +++ b/changes/bug31024 @@ -0,0 +1,4 @@ + o Minor bugfixes (circuitpadding): + - Add two NULL checks in unreachable places to silence Coverity (CID 144729 + and 1447291) and better future proof ourselves. Fixes bug 31024; bugfix + on 0.4.1.1-alpha.
\ No newline at end of file diff --git a/changes/bug31027 b/changes/bug31027 new file mode 100644 index 0000000000..dd3ce20b60 --- /dev/null +++ b/changes/bug31027 @@ -0,0 +1,3 @@ + o Code simplification and refactoring: + - Remove some dead code from circpad_machine_remove_token() to fix some + Coverity warnings (CID 1447298). Fixes bug 31027; bugfix on 0.4.1.1-alpha.
\ No newline at end of file diff --git a/src/core/or/circuitpadding.c b/src/core/or/circuitpadding.c index 0214cc4219..c4670bbc2f 100644 --- a/src/core/or/circuitpadding.c +++ b/src/core/or/circuitpadding.c @@ -450,6 +450,9 @@ circpad_is_token_removal_supported(circpad_machine_runtime_t *mi) /* Machines that do want token removal are less sensitive to performance. * Let's spend some time to check that our state is consistent and sane */ const circpad_state_t *state = circpad_machine_current_state(mi); + if (BUG(!state)) { + return 1; + } tor_assert_nonfatal(state->token_removal != CIRCPAD_TOKEN_REMOVAL_NONE); tor_assert_nonfatal(state->histogram_len == mi->histogram_len); tor_assert_nonfatal(mi->histogram_len != 0); @@ -1083,8 +1086,11 @@ circpad_machine_remove_token(circpad_machine_runtime_t *mi) state = circpad_machine_current_state(mi); + /* If we are not in a padding state (like start or end), we're done */ + if (!state) + return; /* Don't remove any tokens if we're not doing token removal */ - if (!state || state->token_removal == CIRCPAD_TOKEN_REMOVAL_NONE) + if (state->token_removal == CIRCPAD_TOKEN_REMOVAL_NONE) return; current_time = monotime_absolute_usec(); @@ -1103,10 +1109,6 @@ circpad_machine_remove_token(circpad_machine_runtime_t *mi) timer_disable(mi->padding_timer); } - /* If we are not in a padding state (like start or end), we're done */ - if (!state) - return; - /* Perform the specified token removal strategy */ switch (state->token_removal) { case CIRCPAD_TOKEN_REMOVAL_CLOSEST_USEC: @@ -1668,6 +1670,9 @@ circpad_estimate_circ_rtt_on_received(circuit_t *circ, } } else { const circpad_state_t *state = circpad_machine_current_state(mi); + if (BUG(!state)) { + return; + } /* Since monotime is unpredictably expensive, only update this field * if rtt estimates are needed. Otherwise, stop the rtt update. */ |