diff options
author | Bruce Momjian <bruce@momjian.us> | 2014-04-16 10:45:48 -0400 |
---|---|---|
committer | Bruce Momjian <bruce@momjian.us> | 2014-04-16 10:45:48 -0400 |
commit | 41809346518a2b57530b22148609a346a718adc9 (patch) | |
tree | 961b8f02438fed1b5a453890a899ff0351bb7f93 /src/backend/libpq/ip.c | |
parent | 848b9f05ab283724dd063d936a92568c1fdf422b (diff) | |
download | postgresql-41809346518a2b57530b22148609a346a718adc9.tar.gz postgresql-41809346518a2b57530b22148609a346a718adc9.zip |
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.
Diffstat (limited to 'src/backend/libpq/ip.c')
-rw-r--r-- | src/backend/libpq/ip.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/backend/libpq/ip.c b/src/backend/libpq/ip.c index 7e8fc785bb4..acdbab00496 100644 --- a/src/backend/libpq/ip.c +++ b/src/backend/libpq/ip.c @@ -547,7 +547,7 @@ pg_foreach_ifaddr(PgIfAddrCallback callback, void *cb_data) int error; sock = WSASocket(AF_INET, SOCK_DGRAM, 0, 0, 0, 0); - if (sock == SOCKET_ERROR) + if (sock == INVALID_SOCKET) return -1; while (n_ii < 1024) @@ -670,7 +670,7 @@ pg_foreach_ifaddr(PgIfAddrCallback callback, void *cb_data) total; sock = socket(AF_INET, SOCK_DGRAM, 0); - if (sock == -1) + if (sock == PGINVALID_SOCKET) return -1; while (n_buffer < 1024 * 100) @@ -711,7 +711,7 @@ pg_foreach_ifaddr(PgIfAddrCallback callback, void *cb_data) #ifdef HAVE_IPV6 /* We'll need an IPv6 socket too for the SIOCGLIFNETMASK ioctls */ sock6 = socket(AF_INET6, SOCK_DGRAM, 0); - if (sock6 == -1) + if (sock6 == PGINVALID_SOCKET) { free(buffer); close(sock); @@ -788,10 +788,10 @@ pg_foreach_ifaddr(PgIfAddrCallback callback, void *cb_data) char *ptr, *buffer = NULL; size_t n_buffer = 1024; - int sock; + pgsocket sock; sock = socket(AF_INET, SOCK_DGRAM, 0); - if (sock == -1) + if (sock == PGINVALID_SOCKET) return -1; while (n_buffer < 1024 * 100) |