]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
prop224: Add a function to clear INTRO data
authorDavid Goulet <dgoulet@torproject.org>
Tue, 22 Aug 2017 18:37:33 +0000 (14:37 -0400)
committerDavid Goulet <dgoulet@torproject.org>
Thu, 24 Aug 2017 17:03:28 +0000 (13:03 -0400)
New function named hs_cell_introduce1_data_clear() is introduced to clear off
an hs_cell_introduce1_data_t object.

Signed-off-by: David Goulet <dgoulet@torproject.org>
src/or/hs_cell.c
src/or/hs_cell.h
src/or/hs_circuit.c

index 482fa04e927df762abe0136b3def6f822d94203e..5244cfa3dd5473b39e504ad1b27f1da8de1b0daa 100644 (file)
@@ -931,3 +931,18 @@ hs_cell_parse_rendezvous2(const uint8_t *payload, size_t payload_len,
   return ret;
 }
 
+/* Clear the given INTRODUCE1 data structure data. */
+void
+hs_cell_introduce1_data_clear(hs_cell_introduce1_data_t *data)
+{
+  if (data == NULL) {
+    return;
+  }
+  /* Object in this list have been moved to the cell object when building it
+   * so they've been freed earlier. We do that in order to avoid duplicating
+   * them leading to more memory and CPU time being used for nothing. */
+  smartlist_free(data->link_specifiers);
+  /* The data object has no ownership of any members. */
+  memwipe(data, 0, sizeof(hs_cell_introduce1_data_t));
+}
+
index 14dd31c9de54591b585c9587051050b49535dd55..5136fce9335a7201d64297a5807f5f5a7c81be75 100644 (file)
@@ -115,5 +115,8 @@ int hs_cell_parse_rendezvous2(const uint8_t *payload, size_t payload_len,
                               uint8_t *handshake_info,
                               size_t handshake_info_len);
 
+/* Util API. */
+void hs_cell_introduce1_data_clear(hs_cell_introduce1_data_t *data);
+
 #endif /* TOR_HS_CELL_H */
 
index 819d254327cae538440c28a84cd74f1d6e488cf5..7d41a33c89cf0f1f116ec99c6b26322a582acd10 100644 (file)
@@ -1079,11 +1079,7 @@ hs_circ_send_introduce1(origin_circuit_t *intro_circ,
   goto done;
 
  done:
-  /* Object in this list have been moved to the cell object when building it
-   * so they've been freed earlier. We do that in order to avoid duplicating
-   * them leading to more memory and CPU time being used for nothing. */
-  smartlist_free(intro1_data.link_specifiers);
-  memwipe(&intro1_data, 0, sizeof(intro1_data));
+  hs_cell_introduce1_data_clear(&intro1_data);
   memwipe(payload, 0, sizeof(payload));
   return ret;
 }