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

Commit0bd6822

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 parentb8a606e commit0bd6822

File tree

7 files changed

+8
-25
lines changed

7 files changed

+8
-25
lines changed

‎configure‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12641,7 +12641,7 @@ done
1264112641
# defines OPENSSL_VERSION_NUMBER to claim version 2.0.0, even though it
1264212642
# doesn't have these OpenSSL 1.1.0 functions. So check for individual
1264312643
# functions.
12644-
for ac_func in OPENSSL_init_sslBIO_get_dataBIO_meth_new ASN1_STRING_get0_data
12644+
for ac_func in OPENSSL_init_ssl BIO_meth_new ASN1_STRING_get0_data
1264512645
do :
1264612646
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
1264712647
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
@@ -1290,7 +1290,7 @@ if test "$with_openssl" = yes ; then
12901290
# defines OPENSSL_VERSION_NUMBER to claim version 2.0.0, even though it
12911291
# doesn't have these OpenSSL 1.1.0 functions. So check for individual
12921292
# functions.
1293-
AC_CHECK_FUNCS([OPENSSL_init_sslBIO_get_dataBIO_meth_new ASN1_STRING_get0_data])
1293+
AC_CHECK_FUNCS([OPENSSL_init_ssl BIO_meth_new ASN1_STRING_get0_data])
12941294
# OpenSSL versions before 1.1.0 required setting callback functions, for
12951295
# thread-safety. In 1.1.0, it's no longer required, and CRYPTO_lock()
12961296
# function was removed.

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

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

702-
#ifndefHAVE_BIO_GET_DATA
703-
#defineBIO_get_data(bio) (bio->ptr)
704-
#defineBIO_set_data(bio,data) (bio->ptr = data)
705-
#endif
706-
707702
staticBIO_METHOD*my_bio_methods=NULL;
708703

709704
staticint
@@ -713,7 +708,7 @@ my_sock_read(BIO *h, char *buf, int size)
713708

714709
if (buf!=NULL)
715710
{
716-
res=secure_raw_read(((Port*)BIO_get_data(h)),buf,size);
711+
res=secure_raw_read(((Port*)BIO_get_app_data(h)),buf,size);
717712
BIO_clear_retry_flags(h);
718713
if (res <=0)
719714
{
@@ -733,7 +728,7 @@ my_sock_write(BIO *h, const char *buf, int size)
733728
{
734729
intres=0;
735730

736-
res=secure_raw_write(((Port*)BIO_get_data(h)),buf,size);
731+
res=secure_raw_write(((Port*)BIO_get_app_data(h)),buf,size);
737732
BIO_clear_retry_flags(h);
738733
if (res <=0)
739734
{
@@ -809,7 +804,7 @@ my_SSL_set_fd(Port *port, int fd)
809804
SSLerr(SSL_F_SSL_SET_FD,ERR_R_BUF_LIB);
810805
gotoerr;
811806
}
812-
BIO_set_data(bio,port);
807+
BIO_set_app_data(bio,port);
813808

814809
BIO_set_fd(bio,fd,BIO_NOCLOSE);
815810
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
@@ -96,9 +96,6 @@
9696
/* Define to 1 if you have the <atomic.h> header file. */
9797
#undef HAVE_ATOMIC_H
9898

99-
/* Define to 1 if you have the `BIO_get_data' function. */
100-
#undef HAVE_BIO_GET_DATA
101-
10299
/* Define to 1 if you have the `BIO_meth_new' function. */
103100
#undef HAVE_BIO_METH_NEW
104101

‎src/include/pg_config.h.win32‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,6 @@
7575
/* Define to 1 if you have the `ASN1_STRING_get0_data' function. */
7676
/* #undef HAVE_ASN1_STRING_GET0_DATA */
7777

78-
/* Define to 1 if you have the `BIO_get_data' function. */
79-
/* #undef HAVE_BIO_GET_DATA */
80-
8178
/* Define to 1 if you have the `BIO_meth_new' function. */
8279
/* #undef HAVE_BIO_METH_NEW */
8380

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

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

1494-
#ifndefHAVE_BIO_GET_DATA
1495-
#defineBIO_get_data(bio) (bio->ptr)
1496-
#defineBIO_set_data(bio,data) (bio->ptr = data)
1497-
#endif
1498-
14991494
/* protected by ssl_config_mutex */
15001495
staticBIO_METHOD*my_bio_methods;
15011496

@@ -1504,7 +1499,7 @@ my_sock_read(BIO *h, char *buf, int size)
15041499
{
15051500
intres;
15061501

1507-
res=pqsecure_raw_read((PGconn*)BIO_get_data(h),buf,size);
1502+
res=pqsecure_raw_read((PGconn*)BIO_get_app_data(h),buf,size);
15081503
BIO_clear_retry_flags(h);
15091504
if (res<0)
15101505
{
@@ -1534,7 +1529,7 @@ my_sock_write(BIO *h, const char *buf, int size)
15341529
{
15351530
intres;
15361531

1537-
res=pqsecure_raw_write((PGconn*)BIO_get_data(h),buf,size);
1532+
res=pqsecure_raw_write((PGconn*)BIO_get_app_data(h),buf,size);
15381533
BIO_clear_retry_flags(h);
15391534
if (res<0)
15401535
{
@@ -1653,7 +1648,7 @@ my_SSL_set_fd(PGconn *conn, int fd)
16531648
SSLerr(SSL_F_SSL_SET_FD,ERR_R_BUF_LIB);
16541649
gotoerr;
16551650
}
1656-
BIO_set_data(bio,conn);
1651+
BIO_set_app_data(bio,conn);
16571652

16581653
SSL_set_bio(conn->ssl,bio,bio);
16591654
BIO_set_fd(bio,fd,BIO_NOCLOSE);

‎src/tools/msvc/Solution.pm‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,6 @@ sub GenerateFiles
273273
|| ($digit1 >='1' &&$digit2 >='1' &&$digit3 >='0'))
274274
{
275275
print$o"#define HAVE_ASN1_STRING_GET0_DATA 1\n";
276-
print$o"#define HAVE_BIO_GET_DATA 1\n";
277276
print$o"#define HAVE_BIO_METH_NEW 1\n";
278277
print$o"#define HAVE_OPENSSL_INIT_SSL 1\n";
279278
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp