Commit 7c507a1f authored by George Kadianakis's avatar George Kadianakis Committed by Nick Mathewson
Browse files

Relax assertions: turn them to BUGs and non-fatal asserts.

parent e42c5562
......@@ -3098,10 +3098,12 @@ handle_hs_exit_conn(circuit_t *circ, edge_connection_t *conn)
/* Setup the identifier to be the one for the circuit service. */
conn->hs_ident =
hs_ident_edge_conn_new(&origin_circ->hs_ident->identity_pk);
tor_assert(connection_edge_is_rendezvous_stream(conn));
ret = hs_service_set_conn_addr_port(origin_circ, conn);
} else {
/* We should never get here if the circuit's purpose is rendezvous. */
tor_assert(0);
tor_assert_nonfatal_unreached();
return -1;
}
if (ret < 0) {
log_info(LD_REND, "Didn't find rendezvous service (addr%s, port %d)",
......
......@@ -377,12 +377,16 @@ service_intro_point_new(const extend_info_t *ei, unsigned int is_legacy)
* mandatory. */
ls = hs_desc_link_specifier_new(ei, LS_IPV4);
/* It is impossible to have an extend info object without a v4. */
tor_assert(ls);
if (BUG(!ls)) {
goto err;
}
smartlist_add(ip->base.link_specifiers, ls);
ls = hs_desc_link_specifier_new(ei, LS_LEGACY_ID);
/* It is impossible to have an extend info object without an identity
* digest. */
tor_assert(ls);
if (BUG(!ls)) {
goto err;
}
smartlist_add(ip->base.link_specifiers, ls);
ls = hs_desc_link_specifier_new(ei, LS_ED25519_ID);
/* It is impossible to have an extend info object without an ed25519
......@@ -546,8 +550,9 @@ get_node_from_intro_point(const hs_service_intro_point_t *ip)
tor_assert(ip);
ls = get_link_spec_by_type(ip, LS_LEGACY_ID);
/* Legacy ID is mandatory for an intro point object to have. */
tor_assert(ls);
if (BUG(!ls)) {
return NULL;
}
/* XXX In the future, we want to only use the ed25519 ID (#22173). */
return node_get_by_id((const char *) ls->u.legacy_id);
}
......@@ -1427,7 +1432,10 @@ pick_needed_intro_points(hs_service_t *service,
* robin so they are considered valid nodes to pick again. */
DIGEST256MAP_FOREACH(desc->intro_points.map, key,
hs_service_intro_point_t *, ip) {
smartlist_add(exclude_nodes, (void *) get_node_from_intro_point(ip));
const node_t *intro_node = get_node_from_intro_point(ip);
if (intro_node) {
smartlist_add(exclude_nodes, (void*)intro_node);
}
} DIGEST256MAP_FOREACH_END;
/* Also, add the failing intro points that our descriptor encounteered in
* the exclude node list. */
......@@ -2299,10 +2307,17 @@ service_intro_circ_has_opened(origin_circuit_t *circ)
hs_service_descriptor_t *desc = NULL;
tor_assert(circ);
tor_assert(circ->cpath);
/* Getting here means this is a v3 intro circuit. */
tor_assert(circ->hs_ident);
tor_assert(TO_CIRCUIT(circ)->purpose == CIRCUIT_PURPOSE_S_ESTABLISH_INTRO);
/* Let's do some basic sanity checking of the circ state */
if (BUG(!circ->cpath)) {
return;
}
if (BUG(TO_CIRCUIT(circ)->purpose != CIRCUIT_PURPOSE_S_ESTABLISH_INTRO)) {
return;
}
if (BUG(!circ->hs_ident)) {
return;
}
/* Get the corresponding service and intro point. */
get_objects_from_ident(circ->hs_ident, &service, &ip, &desc);
......
......@@ -313,8 +313,8 @@ STATIC void get_objects_from_ident(const hs_ident_circuit_t *ident,
hs_service_t **service,
hs_service_intro_point_t **ip,
hs_service_descriptor_t **desc);
STATIC const node_t *get_node_from_intro_point(
const hs_service_intro_point_t *ip);
STATIC const node_t *
get_node_from_intro_point(const hs_service_intro_point_t *ip);
STATIC int can_service_launch_intro_circuit(hs_service_t *service,
time_t now);
STATIC int intro_point_should_expire(const hs_service_intro_point_t *ip,
......
......@@ -540,7 +540,7 @@ test_helper_functions(void *arg)
/* Testing get_node_from_intro_point() */
{
const node_t *node = get_node_from_intro_point(ip);
tt_assert(node == &mock_node);
tt_ptr_op(node, OP_EQ, &mock_node);
SMARTLIST_FOREACH_BEGIN(ip->base.link_specifiers,
hs_desc_link_specifier_t *, ls) {
if (ls->type == LS_LEGACY_ID) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment