summaryrefslogtreecommitdiff
path: root/network_io/unix
diff options
context:
space:
mode:
authorjorton <jorton@13f79535-47bb-0310-9956-ffa450edef68>2010-08-09 12:51:29 +0000
committerjorton <jorton@13f79535-47bb-0310-9956-ffa450edef68>2010-08-09 12:51:29 +0000
commited2ca99a6aceb2db4f679162e7897536a68864f0 (patch)
treeb94577978ba71dbe3087a11f025696456be53310 /network_io/unix
parentfca8bd46a6fb876af0def21bfc7064480870268e (diff)
downloadlibapr-ed2ca99a6aceb2db4f679162e7897536a68864f0.tar.gz
* network_io/unix/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. * test/testsock.c (test_get_addr): Enhance test case to cover this. PR: 49713 git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@983618 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'network_io/unix')
-rw-r--r--network_io/unix/sockets.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/network_io/unix/sockets.c b/network_io/unix/sockets.c
index 3523c95f5..13d3ecb0c 100644
--- a/network_io/unix/sockets.c
+++ b/network_io/unix/sockets.c
@@ -387,10 +387,13 @@ apr_status_t apr_socket_connect(apr_socket_t *sock, apr_sockaddr_t *sa)
/* A real remote address was passed in. If the unspecified
* address was used, the actual remote addr will have to be
* determined using getpeername() if required. */
- /* ### this should probably be a structure copy + fixup as per
- * _accept()'s handling of local_addr */
- sock->remote_addr = sa;
sock->remote_addr_unknown = 0;
+
+ /* Copy the address structure details in. */
+ sock->remote_addr->sa = sa->sa;
+ sock->remote_addr->salen = sa->salen;
+ /* Adjust ipaddr_ptr et al. */
+ apr_sockaddr_vars_set(sock->remote_addr, sa->family, sa->port);
}
if (sock->local_addr->port == 0) {