]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Use SOCK_ERRNO[_SET] in fe-secure-gssapi.c. REL_14_STABLE github/REL_14_STABLE
authorTom Lane <tgl@sss.pgh.pa.us>
Sun, 5 Oct 2025 20:27:47 +0000 (16:27 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Sun, 5 Oct 2025 20:27:47 +0000 (16:27 -0400)
commitf46d77377b9a0be25524a6339296c8a892059f2c
treebeecc58be42c5d5260977bfcf3431b052d7c2142
parent9b3beb7c6f12597830c68ffa36abe1c23f366454
Use SOCK_ERRNO[_SET] in fe-secure-gssapi.c.

On Windows, this code did not handle error conditions correctly at
all, since it looked at "errno" which is not used for socket-related
errors on that platform.  This resulted, for example, in failure
to connect to a PostgreSQL server with GSSAPI enabled.

We have a convention for dealing with this within libpq, which is to
use SOCK_ERRNO and SOCK_ERRNO_SET rather than touching errno directly;
but the GSSAPI code is a relative latecomer and did not get that memo.
(The equivalent backend code continues to use errno, because the
backend does this differently.  Maybe libpq's approach should be
rethought someday.)

Apparently nobody tries to build libpq with GSSAPI support on Windows,
or we'd have heard about this before, because it's been broken all
along.  Back-patch to all supported branches.

Author: Ning Wu <ning94803@gmail.com>
Co-authored-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/CAFGqpvg-pRw=cdsUpKYfwY6D3d-m9tw8WMcAEE7HHWfm-oYWvw@mail.gmail.com
Backpatch-through: 13
src/interfaces/libpq/fe-secure-gssapi.c