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

Commit6ddc855

Browse files
committed
libpq: Use strerror_r instead of strerror
Commit453c468 introduced a use of strerror() into libpq, but thatis not thread-safe. Fix by using strerror_r() instead.In passing, update some of the code comments added by453c468, aswe have learned more about the reason for the change in OpenSSL thatstarted this.Reviewed-by: Daniel Gustafsson <daniel@yesql.se>Discussion: Discussion:https://postgr.es/m/b6fb018b-f05c-4afd-abd3-318c649faf18@highgo.ca
1 parentce3045e commit6ddc855

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1270,10 +1270,11 @@ SSLerrmessage(unsigned long ecode)
12701270
returnerrreason;
12711271

12721272
/*
1273-
* In OpenSSL 3.0.0 and later, ERR_reason_error_string randomly refuses to
1274-
* map system errno values. We can cover that shortcoming with this bit
1275-
* of code. Older OpenSSL versions don't have the ERR_SYSTEM_ERROR macro,
1276-
* but that's okay because they don't have the shortcoming either.
1273+
* In OpenSSL 3.0.0 and later, ERR_reason_error_string does not map system
1274+
* errno values anymore. (See OpenSSL source code for the explanation.)
1275+
* We can cover that shortcoming with this bit of code. Older OpenSSL
1276+
* versions don't have the ERR_SYSTEM_ERROR macro, but that's okay because
1277+
* they don't have the shortcoming either.
12771278
*/
12781279
#ifdefERR_SYSTEM_ERROR
12791280
if (ERR_SYSTEM_ERROR(ecode))

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1689,15 +1689,16 @@ SSLerrmessage(unsigned long ecode)
16891689
}
16901690

16911691
/*
1692-
* In OpenSSL 3.0.0 and later, ERR_reason_error_string randomly refuses to
1693-
* map system errno values. We can cover that shortcoming with this bit
1694-
* of code. Older OpenSSL versions don't have the ERR_SYSTEM_ERROR macro,
1695-
* but that's okay because they don't have the shortcoming either.
1692+
* In OpenSSL 3.0.0 and later, ERR_reason_error_string does not map system
1693+
* errno values anymore. (See OpenSSL source code for the explanation.)
1694+
* We can cover that shortcoming with this bit of code. Older OpenSSL
1695+
* versions don't have the ERR_SYSTEM_ERROR macro, but that's okay because
1696+
* they don't have the shortcoming either.
16961697
*/
16971698
#ifdefERR_SYSTEM_ERROR
16981699
if (ERR_SYSTEM_ERROR(ecode))
16991700
{
1700-
strlcpy(errbuf,strerror(ERR_GET_REASON(ecode)),SSL_ERR_LEN);
1701+
strerror_r(ERR_GET_REASON(ecode),errbuf,SSL_ERR_LEN);
17011702
returnerrbuf;
17021703
}
17031704
#endif

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp