From 966f015b60d90f6450cbadcbfa89e21408fe52f9 Mon Sep 17 00:00:00 2001 From: Bruce Momjian Date: Wed, 16 Apr 2014 10:45:48 -0400 Subject: check socket creation errors against PGINVALID_SOCKET Previously, in some places, socket creation errors were checked for negative values, which is not true for Windows because sockets are unsigned. This masked socket creation errors on Windows. Backpatch through 9.0. 8.4 doesn't have the infrastructure to fix this. --- src/backend/libpq/auth.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/backend/libpq/auth.c') diff --git a/src/backend/libpq/auth.c b/src/backend/libpq/auth.c index c65427e53c4..a85f285e9f7 100644 --- a/src/backend/libpq/auth.c +++ b/src/backend/libpq/auth.c @@ -1673,7 +1673,7 @@ ident_inet(hbaPort *port) sock_fd = socket(ident_serv->ai_family, ident_serv->ai_socktype, ident_serv->ai_protocol); - if (sock_fd < 0) + if (sock_fd == PGINVALID_SOCKET) { ereport(LOG, (errcode_for_socket_access(), @@ -1753,7 +1753,7 @@ ident_inet(hbaPort *port) ident_response))); ident_inet_done: - if (sock_fd >= 0) + if (sock_fd != PGINVALID_SOCKET) closesocket(sock_fd); pg_freeaddrinfo_all(remote_addr.addr.ss_family, ident_serv); pg_freeaddrinfo_all(local_addr.addr.ss_family, la); @@ -2576,7 +2576,7 @@ CheckRADIUSAuth(Port *port) packet->length = htons(packet->length); sock = socket(serveraddrs[0].ai_family, SOCK_DGRAM, 0); - if (sock < 0) + if (sock == PGINVALID_SOCKET) { ereport(LOG, (errmsg("could not create RADIUS socket: %m"))); -- cgit v1.2.3