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

Commitc530168

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 parent1091f8e commitc530168

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
@@ -1379,10 +1379,11 @@ SSLerrmessage(unsigned long ecode)
13791379
returnerrreason;
13801380

13811381
/*
1382-
* In OpenSSL 3.0.0 and later, ERR_reason_error_string randomly refuses to
1383-
* map system errno values. We can cover that shortcoming with this bit
1384-
* of code. Older OpenSSL versions don't have the ERR_SYSTEM_ERROR macro,
1385-
* but that's okay because they don't have the shortcoming either.
1382+
* In OpenSSL 3.0.0 and later, ERR_reason_error_string does not map system
1383+
* errno values anymore. (See OpenSSL source code for the explanation.)
1384+
* We can cover that shortcoming with this bit of code. Older OpenSSL
1385+
* versions don't have the ERR_SYSTEM_ERROR macro, but that's okay because
1386+
* they don't have the shortcoming either.
13861387
*/
13871388
#ifdefERR_SYSTEM_ERROR
13881389
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
@@ -1707,15 +1707,16 @@ SSLerrmessage(unsigned long ecode)
17071707
}
17081708

17091709
/*
1710-
* In OpenSSL 3.0.0 and later, ERR_reason_error_string randomly refuses to
1711-
* map system errno values. We can cover that shortcoming with this bit
1712-
* of code. Older OpenSSL versions don't have the ERR_SYSTEM_ERROR macro,
1713-
* but that's okay because they don't have the shortcoming either.
1710+
* In OpenSSL 3.0.0 and later, ERR_reason_error_string does not map system
1711+
* errno values anymore. (See OpenSSL source code for the explanation.)
1712+
* We can cover that shortcoming with this bit of code. Older OpenSSL
1713+
* versions don't have the ERR_SYSTEM_ERROR macro, but that's okay because
1714+
* they don't have the shortcoming either.
17141715
*/
17151716
#ifdefERR_SYSTEM_ERROR
17161717
if (ERR_SYSTEM_ERROR(ecode))
17171718
{
1718-
strlcpy(errbuf,strerror(ERR_GET_REASON(ecode)),SSL_ERR_LEN);
1719+
strerror_r(ERR_GET_REASON(ecode),errbuf,SSL_ERR_LEN);
17191720
returnerrbuf;
17201721
}
17211722
#endif

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp