]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Abolish RELAY_HEADER_SIZE.
authorNick Mathewson <nickm@torproject.org>
Thu, 17 Apr 2025 23:17:26 +0000 (19:17 -0400)
committerNick Mathewson <nickm@torproject.org>
Mon, 5 May 2025 17:07:37 +0000 (13:07 -0400)
It was frequently used before to index into a cell, which
is never right any more.

src/core/or/or.h
src/test/test_cell_formats.c

index 3e18d65bbd9e9924501c4a5e76c348f167eebe0c..57d5d3e6949feba8daeb536a732d1479f83edaa3 100644 (file)
@@ -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)
index 178aec2ab2d409913ba0cf68cb463287da99781e..b46726aa4af9ca91f4b70d3d8bd4f446d0b5dbd4 100644 (file)
@@ -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:
   ;