]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Allow to specify mempool when copying an IP address structure
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Sun, 20 Mar 2022 12:45:03 +0000 (12:45 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Sun, 20 Mar 2022 12:45:03 +0000 (12:45 +0000)
12 files changed:
src/fuzzy_storage.c
src/libmime/received.cxx
src/libserver/http/http_context.c
src/libutil/addr.c
src/libutil/addr.h
src/libutil/upstream.c
src/lua/lua_http.c
src/lua/lua_ip.c
src/lua/lua_task.c
src/lua/lua_udp.c
src/rspamd.c
src/rspamd_proxy.c

index b9397fc2efc86b91e708bca656486501eea658d8..3ed30b179f0e92aac984053145ee5757540c595b 100644 (file)
@@ -262,7 +262,7 @@ rspamd_fuzzy_check_ratelimit (struct fuzzy_session *session)
        }
        */
 
-       masked = rspamd_inet_address_copy (session->addr);
+       masked = rspamd_inet_address_copy(session->addr, NULL);
 
        if (rspamd_inet_address_get_af (masked) == AF_INET) {
                rspamd_inet_address_apply_mask (masked,
@@ -1098,7 +1098,7 @@ rspamd_fuzzy_process_command (struct fuzzy_session *session)
                                session->addr, -1);
 
                if (ip_stat == NULL) {
-                       naddr = rspamd_inet_address_copy (session->addr);
+                       naddr = rspamd_inet_address_copy(session->addr, NULL);
                        ip_stat = g_malloc0 (sizeof (*ip_stat));
                        REF_INIT_RETAIN (ip_stat, fuzzy_key_stat_dtor);
                        rspamd_lru_hash_insert (session->key_stat->last_ips,
@@ -1662,7 +1662,7 @@ accept_fuzzy_socket (EV_P_ ev_io *w, int revents)
                                                nerrors = g_malloc (sizeof (*nerrors));
                                                *nerrors = 1;
                                                rspamd_lru_hash_insert (session->ctx->errors_ips,
-                                                               rspamd_inet_address_copy (session->addr),
+                                                               rspamd_inet_address_copy(session->addr, NULL),
                                                                nerrors, -1, -1);
                                        }
                                        else {
index 9571580e9c987499d49b59db0fa6ca204ab268da..0886d6e37a9d9f139229d0e53547dec04dc2bdec 100644 (file)
@@ -737,7 +737,7 @@ received_maybe_fix_task(struct rspamd_task *task) -> bool
                                if (mta_name) {
                                        trecv.by_hostname.assign_copy(std::string_view(mta_name));
                                }
-                               trecv.addr = rspamd_inet_address_copy(task->from_addr);
+                               trecv.addr = rspamd_inet_address_copy(task->from_addr, NULL);
 
                                if (task->hostname) {
                                        trecv.real_hostname.assign_copy(std::string_view(task->hostname));
index e86d8ae790fc1b20b237af98582fbe67031ab1ca..87ee9268e63b453a56ad9d935cd4e4f5d5a5c76f 100644 (file)
@@ -539,7 +539,7 @@ rspamd_http_context_prepare_keepalive(struct rspamd_http_context *ctx,
                phk->conns = empty_init;
                phk->host = g_strdup (host);
                phk->is_ssl = is_ssl;
-               phk->addr = rspamd_inet_address_copy (addr);
+               phk->addr = rspamd_inet_address_copy(addr, NULL);
                phk->port = hk.port;
 
 
index b19182514701ad2d6a7c55888100d00a82874f10..d5502fce0337c462c1716592203a5d7012ae57a3 100644 (file)
@@ -1832,7 +1832,7 @@ rspamd_inet_address_compare_ptr (gconstpointer a1,
 }
 
 rspamd_inet_addr_t *
-rspamd_inet_address_copy (const rspamd_inet_addr_t *addr)
+rspamd_inet_address_copy(const rspamd_inet_addr_t *addr, rspamd_mempool_t *pool)
 {
        rspamd_inet_addr_t *n;
 
@@ -1840,7 +1840,7 @@ rspamd_inet_address_copy (const rspamd_inet_addr_t *addr)
                return NULL;
        }
 
-       n = rspamd_inet_addr_create (addr->af, NULL);
+       n = rspamd_inet_addr_create (addr->af, pool);
 
        if (n->af == AF_UNIX) {
                memcpy (n->u.un, addr->u.un, sizeof (*addr->u.un));
index 832245a4976205fc7f6a27725dfdf45456e9db2c..a839783b8349714dae4f010dd078ecc66b49554f 100644 (file)
@@ -322,7 +322,7 @@ gint rspamd_inet_address_compare_ptr (gconstpointer a1,
  * @param addr
  * @return
  */
-rspamd_inet_addr_t *rspamd_inet_address_copy (const rspamd_inet_addr_t *addr);
+rspamd_inet_addr_t *rspamd_inet_address_copy(const rspamd_inet_addr_t *addr, rspamd_mempool_t *pool);
 
 /**
  * Returns hash for inet address (ignoring port)
index 30c53daee05fad6cae8b481ae45ef764e7ea95c1..7eb3e402e6d138708c4583476a592dc738ba0447 100644 (file)
@@ -1167,7 +1167,7 @@ rspamd_upstreams_add_upstream (struct upstream_list *ups, const gchar *str,
                }
                for (i = 0; i < addrs->len; i ++) {
                        addr = g_ptr_array_index (addrs, i);
-                       rspamd_upstream_add_addr (upstream, rspamd_inet_address_copy (addr));
+                       rspamd_upstream_add_addr (upstream, rspamd_inet_address_copy(addr, NULL));
                }
        }
 
index c95f2dd0d864c0d6c1cb0a3d4eaff2ed2f76e099..51fe1f272d1d98a45444d8d1a20dc55ece679a10 100644 (file)
@@ -1078,7 +1078,7 @@ lua_http_request (lua_State *L)
                                        msg->flags & RSPAMD_HTTP_FLAG_WANT_SSL);
 
                        if (ka_addr) {
-                               cbd->addr = rspamd_inet_address_copy(ka_addr);
+                               cbd->addr = rspamd_inet_address_copy(ka_addr, NULL);
                                numeric_ip = true;
                        }
                }
index dc51a83e9a97ba631c4cb15726dea0658adae458..ad2e2e8b0ad812a889c1e90ac4284c627fce9b42 100644 (file)
@@ -210,7 +210,7 @@ lua_ip_new (lua_State *L, struct rspamd_lua_ip *old)
        ip = g_malloc0 (sizeof (*ip));
 
        if (old != NULL && old->addr != NULL) {
-               ip->addr = rspamd_inet_address_copy (old->addr);
+               ip->addr = rspamd_inet_address_copy(old->addr, NULL);
        }
 
        pip = lua_newuserdata (L, sizeof (struct rspamd_lua_ip *));
@@ -589,7 +589,7 @@ rspamd_lua_ip_push (lua_State *L, rspamd_inet_addr_t *addr)
        struct rspamd_lua_ip *ip, **pip;
 
        ip = g_malloc0 (sizeof (struct rspamd_lua_ip));
-       ip->addr = rspamd_inet_address_copy (addr);
+       ip->addr = rspamd_inet_address_copy(addr, NULL);
        pip = lua_newuserdata (L, sizeof (struct rspamd_lua_ip *));
        rspamd_lua_setclass (L, "rspamd{ip}", -1);
        *pip = ip;
index 011950125c58988428f1b77ace08f023df4d4eff..2b811f4a7cb139478b47dee0d52d2584eb7670b7 100644 (file)
@@ -4272,7 +4272,7 @@ lua_task_set_from_ip (lua_State *L)
                                        rspamd_inet_address_free (task->from_addr);
                                }
 
-                               task->from_addr = rspamd_inet_address_copy (ip->addr);
+                               task->from_addr = rspamd_inet_address_copy(ip->addr, NULL);
                        }
                        else {
                                return luaL_error (L, "invalid IP object");
index 656d8034909ae16094784ef7784b77ec284f5619..4f5696a947c71398186ab1f062bc04f46a7abb23 100644 (file)
@@ -397,7 +397,7 @@ lua_udp_sendto (lua_State *L) {
                                return luaL_error (L, "invalid host class");
                        }
 
-                       addr = rspamd_inet_address_copy (lip->addr);
+                       addr = rspamd_inet_address_copy(lip->addr, NULL);
 
                        if (port != 0) {
                                rspamd_inet_address_set_port (addr, port);
index 610c9aa7bb601a94e411e9b19bda6d15b045a3f9..230206addca10a93c928ee6faf5501a987187030 100644 (file)
@@ -413,7 +413,7 @@ create_listen_socket (GPtrArray *addrs, guint cnt,
                                        listen_opts, -1);
                        if (fd != -1) {
                                ls = g_malloc0 (sizeof (*ls));
-                               ls->addr = rspamd_inet_address_copy (g_ptr_array_index (addrs, i));
+                               ls->addr = rspamd_inet_address_copy(g_ptr_array_index (addrs, i), NULL);
                                ls->fd = fd;
                                ls->type = RSPAMD_WORKER_SOCKET_TCP;
                                result = g_list_prepend (result, ls);
@@ -425,7 +425,7 @@ create_listen_socket (GPtrArray *addrs, guint cnt,
                                        listen_opts | RSPAMD_INET_ADDRESS_LISTEN_REUSEPORT, -1);
                        if (fd != -1) {
                                ls = g_malloc0 (sizeof (*ls));
-                               ls->addr = rspamd_inet_address_copy (g_ptr_array_index (addrs, i));
+                               ls->addr = rspamd_inet_address_copy(g_ptr_array_index (addrs, i), NULL);
                                ls->fd = fd;
                                ls->type = RSPAMD_WORKER_SOCKET_UDP;
                                result = g_list_prepend (result, ls);
index 13393660e2050469da04f952e228d5ad13c08aa2..10f95e0bf483fafb91e5b1f7e0c4dc4252afaa71 100644 (file)
@@ -1804,11 +1804,11 @@ rspamd_proxy_self_scan (struct rspamd_proxy_session *session)
        task->sock = -1;
 
        if (session->client_milter_conn) {
-               task->client_addr = rspamd_inet_address_copy (
-                               session->client_milter_conn->addr);
+               task->client_addr = rspamd_inet_address_copy(
+                               session->client_milter_conn->addr, NULL);
        }
        else {
-               task->client_addr = rspamd_inet_address_copy (session->client_addr);
+               task->client_addr = rspamd_inet_address_copy(session->client_addr, NULL);
        }
 
        task->fin_arg = session;