summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorjsing <>2018-11-24 04:11:47 +0000
committerjsing <>2018-11-24 04:11:47 +0000
commitb2f89354805a7b9d93880d8953cd132eadedeca4 (patch)
treee76987af4d3eff5c5d457887ba61d74f44234bb1 /src/lib
parentab91451e6ebf1260022c78c25a334e437c04d78e (diff)
downloadopenbsd-b2f89354805a7b9d93880d8953cd132eadedeca4.tar.gz
openbsd-b2f89354805a7b9d93880d8953cd132eadedeca4.tar.bz2
openbsd-b2f89354805a7b9d93880d8953cd132eadedeca4.zip
Store and return the locking callbacks, restoring previous behaviour.
The previous code meant that a caller could set the locking callback, after which CRYPTO_get_locking_callback() would return non-NULL. Some existing code depends on this behaviour, specifically to identify if lock handling has been configured. As such, always returning NULL from CRYPTO_get_locking_callback() can result in unexpected application behaviour. ok bcook@
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/libcrypto/cryptlib.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/src/lib/libcrypto/cryptlib.c b/src/lib/libcrypto/cryptlib.c
index 2af8b12095..5518c66c46 100644
--- a/src/lib/libcrypto/cryptlib.c
+++ b/src/lib/libcrypto/cryptlib.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: cryptlib.c,v 1.43 2018/11/11 16:32:28 bcook Exp $ */ 1/* $OpenBSD: cryptlib.c,v 1.44 2018/11/24 04:11:47 jsing Exp $ */
2/* ==================================================================== 2/* ====================================================================
3 * Copyright (c) 1998-2006 The OpenSSL Project. All rights reserved. 3 * Copyright (c) 1998-2006 The OpenSSL Project. All rights reserved.
4 * 4 *
@@ -122,13 +122,19 @@
122#include <openssl/opensslconf.h> 122#include <openssl/opensslconf.h>
123#include <openssl/crypto.h> 123#include <openssl/crypto.h>
124 124
125static void (*locking_callback)(int mode, int type,
126 const char *file, int line) = NULL;
127static int (*add_lock_callback)(int *pointer, int amount,
128 int type, const char *file, int line) = NULL;
129
125int 130int
126CRYPTO_num_locks(void) 131CRYPTO_num_locks(void)
127{ 132{
128 return 1; 133 return 1;
129} 134}
130 135
131unsigned long (*CRYPTO_get_id_callback(void))(void) 136unsigned long
137(*CRYPTO_get_id_callback(void))(void)
132{ 138{
133 return NULL; 139 return NULL;
134} 140}
@@ -149,28 +155,28 @@ void
149CRYPTO_set_locking_callback(void (*func)(int mode, int lock_num, 155CRYPTO_set_locking_callback(void (*func)(int mode, int lock_num,
150 const char *file, int line)) 156 const char *file, int line))
151{ 157{
152 return; 158 locking_callback = func;
153} 159}
154 160
155void 161void
156(*CRYPTO_get_locking_callback(void))(int mode, int lock_num, 162(*CRYPTO_get_locking_callback(void))(int mode, int lock_num,
157 const char *file, int line) 163 const char *file, int line)
158{ 164{
159 return NULL; 165 return locking_callback;
160} 166}
161 167
162void 168void
163CRYPTO_set_add_lock_callback(int (*func)(int *num, int mount, int lock_num, 169CRYPTO_set_add_lock_callback(int (*func)(int *num, int mount, int lock_num,
164 const char *file, int line)) 170 const char *file, int line))
165{ 171{
166 return; 172 add_lock_callback = func;
167} 173}
168 174
169int 175int
170(*CRYPTO_get_add_lock_callback(void))(int *num, int mount, int type, 176(*CRYPTO_get_add_lock_callback(void))(int *num, int mount, int type,
171 const char *file, int line) 177 const char *file, int line)
172{ 178{
173 return NULL; 179 return add_lock_callback;
174} 180}
175 181
176const char * 182const char *