Stop fiddling with hash table internals from lhash doall callers.
authorjsing <jsing@openbsd.org>
Wed, 24 Jan 2024 14:05:10 +0000 (14:05 +0000)
committerjsing <jsing@openbsd.org>
Wed, 24 Jan 2024 14:05:10 +0000 (14:05 +0000)
It is now safe to call delete from an lhash doall callback - stop fiddling
wit hash table internals from lhash doall callers that previously has to
workaround this themselves.

ok tb@

lib/libcrypto/conf/conf_api.c
lib/libcrypto/objects/obj_dat.c
lib/libssl/ssl_sess.c

index 6fe071e..464edcd 100644 (file)
@@ -1,4 +1,4 @@
-/* $OpenBSD: conf_api.c,v 1.16 2023/07/08 08:26:26 beck Exp $ */
+/* $OpenBSD: conf_api.c,v 1.17 2024/01/24 14:05:10 jsing Exp $ */
 /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
  * All rights reserved.
  *
@@ -205,9 +205,6 @@ _CONF_free_data(CONF *conf)
        if (conf == NULL || conf->data == NULL)
                return;
 
-       lh_CONF_VALUE_down_load(conf->data) = 0; /* evil thing to make
-                                                 * sure the 'free()' works as
-                                                 * expected */
        lh_CONF_VALUE_doall_arg(conf->data,
            LHASH_DOALL_ARG_FN(value_free_hash),
            LHASH_OF(CONF_VALUE), conf->data);
index acc4556..170a6d5 100644 (file)
@@ -1,4 +1,4 @@
-/* $OpenBSD: obj_dat.c,v 1.84 2024/01/13 11:57:51 tb Exp $ */
+/* $OpenBSD: obj_dat.c,v 1.85 2024/01/24 14:05:10 jsing Exp $ */
 /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
  * All rights reserved.
  *
@@ -188,7 +188,7 @@ OBJ_cleanup(void)
 {
        if (added == NULL)
                return;
-       lh_ADDED_OBJ_down_load(added) = 0;
+
        lh_ADDED_OBJ_doall(added, LHASH_DOALL_FN(cleanup1)); /* zero counters */
        lh_ADDED_OBJ_doall(added, LHASH_DOALL_FN(cleanup2)); /* set counters */
        lh_ADDED_OBJ_doall(added, LHASH_DOALL_FN(cleanup3)); /* free objects */
index ae7532d..355193c 100644 (file)
@@ -1,4 +1,4 @@
-/* $OpenBSD: ssl_sess.c,v 1.123 2023/11/19 15:51:49 tb Exp $ */
+/* $OpenBSD: ssl_sess.c,v 1.124 2024/01/24 14:05:10 jsing Exp $ */
 /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
  * All rights reserved.
  *
@@ -1159,7 +1159,6 @@ timeout_LHASH_DOALL_ARG(void *arg1, void *arg2)
 void
 SSL_CTX_flush_sessions(SSL_CTX *s, long t)
 {
-       unsigned long i;
        TIMEOUT_PARAM tp;
 
        tp.ctx = s;
@@ -1167,12 +1166,10 @@ SSL_CTX_flush_sessions(SSL_CTX *s, long t)
        if (tp.cache == NULL)
                return;
        tp.time = t;
+
        CRYPTO_w_lock(CRYPTO_LOCK_SSL_CTX);
-       i = CHECKED_LHASH_OF(SSL_SESSION, tp.cache)->down_load;
-       CHECKED_LHASH_OF(SSL_SESSION, tp.cache)->down_load = 0;
        lh_SSL_SESSION_doall_arg(tp.cache, timeout_LHASH_DOALL_ARG,
-       TIMEOUT_PARAM, &tp);
-       CHECKED_LHASH_OF(SSL_SESSION, tp.cache)->down_load = i;
+           TIMEOUT_PARAM, &tp);
        CRYPTO_w_unlock(CRYPTO_LOCK_SSL_CTX);
 }
 LSSL_ALIAS(SSL_CTX_flush_sessions);