From: Hugo Landau Date: Sun, 10 Mar 2024 00:19:43 +0000 (+0000) Subject: QUIC OBJ: Use QUIC_OBJ pointer for parent references X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=20b939de177334d6367c6a48223087f3eb834dd8;p=thirdparty%2Fopenssl.git QUIC OBJ: Use QUIC_OBJ pointer for parent references Reviewed-by: Matt Caswell Reviewed-by: Neil Horman (Merged from https://github.com/openssl/openssl/pull/23334) --- diff --git a/ssl/quic/quic_obj.c b/ssl/quic/quic_obj.c index 5404aa09dcf..8529ad70d74 100644 --- a/ssl/quic/quic_obj.c +++ b/ssl/quic/quic_obj.c @@ -34,7 +34,7 @@ int ossl_quic_obj_init(QUIC_OBJ *obj, if (!ossl_ssl_init(&obj->ssl, ctx, ctx->method, type)) goto err; - obj->parent_obj = parent_obj; + obj->parent_obj = (QUIC_OBJ *)parent_obj; obj->is_event_leader = is_event_leader; obj->is_port_leader = is_port_leader; obj->engine = engine; @@ -51,22 +51,12 @@ err: return 0; } -static ossl_inline QUIC_OBJ * -ssl_to_obj(SSL *ssl) -{ - if (ssl == NULL) - return NULL; - - assert(IS_QUIC(ssl)); - return (QUIC_OBJ *)ssl; -} - static int obj_update_cache(QUIC_OBJ *obj) { QUIC_OBJ *p; for (p = obj; p != NULL && !p->is_event_leader; - p = ssl_to_obj(p->parent_obj)) + p = p->parent_obj) if (!ossl_assert(p == obj || p->init_done)) return 0; @@ -77,13 +67,13 @@ static int obj_update_cache(QUIC_OBJ *obj) * Offset of ->ssl is guaranteed to be 0 but the NULL check makes ubsan * happy. */ - obj->cached_event_leader = (p != NULL) ? &p->ssl : NULL; + obj->cached_event_leader = p; obj->engine = p->engine; for (p = obj; p != NULL && !p->is_port_leader; - p = ssl_to_obj(p->parent_obj)); + p = p->parent_obj); - obj->cached_port_leader = (p != NULL) ? &p->ssl : NULL; + obj->cached_port_leader = p; obj->port = (p != NULL) ? p->port : NULL; return 1; } diff --git a/ssl/quic/quic_obj_local.h b/ssl/quic/quic_obj_local.h index 2b31f4b426b..55daf822151 100644 --- a/ssl/quic/quic_obj_local.h +++ b/ssl/quic/quic_obj_local.h @@ -75,12 +75,12 @@ struct quic_obj_st { * Pointer to a parent APL object in a QUIC APL object hierarchy, or NULL if * this is the root object. */ - SSL *parent_obj; + QUIC_OBJ *parent_obj; /* invariant: != NULL */ - SSL *cached_event_leader; + QUIC_OBJ *cached_event_leader; /* invariant: != NULL iff this is a port leader or subsidiary object */ - SSL *cached_port_leader; + QUIC_OBJ *cached_port_leader; /* * Points to the QUIC_ENGINE instance. Always equals @@ -257,7 +257,9 @@ static ossl_inline ossl_unused SSL * ossl_quic_obj_get0_event_leader(const QUIC_OBJ *obj) { assert(obj->init_done); - return obj->cached_event_leader; + return obj->cached_event_leader != NULL + ? &obj->cached_event_leader->ssl + : NULL; } /* @@ -268,7 +270,9 @@ static ossl_inline ossl_unused SSL * ossl_quic_obj_get0_port_leader(const QUIC_OBJ *obj) { assert(obj->init_done); - return obj->cached_port_leader; + return obj->cached_port_leader != NULL + ? &obj->cached_port_leader->ssl + : NULL; } # endif