public inbox for [email protected]  
help / color / mirror / Atom feed
pgsql: Fix gai_strerror() thread-safety on Windows.
2+ messages / 1 participants
[nested] [flat]

* pgsql: Fix gai_strerror() thread-safety on Windows.
@ 2024-02-11 22:18  Thomas Munro <[email protected]>
  0 siblings, 0 replies; 2+ messages in thread

From: Thomas Munro @ 2024-02-11 22:18 UTC (permalink / raw)
  To: [email protected]

Fix gai_strerror() thread-safety on Windows.

Commit 5579388d removed code that supplied a fallback implementation of
getaddrinfo(), which was dead code on modern systems.  One tiny piece of
the removed code was still doing something useful on Windows, though:
that OS's own gai_strerror()/gai_strerrorA() function returns a pointer
to a static buffer that it overwrites each time, so it's not
thread-safe.  In rare circumstances, a multi-threaded client program
could get an incorrect or corrupted error message.

Restore the replacement gai_strerror() function, though now that it's
only for Windows we can put it into a win32-specific file and cut it
down to the errors that Windows documents.  The error messages here are
taken from FreeBSD, because Windows' own messages seemed too verbose.

Back-patch to 16.

Reviewed-by: Kyotaro Horiguchi <[email protected]>
Discussion: https://postgr.es/m/CA%2BhUKGKz%2BF9d2PTiXwfYV7qJw%2BWg2jzACgSDgPizUw7UG%3Di58A%40mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/65f438471b769f6b9706a386028f81df065d0a25

Modified Files
--------------
configure                           |  6 +++++
configure.ac                        |  1 +
src/include/port/win32/sys/socket.h |  8 +++++++
src/port/meson.build                |  1 +
src/port/win32gai_strerror.c        | 45 +++++++++++++++++++++++++++++++++++++
5 files changed, 61 insertions(+)



^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* pgsql: Fix gai_strerror() thread-safety on Windows.
@ 2024-02-11 22:18  Thomas Munro <[email protected]>
  0 siblings, 0 replies; 2+ messages in thread

From: Thomas Munro @ 2024-02-11 22:18 UTC (permalink / raw)
  To: [email protected]

Fix gai_strerror() thread-safety on Windows.

Commit 5579388d removed code that supplied a fallback implementation of
getaddrinfo(), which was dead code on modern systems.  One tiny piece of
the removed code was still doing something useful on Windows, though:
that OS's own gai_strerror()/gai_strerrorA() function returns a pointer
to a static buffer that it overwrites each time, so it's not
thread-safe.  In rare circumstances, a multi-threaded client program
could get an incorrect or corrupted error message.

Restore the replacement gai_strerror() function, though now that it's
only for Windows we can put it into a win32-specific file and cut it
down to the errors that Windows documents.  The error messages here are
taken from FreeBSD, because Windows' own messages seemed too verbose.

Back-patch to 16.

Reviewed-by: Kyotaro Horiguchi <[email protected]>
Discussion: https://postgr.es/m/CA%2BhUKGKz%2BF9d2PTiXwfYV7qJw%2BWg2jzACgSDgPizUw7UG%3Di58A%40mail.gmail.com

Branch
------
REL_16_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/0460e4ecc0fa532468331a4b71ad0fbe8ff1a416

Modified Files
--------------
configure                           |  6 +++++
configure.ac                        |  1 +
src/include/port/win32/sys/socket.h |  8 +++++++
src/port/meson.build                |  1 +
src/port/win32gai_strerror.c        | 45 +++++++++++++++++++++++++++++++++++++
src/tools/msvc/Mkvcbuild.pm         |  1 +
6 files changed, 62 insertions(+)



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2024-02-11 22:18 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2024-02-11 22:18 pgsql: Fix gai_strerror() thread-safety on Windows. Thomas Munro <[email protected]>
2024-02-11 22:18 pgsql: Fix gai_strerror() thread-safety on Windows. Thomas Munro <[email protected]>

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox