]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
QUIC OBJ: Use QUIC_OBJ pointer for parent references
authorHugo Landau <hlandau@openssl.org>
Sun, 10 Mar 2024 00:19:43 +0000 (00:19 +0000)
committerViktor Dukhovni <openssl-users@dukhovni.org>
Wed, 11 Sep 2024 08:35:22 +0000 (18:35 +1000)
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Neil Horman <nhorman@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/23334)

ssl/quic/quic_obj.c
ssl/quic/quic_obj_local.h

index 5404aa09dcfab6e23882c56fc9035b10a91cb7e6..8529ad70d7445b89216107a14fb0f89f14b00954 100644 (file)
@@ -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;
 }
index 2b31f4b426bd6621023242e2f61005863ea5ad73..55daf822151b565ee71cb5cb32fd454f8aa6ed8e 100644 (file)
@@ -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