/*
- * Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 2019-2020 The OpenSSL Project Authors. All Rights Reserved.
*
* Licensed under the Apache License 2.0 (the "License"). You may not use
* this file except in compliance with the License. You can obtain a copy
*/
#include <openssl/crypto.h>
-#include <openssl/core_numbers.h>
+#include <openssl/core_dispatch.h>
#include "crypto/cryptlib.h"
#include "prov/providercommon.h"
#include "internal/thread_once.h"
-#ifdef FIPS_MODE
+#ifdef FIPS_MODULE
/*
* Thread aware code may want to be told about thread stop events. We register
* to hear about those thread stop events when we see a new thread has started.
THREAD_EVENT_HANDLER *next;
};
-#ifndef FIPS_MODE
+#ifndef FIPS_MODULE
DEFINE_SPECIAL_STACK_OF(THREAD_EVENT_HANDLER_PTR, THREAD_EVENT_HANDLER *)
typedef struct global_tevent_register_st GLOBAL_TEVENT_REGISTER;
}
#endif
-#ifndef FIPS_MODE
+#ifndef FIPS_MODULE
static int init_thread_push_handlers(THREAD_EVENT_HANDLER **hands);
static void init_thread_remove_handlers(THREAD_EVENT_HANDLER **handsin);
static void init_thread_destructor(void *hands);
return NULL;
}
-#ifndef FIPS_MODE
+#ifndef FIPS_MODULE
if (!init_thread_push_handlers(hands)) {
CRYPTO_THREAD_set_local(local, NULL);
OPENSSL_free(hands);
return hands;
}
-#ifndef FIPS_MODE
+#ifndef FIPS_MODULE
/*
* Since per-thread-specific-data destructors are not universally
* available, i.e. not on Windows, only below CRYPTO_THREAD_LOCAL key
init_thread_stop(arg, hands);
OPENSSL_free(hands);
}
-#endif /* FIPS_MODE */
+#endif /* FIPS_MODULE */
static void init_thread_stop(void *arg, THREAD_EVENT_HANDLER **hands)
{
- THREAD_EVENT_HANDLER *curr, *prev = NULL;
+ THREAD_EVENT_HANDLER *curr, *prev = NULL, *tmp;
/* Can't do much about this */
if (hands == NULL)
curr = *hands;
while (curr != NULL) {
if (arg != NULL && curr->arg != arg) {
+ prev = curr;
curr = curr->next;
continue;
}
curr->handfn(curr->arg);
- prev = curr;
+ if (prev == NULL)
+ *hands = curr->next;
+ else
+ prev->next = curr->next;
+
+ tmp = curr;
curr = curr->next;
- if (prev == *hands)
- *hands = curr;
- OPENSSL_free(prev);
+
+ OPENSSL_free(tmp);
}
}
{
THREAD_EVENT_HANDLER **hands;
THREAD_EVENT_HANDLER *hand;
-#ifdef FIPS_MODE
+#ifdef FIPS_MODULE
OPENSSL_CTX *ctx = arg;
/*
if (hands == NULL)
return 0;
-#ifdef FIPS_MODE
+#ifdef FIPS_MODULE
if (*hands == NULL) {
/*
* We've not yet registered any handlers for this thread. We need to get
* libcrypto to tell us about later thread stop events. c_thread_start
* is a callback to libcrypto defined in fipsprov.c
*/
- if (!c_thread_start(FIPS_get_provider(ctx), ossl_ctx_thread_stop))
+ if (!c_thread_start(FIPS_get_core_handle(ctx), ossl_ctx_thread_stop))
return 0;
}
#endif
return 1;
}
-#ifndef FIPS_MODE
+#ifndef FIPS_MODULE
static int init_thread_deregister(void *index, int all)
{
GLOBAL_TEVENT_REGISTER *gtr;