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

Commitefb8046

Browse files
committed
Use BIO_{get,set}_app_data instead of BIO_{get,set}_data.
We should have done it this way all along, but we accidentally gotaway with using the wrong BIO field up until OpenSSL 3.2. There,the library's BIO routines that we rely on use the "data" fieldfor their own purposes, and our conflicting use causes assortedweird behaviors up to and including core dumps when SSL connectionsare attempted. Switch to using the approved field for the purpose,i.e. app_data.While at it, remove our configure probes for BIO_get_data as wellas the fallback implementation. BIO_{get,set}_app_data have beenthere since long before any OpenSSL version that we still support,even in the back branches.Also, update src/test/ssl/t/001_ssltests.pl to allow for a minorchange in an error message spelling that evidently came in with 3.2.Tristan Partin and Bo Andreson. Back-patch to all supported branches.Discussion:https://postgr.es/m/CAN55FZ1eDDYsYaL7mv+oSLUij2h_u6hvD4Qmv-7PK7jkji0uyQ@mail.gmail.com
1 parente434d36 commitefb8046

File tree

6 files changed

+8
-23
lines changed

6 files changed

+8
-23
lines changed

‎configure

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12713,7 +12713,7 @@ done
1271312713
# defines OPENSSL_VERSION_NUMBER to claim version 2.0.0, even though it
1271412714
# doesn't have these OpenSSL 1.1.0 functions. So check for individual
1271512715
# functions.
12716-
for ac_func in OPENSSL_init_sslBIO_get_dataBIO_meth_new ASN1_STRING_get0_data
12716+
for ac_func in OPENSSL_init_ssl BIO_meth_new ASN1_STRING_get0_data
1271712717
do :
1271812718
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
1271912719
ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"

‎configure.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1275,7 +1275,7 @@ if test "$with_openssl" = yes ; then
12751275
# defines OPENSSL_VERSION_NUMBER to claim version 2.0.0, even though it
12761276
# doesn't have these OpenSSL 1.1.0 functions. So check for individual
12771277
# functions.
1278-
AC_CHECK_FUNCS([OPENSSL_init_sslBIO_get_dataBIO_meth_new ASN1_STRING_get0_data])
1278+
AC_CHECK_FUNCS([OPENSSL_init_ssl BIO_meth_new ASN1_STRING_get0_data])
12791279
# OpenSSL versions before 1.1.0 required setting callback functions, for
12801280
# thread-safety. In 1.1.0, it's no longer required, and CRYPTO_lock()
12811281
# function was removed.

‎src/backend/libpq/be-secure-openssl.c

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -748,11 +748,6 @@ be_tls_write(Port *port, void *ptr, size_t len, int *waitfor)
748748
* to retry; do we need to adopt their logic for that?
749749
*/
750750

751-
#ifndefHAVE_BIO_GET_DATA
752-
#defineBIO_get_data(bio) (bio->ptr)
753-
#defineBIO_set_data(bio,data) (bio->ptr = data)
754-
#endif
755-
756751
staticBIO_METHOD*my_bio_methods=NULL;
757752

758753
staticint
@@ -762,7 +757,7 @@ my_sock_read(BIO *h, char *buf, int size)
762757

