httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Yann Ylavic <ylavic....@gmail.com>
Subject ProxySourceAddress leak
Date Wed, 25 Sep 2013 08:38:05 GMT
Hi devs,

I suspect a memory leak in the following code/patch related to
ProxySourceAddress.

Since the local_addr is associated with the socket, it should have the same
pool (lifetime), which is conn->scpool and not conn->pool.

The less the socket is reused (disablereuse/is_address_reusable/backend
close), the more the leak is substantial (although not reusing a bound
socket to connect the same backend port can be problematic per se...).

Regards,
Yann.

Index: modules/proxy/proxy_util.c
===================================================================
--- modules/proxy/proxy_util.c    (revision 1526127)
+++ modules/proxy/proxy_util.c    (working copy)
@@ -2572,9 +2572,9 @@ PROXY_DECLARE(int) ap_proxy_connect_backend(const
                          proxy_function, backend_addr->family,
worker->s->hostname);

             if (conf->source_address_set) {
-                local_addr = apr_pmemdup(conn->pool, conf->source_address,
+                local_addr = apr_pmemdup(conn->scpool,
conf->source_address,
                                          sizeof(apr_sockaddr_t));
-                local_addr->pool = conn->pool;
+                local_addr->pool = conn->scpool;
                 rv = apr_socket_bind(newsock, local_addr);
                 if (rv != APR_SUCCESS) {
                     ap_log_error(APLOG_MARK, APLOG_ERR, rv, s,
APLOGNO(00956)

Mime
View raw message