From: Nick Mathewson Date: Thu, 8 May 2025 01:16:35 +0000 (-0400) Subject: Un-parenthesize checks wrt connection_edge_process_ordered_relay_cell() X-Git-Tag: tor-0.4.9.3-alpha~48^2~2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=38d2ec897014739af16b93f127f578c0d2ba6bf8;p=thirdparty%2Ftor.git Un-parenthesize checks wrt connection_edge_process_ordered_relay_cell() Previously, one of these checks had the parentheses in the wrong place, given an incorrect result. The code is hard enough to read that I refactored both instances to be more obviously right. I've grepped for similar errors elsewhere, but didn't find them. Fixed #41070. Bug not in any released Tor. --- diff --git a/src/core/or/relay.c b/src/core/or/relay.c index 7a79bb3888..f116cb5972 100644 --- a/src/core/or/relay.c +++ b/src/core/or/relay.c @@ -2107,12 +2107,11 @@ connection_edge_process_relay_cell(const relay_msg_t *msg, circuit_t *circ, if (conflux_process_relay_msg(circ->conflux, circ, layer_hint, (relay_msg_t *) msg)) { conflux_msg_t *c_msg = NULL; - int ret = 0; /* First, process this cell */ - if ((ret = connection_edge_process_ordered_relay_cell(msg, circ, - conn, - layer_hint) < 0)) { + int ret = connection_edge_process_ordered_relay_cell( + msg, circ, conn, layer_hint); + if (ret < 0) { return ret; } @@ -2120,10 +2119,10 @@ connection_edge_process_relay_cell(const relay_msg_t *msg, circuit_t *circ, while ((c_msg = conflux_dequeue_relay_msg(circ->conflux))) { conn = relay_lookup_conn(circ, c_msg->msg, CELL_DIRECTION_OUT, layer_hint); - if ((ret = - connection_edge_process_ordered_relay_cell(c_msg->msg, circ, - conn, - layer_hint)) < 0) { + ret = connection_edge_process_ordered_relay_cell(c_msg->msg, circ, + conn, + layer_hint); + if (ret < 0) { /* Negative return value is a fatal error. Return early and tear down * circuit */ conflux_relay_msg_free(c_msg);