diff options
| author | jsing <> | 2018-11-24 04:11:47 +0000 | 
|---|---|---|
| committer | jsing <> | 2018-11-24 04:11:47 +0000 | 
| commit | 8e6972c56a2f404ee1ab7aef845a882f2db938d8 (patch) | |
| tree | e76987af4d3eff5c5d457887ba61d74f44234bb1 | |
| parent | e8890ed3b276eb268ca4797509a7faf50534f77d (diff) | |
| download | openbsd-8e6972c56a2f404ee1ab7aef845a882f2db938d8.tar.gz openbsd-8e6972c56a2f404ee1ab7aef845a882f2db938d8.tar.bz2 openbsd-8e6972c56a2f404ee1ab7aef845a882f2db938d8.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 '')
| -rw-r--r-- | src/lib/libcrypto/cryptlib.c | 18 | 
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 | ||
| 125 | static void (*locking_callback)(int mode, int type, | ||
| 126 | const char *file, int line) = NULL; | ||
| 127 | static int (*add_lock_callback)(int *pointer, int amount, | ||
| 128 | int type, const char *file, int line) = NULL; | ||
| 129 | |||
| 125 | int | 130 | int | 
| 126 | CRYPTO_num_locks(void) | 131 | CRYPTO_num_locks(void) | 
| 127 | { | 132 | { | 
| 128 | return 1; | 133 | return 1; | 
| 129 | } | 134 | } | 
| 130 | 135 | ||
| 131 | unsigned long (*CRYPTO_get_id_callback(void))(void) | 136 | unsigned long | 
| 137 | (*CRYPTO_get_id_callback(void))(void) | ||
| 132 | { | 138 | { | 
| 133 | return NULL; | 139 | return NULL; | 
| 134 | } | 140 | } | 
| @@ -149,28 +155,28 @@ void | |||
| 149 | CRYPTO_set_locking_callback(void (*func)(int mode, int lock_num, | 155 | CRYPTO_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 | ||
| 155 | void | 161 | void | 
| 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 | ||
| 162 | void | 168 | void | 
| 163 | CRYPTO_set_add_lock_callback(int (*func)(int *num, int mount, int lock_num, | 169 | CRYPTO_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 | ||
| 169 | int | 175 | int | 
| 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 | ||
| 176 | const char * | 182 | const char * | 