763758
if (buf!=NULL)
764759
{
765-
res=secure_raw_read(((Port*)BIO_get_data(h)),buf,size);
760+
res=secure_raw_read(((Port*)BIO_get_app_data(h)),buf,size);
766761
BIO_clear_retry_flags(h);
767762
if (res <=0)
768763
{
@@ -782,7 +777,7 @@ my_sock_write(BIO *h, const char *buf, int size)
782777
{
783778
intres=0;
784779

785-
res=secure_raw_write(((Port*)BIO_get_data(h)),buf,size);
780+
res=secure_raw_write(((Port*)BIO_get_app_data(h)),buf,size);
786781
BIO_clear_retry_flags(h);
787782
if (res <=0)
788783
{
@@ -858,7 +853,7 @@ my_SSL_set_fd(Port *port, int fd)
858853
SSLerr(SSL_F_SSL_SET_FD,ERR_R_BUF_LIB);
859854
gotoerr;
860855
}
861-
BIO_set_data(bio,port);
856+
BIO_set_app_data(bio,port);
862857

863858
BIO_set_fd(bio,fd,BIO_NOCLOSE);
864859
SSL_set_bio(port->ssl,bio,bio);

‎src/include/pg_config.h.in

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,6 @@
8686
/* Define to 1 if you have the `backtrace_symbols' function. */
8787
#undef HAVE_BACKTRACE_SYMBOLS
8888

89-
/* Define to 1 if you have the `BIO_get_data' function. */
90-
#undef HAVE_BIO_GET_DATA
91-
9289
/* Define to 1 if you have the `BIO_meth_new' function. */
9390
#undef HAVE_BIO_METH_NEW
9491

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

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1602,11 +1602,6 @@ PQsslAttribute(PGconn *conn, const char *attribute_name)
16021602
* to retry; do we need to adopt their logic for that?
16031603
*/
16041604

1605-
#ifndefHAVE_BIO_GET_DATA
1606-
#defineBIO_get_data(bio) (bio->ptr)
1607-
#defineBIO_set_data(bio,data) (bio->ptr = data)
1608-
#endif
1609-
16101605
/* protected by ssl_config_mutex */
16111606
staticBIO_METHOD*my_bio_methods;
16121607

@@ -1615,7 +1610,7 @@ my_sock_read(BIO *h, char *buf, int size)
16151610
{
16161611
intres;
16171612

1618-
res=pqsecure_raw_read((PGconn*)BIO_get_data(h),buf,size);
1613+
res=pqsecure_raw_read((PGconn*)BIO_get_app_data(h),buf,size);
16191614
BIO_clear_retry_flags(h);
16201615
if (res<0)
16211616
{
@@ -1645,7 +1640,7 @@ my_sock_write(BIO *h, const char *buf, int size)
16451640
{
16461641
intres;
16471642

1648-
res=pqsecure_raw_write((PGconn*)BIO_get_data(h),buf,size);
1643+
res=pqsecure_raw_write((PGconn*)BIO_get_app_data(h),buf,size);
16491644
BIO_clear_retry_flags(h);
16501645
if (res<0)
16511646
{
@@ -1764,7 +1759,7 @@ my_SSL_set_fd(PGconn *conn, int fd)
17641759
SSLerr(SSL_F_SSL_SET_FD,ERR_R_BUF_LIB);
17651760
gotoerr;
17661761
}
1767-
BIO_set_data(bio,conn);
1762+
BIO_set_app_data(bio,conn);
17681763

17691764
SSL_set_bio(conn->ssl,bio,bio);
17701765
BIO_set_fd(bio,fd,BIO_NOCLOSE);

‎src/tools/msvc/Solution.pm

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,6 @@ sub GenerateFiles
226226
HAVE_ATOMICS=> 1,
227227
HAVE_ATOMIC_H=>undef,
228228
HAVE_BACKTRACE_SYMBOLS=>undef,
229-
HAVE_BIO_GET_DATA=>undef,
230229
HAVE_BIO_METH_NEW=>undef,
231230
HAVE_CLOCK_GETTIME=>undef,
232231
HAVE_COMPUTED_GOTO=>undef,
@@ -543,7 +542,6 @@ sub GenerateFiles
543542
|| ($digit1 >='1' &&$digit2 >='1' &&$digit3 >='0'))
544543
{
545544
$define{HAVE_ASN1_STRING_GET0_DATA} = 1;
546-
$define{HAVE_BIO_GET_DATA} = 1;
547545
$define{HAVE_BIO_METH_NEW} = 1;
548546
$define{HAVE_OPENSSL_INIT_SSL} = 1;
549547
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp