tor

The Tor anonymity network
git clone https://git.dasho.dev/tor.git
Log | Files | Refs | README | LICENSE

commit 5d6162374ae1f5c06ddd6fa721197d2966bde71b
parent bdc9df82d05c62355d05325f6b55d1cf8c5f8653
Author: Nick Mathewson <nickm@torproject.org>
Date:   Thu, 17 Apr 2025 19:17:26 -0400

Abolish RELAY_HEADER_SIZE.

It was frequently used before to index into a cell, which
is never right any more.

Diffstat:
Msrc/core/or/or.h | 3+--
Msrc/test/test_cell_formats.c | 8++++----
2 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/src/core/or/or.h b/src/core/or/or.h @@ -553,9 +553,8 @@ static inline int get_circ_id_size(int wide_circ_ids) /* TODO #41051: It would be better if these went away. */ /** Number of bytes in a relay cell's header (not including general cell * header). */ -#define RELAY_HEADER_SIZE (1+2+2+4+2) /** Largest number of bytes that can fit in a relay cell payload. */ -#define RELAY_PAYLOAD_SIZE (CELL_PAYLOAD_SIZE-RELAY_HEADER_SIZE) +#define RELAY_PAYLOAD_SIZE (CELL_PAYLOAD_SIZE-(1+2+2+4+2)) /** Number of bytes used for a relay cell's header, in the v0 format. */ #define RELAY_HEADER_SIZE_V0 (1+2+2+4+2) diff --git a/src/test/test_cell_formats.c b/src/test/test_cell_formats.c @@ -33,12 +33,12 @@ static void test_cfmt_relay_header(void *arg) { relay_header_t rh; - const uint8_t hdr_1[RELAY_HEADER_SIZE] = + const uint8_t hdr_1[RELAY_HEADER_SIZE_V0] = "\x03" "\x00\x00" "\x21\x22" "ABCD" "\x01\x03"; - uint8_t hdr_out[RELAY_HEADER_SIZE]; + uint8_t hdr_out[RELAY_HEADER_SIZE_V0]; (void)arg; - tt_int_op(sizeof(hdr_1), OP_EQ, RELAY_HEADER_SIZE); + tt_int_op(sizeof(hdr_1), OP_EQ, RELAY_HEADER_SIZE_V0); relay_header_unpack(&rh, hdr_1); tt_int_op(rh.command, OP_EQ, 3); tt_int_op(rh.recognized, OP_EQ, 0); @@ -47,7 +47,7 @@ test_cfmt_relay_header(void *arg) tt_int_op(rh.length, OP_EQ, 0x103); relay_header_pack(hdr_out, &rh); - tt_mem_op(hdr_out, OP_EQ, hdr_1, RELAY_HEADER_SIZE); + tt_mem_op(hdr_out, OP_EQ, hdr_1, RELAY_HEADER_SIZE_V0); done: ;