svn commit: r1924683 - in /apr/apr/branches/1.7.x: ./ CHANGES network_io/win32/sockets.c

[email protected]
Newsgroups gmane.comp.apache.apr.cvs
Message-ID <[email protected]>
Author: minfrin
Date: Fri Mar 28 15:49:17 2025
New Revision: 1924683

URL: http://svn.apache.org/viewvc?rev=1924683&view=rev
Log:
Backport r1920061.

* 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.

Modified:
    apr/apr/branches/1.7.x/   (props changed)
    apr/apr/branches/1.7.x/CHANGES
    apr/apr/branches/1.7.x/network_io/win32/sockets.c

Propchange: apr/apr/branches/1.7.x/
------------------------------------------------------------------------------
  Merged /apr/apr/trunk:r1920061

Modified: apr/apr/branches/1.7.x/CHANGES
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.7.x/CHANGES?rev=1924683&r1=1924682&r2=1924683&view=diff
==============================================================================
--- apr/apr/branches/1.7.x/CHANGES [utf-8] (original)
+++ apr/apr/branches/1.7.x/CHANGES [utf-8] Fri Mar 28 15:49:17 2025
@@ -1,5 +1,12 @@
                                                      -*- coding: utf-8 -*-
 Changes for APR 1.7.6
+
+  *) 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. [Ivan Zhakov]
+
   *) CMake: Install include/apr_encode.h. [Ivan Zhakov]
 
   *) CMake: Fix installation PDB files with multi-config generators.

Modified: apr/apr/branches/1.7.x/network_io/win32/sockets.c
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.7.x/network_io/win32/sockets.c?rev=1924683&r1=1924682&r2=1924683&view=diff
==============================================================================
--- apr/apr/branches/1.7.x/network_io/win32/sockets.c (original)
+++ apr/apr/branches/1.7.x/network_io/win32/sockets.c Fri Mar 28 15:49:17 2025
@@ -414,7 +414,10 @@ APR_DECLARE(apr_status_t) apr_socket_con
         sock->remote_addr_unknown = 0;
 
         /* Copy the address structure details in. */
-        sock->remote_addr = sa;
+        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->sa.sin.sin_port == 0) {
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.