summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/core/or/conflux.c8
-rw-r--r--src/core/or/conflux_pool.c44
-rw-r--r--src/core/or/relay.c3
-rw-r--r--src/ext/equix/hashx/src/compiler_a64.c2
-rw-r--r--src/ext/equix/hashx/src/program.c10
-rw-r--r--src/ext/equix/src/lib.rs2
-rw-r--r--src/lib/compress/compress_zstd.c14
-rwxr-xr-xsrc/test/test_rebind.sh1
8 files changed, 23 insertions, 61 deletions
diff --git a/src/core/or/conflux.c b/src/core/or/conflux.c
index eb004b3626..ab464f3446 100644
--- a/src/core/or/conflux.c
+++ b/src/core/or/conflux.c
@@ -467,8 +467,12 @@ conflux_decide_circ_for_send(conflux_t *cfx,
* so these commands arrive in-order. */
if (!new_circ && relay_command != RELAY_COMMAND_DATA) {
/* Curr leg should be set, because conflux_decide_next_circ() should
- * have set it earlier. */
- tor_assert(cfx->curr_leg);
+ * have set it earlier. No BUG() here because the only caller BUG()s. */
+ if (!cfx->curr_leg) {
+ log_warn(LD_BUG, "No current leg for conflux with relay command %d",
+ relay_command);
+ return NULL;
+ }
return cfx->curr_leg->circ;
}
diff --git a/src/core/or/conflux_pool.c b/src/core/or/conflux_pool.c
index 837c1da720..79fd6c1648 100644
--- a/src/core/or/conflux_pool.c
+++ b/src/core/or/conflux_pool.c
@@ -1509,49 +1509,6 @@ linked_update_stream_backpointers(circuit_t *circ)
}
}
-/** This is called when this circuit is the last leg.
- *
- * The "on_circuit" pointer is nullified here so it is not given back to the
- * conflux subsytem between the circuit mark for close step and actually
- * freeing the circuit which is when streams are destroyed.
- *
- * Reason is that when the connection edge inbuf is packaged in
- * connection_edge_package_raw_inbuf(), the on_circuit pointer is used and
- * then passed on to conflux to learn which leg to use. However, if the circuit
- * was marked prior but not yet freed, there are no more legs remaining which
- * leads to a linked circuit being used without legs. No bueno. */
-static void
-linked_detach_circuit(circuit_t *circ)
-{
- tor_assert(circ);
- tor_assert_nonfatal(circ->conflux);
-
- if (CIRCUIT_IS_ORIGIN(circ)) {
- origin_circuit_t *ocirc = TO_ORIGIN_CIRCUIT(circ);
- tor_assert_nonfatal(circ->purpose == CIRCUIT_PURPOSE_CONFLUX_LINKED);
- /* Iterate over stream list using next_stream pointer, until null */
- for (edge_connection_t *stream = ocirc->p_streams; stream;
- stream = stream->next_stream) {
- /* Update the circuit pointer of each stream */
- stream->on_circuit = NULL;
- }
- } else {
- or_circuit_t *orcirc = TO_OR_CIRCUIT(circ);
- /* Iterate over stream list using next_stream pointer, until null */
- for (edge_connection_t *stream = orcirc->n_streams; stream;
- stream = stream->next_stream) {
- /* Update the circuit pointer of each stream */
- stream->on_circuit = NULL;
- }
- /* Iterate over stream list using next_stream pointer, until null */
- for (edge_connection_t *stream = orcirc->resolving_streams; stream;
- stream = stream->next_stream) {
- /* Update the circuit pointer of each stream */
- stream->on_circuit = NULL;
- }
- }
-}
-
/** Nullify all streams of the given circuit. */
static void
linked_nullify_streams(circuit_t *circ)
@@ -1592,7 +1549,6 @@ linked_circuit_closed(circuit_t *circ)
if (CONFLUX_NUM_LEGS(circ->conflux) == 0) {
/* Last leg, remove conflux object from linked set. */
linked_pool_del(circ->conflux->nonce, is_client);
- linked_detach_circuit(circ);
} else {
/* If there are other circuits, update streams backpointers and
* nullify the stream lists. We do not free those streams in circuit_free_.
diff --git a/src/core/or/relay.c b/src/core/or/relay.c
index 3af9435a76..893daa09fd 100644
--- a/src/core/or/relay.c
+++ b/src/core/or/relay.c
@@ -639,7 +639,8 @@ relay_send_command_from_edge_,(streamid_t stream_id, circuit_t *orig_circ,
circ = conflux_decide_circ_for_send(orig_circ->conflux, orig_circ,
relay_command);
if (BUG(!circ)) {
- log_warn(LD_BUG, "No circuit to send on for conflux");
+ log_warn(LD_BUG, "No circuit to send for conflux for relay command %d, "
+ "called from %s:%d", relay_command, filename, lineno);
circ = orig_circ;
} else {
/* Conflux circuits always send multiplexed relay commands to
diff --git a/src/ext/equix/hashx/src/compiler_a64.c b/src/ext/equix/hashx/src/compiler_a64.c
index 1b7081f537..2e286b3099 100644
--- a/src/ext/equix/hashx/src/compiler_a64.c
+++ b/src/ext/equix/hashx/src/compiler_a64.c
@@ -55,7 +55,7 @@ bool hashx_compile_a64(const hashx_program* program, uint8_t* code) {
uint8_t* target = NULL;
int creg = -1;
EMIT(pos, a64_prologue);
- for (int i = 0; i < program->code_size; ++i) {
+ for (size_t i = 0; i < program->code_size; ++i) {
const instruction* instr = &program->code[i];
switch (instr->opcode)
{
diff --git a/src/ext/equix/hashx/src/program.c b/src/ext/equix/hashx/src/program.c
index 1017d4070a..267ab5956a 100644
--- a/src/ext/equix/hashx/src/program.c
+++ b/src/ext/equix/hashx/src/program.c
@@ -678,7 +678,7 @@ bool hashx_program_generate(const siphash_state* key, hashx_program* program) {
/* Calculate ASIC latency:
Assumes 1 cycle latency for all operations and unlimited parallelization. */
- for (int i = 0; i < program->code_size; ++i) {
+ for (size_t i = 0; i < program->code_size; ++i) {
instruction* instr = &program->code[i];
if (instr->dst < 0)
continue;
@@ -724,8 +724,8 @@ bool hashx_program_generate(const siphash_state* key, hashx_program* program) {
static const char* x86_reg_map[] = { "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15" };
void hashx_program_asm_x86(const hashx_program* program) {
- int target = 0;
- for (unsigned i = 0; i < program->code_size; ++i) {
+ size_t target = 0;
+ for (size_t i = 0; i < program->code_size; ++i) {
const instruction* instr = &program->code[i];
switch (instr->opcode)
{
@@ -762,13 +762,13 @@ void hashx_program_asm_x86(const hashx_program* program) {
break;
case INSTR_TARGET:
printf("test edi, edi\n");
- printf("target_%i: cmovz esi, edi\n", i);
+ printf("target_%i: cmovz esi, edi\n", (int)i);
target = i;
break;
case INSTR_BRANCH:
printf("or edx, esi\n");
printf("test edx, %i\n", instr->imm32);
- printf("jz target_%i\n", target);
+ printf("jz target_%i\n", (int)target);
break;
default:
UNREACHABLE;
diff --git a/src/ext/equix/src/lib.rs b/src/ext/equix/src/lib.rs
index 8eb163075a..716160b4d5 100644
--- a/src/ext/equix/src/lib.rs
+++ b/src/ext/equix/src/lib.rs
@@ -114,7 +114,7 @@ impl HashX {
},
}
unsafe extern "C" fn wrapper(buffer: *mut u64, callback: *mut c_void) {
- let callback: &mut RngCallback = unsafe { mem::transmute(callback) };
+ let callback = &mut *(callback as *mut RngCallback);
buffer.write(callback(buffer.read()));
}
result
diff --git a/src/lib/compress/compress_zstd.c b/src/lib/compress/compress_zstd.c
index 34a2e806f6..85c2bb3bfa 100644
--- a/src/lib/compress/compress_zstd.c
+++ b/src/lib/compress/compress_zstd.c
@@ -368,6 +368,13 @@ tor_zstd_compress_process(tor_zstd_compress_state_t *state,
&output, &input);
}
+ if (ZSTD_isError(retval)) {
+ log_warn(LD_GENERAL, "Zstandard %s didn't finish: %s.",
+ state->compress ? "compression" : "decompression",
+ ZSTD_getErrorName(retval));
+ return TOR_COMPRESS_ERROR;
+ }
+
state->input_so_far += input.pos;
state->output_so_far += output.pos;
@@ -383,13 +390,6 @@ tor_zstd_compress_process(tor_zstd_compress_state_t *state,
return TOR_COMPRESS_ERROR;
}
- if (ZSTD_isError(retval)) {
- log_warn(LD_GENERAL, "Zstandard %s didn't finish: %s.",
- state->compress ? "compression" : "decompression",
- ZSTD_getErrorName(retval));
- return TOR_COMPRESS_ERROR;
- }
-
if (state->compress && !state->have_called_end) {
retval = ZSTD_flushStream(state->u.compress_stream, &output);
diff --git a/src/test/test_rebind.sh b/src/test/test_rebind.sh
index aae2a9a6a0..d87e008f9a 100755
--- a/src/test/test_rebind.sh
+++ b/src/test/test_rebind.sh
@@ -51,6 +51,7 @@ tmpdir=
# shellcheck disable=SC2317
clean () {
if [ -n "$tmpdir" ] && [ -d "$tmpdir" ]; then
+ ls -l "$tmpdir"
rm -rf "$tmpdir"
fi
}