Skip to content

Commit cd2f704

Browse files
author
Ivan Zhakov
committed
Replicate r983618 in Win32 code.
* network_io/win32/sockets.c: (apr_socket_connect): Copy the remote address by value rather than by reference. This ensures that the sockaddr object returned by apr_socket_addr_get is allocated from the same pool as the socket object itself, as apr_socket_accept does; avoiding any potential lifetime mismatches. git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1920061 13f79535-47bb-0310-9956-ffa450edef68
1 parent cd3698c commit cd2f704

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

network_io/win32/sockets.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,10 @@ APR_DECLARE(apr_status_t) apr_socket_connect(apr_socket_t *sock,
401401
sock->remote_addr_unknown = 0;
402402

403403
/* Copy the address structure details in. */
404-
sock->remote_addr = sa;
404+
sock->remote_addr->sa = sa->sa;
405+
sock->remote_addr->salen = sa->salen;
406+
/* Adjust ipaddr_ptr et al. */
407+
apr_sockaddr_vars_set(sock->remote_addr, sa->family, sa->port);
405408
}
406409

407410
if (sock->local_addr->sa.sin.sin_port == 0) {

0 commit comments

Comments
 (0)