From adecd4dd977918ee029ad6adb161bc7402029086 Mon Sep 17 00:00:00 2001 From: Vlad Patrascu Date: Fri, 20 Nov 2020 19:34:22 +0200 Subject: [PATCH] tm: fix transaction leakage when receiving replicated CANCELs (cherry picked from commit 82b8d20f20914654938630e59edd0ca29e4e9e36) --- modules/tm/cluster.c | 6 +++++- modules/tm/tm.c | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/modules/tm/cluster.c b/modules/tm/cluster.c index 0ae276d4dad..90c6c624bee 100644 --- a/modules/tm/cluster.c +++ b/modules/tm/cluster.c @@ -36,6 +36,8 @@ static str tm_repl_cap = str_init("tm-repl"); struct clusterer_binds cluster_api; +int do_t_cleanup( struct sip_msg *req, void *bar); + #define TM_BIN_POP(_t, _f, _d) \ do { \ if (bin_pop_##_t(packet, _f) < 0) { \ @@ -142,7 +144,7 @@ static void tm_repl_cancel(bin_packet_t *packet, str *buf, struct receive_info * tmp = ip_addr2a(&(ri->src_ip)); LM_ERR("Unable to parse replicated CANCEL received from [%s:%d]\n", tmp, ri->src_port); - return; + goto cleanup; } } @@ -152,6 +154,8 @@ static void tm_repl_cancel(bin_packet_t *packet, str *buf, struct receive_info * else LM_ERR("cannot handle auto-CANCEL for %p!\n", t); +cleanup: + do_t_cleanup(&msg, NULL); free_sip_msg(&msg); } diff --git a/modules/tm/tm.c b/modules/tm/tm.c index e63da21df5a..d8d03bdbff2 100644 --- a/modules/tm/tm.c +++ b/modules/tm/tm.c @@ -759,7 +759,7 @@ int load_tm( struct tm_binds *tmb) } -static int do_t_cleanup( struct sip_msg *req, void *bar) +int do_t_cleanup( struct sip_msg *req, void *bar) { struct cell *t;