Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit8a0d34e

Browse files
committed
libpq: Don't overwrite existing OpenSSL thread callbacks
If someone else already set the callbacks, don't overwrite them withours. When unsetting the callbacks, only unset them if they point toours.Author: Jan Urbański <wulczer@wulczer.org>
1 parenta6f3c1f commit8a0d34e

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

‎src/interfaces/libpq/fe-secure-openssl.c

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -806,9 +806,12 @@ pgtls_init(PGconn *conn)
806806

807807
if (ssl_open_connections++==0)
808808
{
809-
/* These are only required for threaded libcrypto applications */
810-
CRYPTO_set_id_callback(pq_threadidcallback);
811-
CRYPTO_set_locking_callback(pq_lockingcallback);
809+
/* These are only required for threaded libcrypto applications, but
810+
* make sure we don't stomp on them if they're already set. */
811+
if (CRYPTO_get_id_callback()==NULL)
812+
CRYPTO_set_id_callback(pq_threadidcallback);
813+
if (CRYPTO_get_locking_callback()==NULL)
814+
CRYPTO_set_locking_callback(pq_lockingcallback);
812815
}
813816
}
814817
#endif/* ENABLE_THREAD_SAFETY */
@@ -885,9 +888,12 @@ destroy_ssl_system(void)
885888

886889
if (pq_init_crypto_lib&&ssl_open_connections==0)
887890
{
888-
/* No connections left, unregister libcrypto callbacks */
889-
CRYPTO_set_locking_callback(NULL);
890-
CRYPTO_set_id_callback(NULL);
891+
/* No connections left, unregister libcrypto callbacks, if no one
892+
* registered different ones in the meantime. */
893+
if (CRYPTO_get_locking_callback()==pq_lockingcallback)
894+
CRYPTO_set_locking_callback(NULL);
895+
if (CRYPTO_get_id_callback()==pq_threadidcallback)
896+
CRYPTO_set_id_callback(NULL);
891897

892898
/*
893899
* We don't free the lock array or the SSL_context. If we get another

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp