mirror of https://github.com/sipwise/kamailio.git
Change-Id: Ic0f1c7c8227e18130bb1ca37e7ba64e4699eff2dmr10.5.3
parent
fb8efd0ff8
commit
d71b0ca8bd
@ -1,30 +0,0 @@
|
|||||||
From: Victor Seva <vseva@sipwise.com>
|
|
||||||
Date: Wed, 22 Jun 2022 12:26:46 +0200
|
|
||||||
Subject: core: fix freeaddrinfo coredump
|
|
||||||
|
|
||||||
> #0 __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
|
|
||||||
> #1 0x00007fbb5e515537 in __GI_abort () at abort.c:79
|
|
||||||
> #2 0x00007fbb5e56e768 in __libc_message (action=action@entry=do_abort, fmt=fmt@entry=0x7fbb5e67ce2d "%s\n") at ../sysdeps/posix/libc_fatal.c:155
|
|
||||||
> #3 0x00007fbb5e575a5a in malloc_printerr (str=str@entry=0x7fbb5e67b05a "free(): invalid pointer") at malloc.c:5347
|
|
||||||
> #4 0x00007fbb5e576c14 in _int_free (av=<optimized out>, p=<optimized out>, have_lock=0) at malloc.c:4173
|
|
||||||
> #5 0x00007fbb5e5d8da0 in __GI_freeaddrinfo (ai=ai@entry=0x7fbb5e83ba10) at ../sysdeps/posix/getaddrinfo.c:2520
|
|
||||||
> #6 0x000055ba099dcd0b in log_init () at core/dprint.c:482
|
|
||||||
> #7 0x000055ba09970d7a in main (argc=10, argv=0x7ffde85a1788) at main.c:2055
|
|
||||||
---
|
|
||||||
src/core/dprint.c | 3 ++-
|
|
||||||
1 file changed, 2 insertions(+), 1 deletion(-)
|
|
||||||
|
|
||||||
diff --git a/src/core/dprint.c b/src/core/dprint.c
|
|
||||||
index 9b01dc8..f4780bb 100644
|
|
||||||
--- a/src/core/dprint.c
|
|
||||||
+++ b/src/core/dprint.c
|
|
||||||
@@ -459,7 +459,8 @@ static str log_prefix_str = STR_NULL;
|
|
||||||
|
|
||||||
void log_init(void)
|
|
||||||
{
|
|
||||||
- struct addrinfo hints, *info;
|
|
||||||
+ struct addrinfo hints;
|
|
||||||
+ struct addrinfo *info = NULL;
|
|
||||||
int gai_result;
|
|
||||||
char hostname[1024];
|
|
||||||
|
|
||||||
@ -1,209 +0,0 @@
|
|||||||
From: Victor Seva <vseva@sipwise.com>
|
|
||||||
Date: Wed, 29 Jun 2022 09:03:14 +0200
|
|
||||||
Subject: presence: be more resilient doing clean up of presentity values
|
|
||||||
|
|
||||||
previously if an error was found we were bailing out and the value
|
|
||||||
was kept so at next round the value will be there and no more values
|
|
||||||
where removed
|
|
||||||
---
|
|
||||||
src/modules/presence/publish.c | 97 +++++++++++++++++++++++++-----------------
|
|
||||||
1 file changed, 58 insertions(+), 39 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/src/modules/presence/publish.c b/src/modules/presence/publish.c
|
|
||||||
index 8889a2e..480ac7b 100644
|
|
||||||
--- a/src/modules/presence/publish.c
|
|
||||||
+++ b/src/modules/presence/publish.c
|
|
||||||
@@ -69,6 +69,7 @@ void ps_presentity_db_timer_clean(unsigned int ticks, void *param)
|
|
||||||
int n_db_cols = 0, n_result_cols = 0;
|
|
||||||
int event_col, etag_col, user_col, domain_col;
|
|
||||||
int i = 0, num_watchers = 0;
|
|
||||||
+ pres_ev_t fake;
|
|
||||||
presentity_t pres;
|
|
||||||
str uri = {0, 0}, event, *rules_doc = NULL;
|
|
||||||
static str query_str;
|
|
||||||
@@ -121,6 +122,7 @@ void ps_presentity_db_timer_clean(unsigned int ticks, void *param)
|
|
||||||
rows = RES_ROWS(result);
|
|
||||||
|
|
||||||
for(i = 0; i < RES_ROW_N(result); i++) {
|
|
||||||
+ num_watchers = 0;
|
|
||||||
values = ROW_VALUES(&rows[i]);
|
|
||||||
memset(&pres, 0, sizeof(presentity_t));
|
|
||||||
|
|
||||||
@@ -134,28 +136,33 @@ void ps_presentity_db_timer_clean(unsigned int ticks, void *param)
|
|
||||||
event.len = strlen(event.s);
|
|
||||||
pres.event = contains_event(&event, NULL);
|
|
||||||
if(pres.event == NULL || pres.event->evp == NULL) {
|
|
||||||
- LM_ERR("event not found\n");
|
|
||||||
- goto error;
|
|
||||||
+ LM_ERR("event[%.*s] not found\n", STR_FMT(&event));
|
|
||||||
+ memset(&fake, 0, sizeof(pres_ev_t));
|
|
||||||
+ fake.name = event;
|
|
||||||
+ pres.event = &fake;
|
|
||||||
+ goto simple_error;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(uandd_to_uri(pres.user, pres.domain, &uri) < 0) {
|
|
||||||
- LM_ERR("constructing uri\n");
|
|
||||||
- goto error;
|
|
||||||
+ LM_ERR("constructing uri from [user]=%.*s [domain]=%.*s\n",
|
|
||||||
+ STR_FMT(&pres.user), STR_FMT(&pres.domain));
|
|
||||||
+ goto simple_error;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* delete from hash table */
|
|
||||||
if(publ_cache_mode==PS_PCACHE_HYBRID
|
|
||||||
&& delete_phtable(&uri, pres.event->evp->type) < 0) {
|
|
||||||
- LM_ERR("deleting from presentity hash table\n");
|
|
||||||
- goto error;
|
|
||||||
+ LM_ERR("deleting uri[%.*s] event[%.*s] from presentity hash table\n",
|
|
||||||
+ STR_FMT(&uri), STR_FMT(&event));
|
|
||||||
+ goto simple_error;
|
|
||||||
}
|
|
||||||
|
|
||||||
- LM_DBG("found expired publish for [user]=%.*s [domanin]=%.*s\n",
|
|
||||||
+ LM_DBG("found expired publish for [user]=%.*s [domain]=%.*s\n",
|
|
||||||
pres.user.len, pres.user.s, pres.domain.len, pres.domain.s);
|
|
||||||
|
|
||||||
if(pres_force_delete == 1) {
|
|
||||||
if(delete_presentity(&pres, NULL) < 0) {
|
|
||||||
- LM_ERR("Deleting presentity\n");
|
|
||||||
+ LM_ERR("Deleting presentity uri[%.*s]\n", STR_FMT(&uri));
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
} else if(pres_notifier_processes > 0) {
|
|
||||||
@@ -171,7 +178,7 @@ void ps_presentity_db_timer_clean(unsigned int ticks, void *param)
|
|
||||||
if(pa_dbf.abort_transaction(pa_db) < 0)
|
|
||||||
LM_ERR("in abort_transaction\n");
|
|
||||||
}
|
|
||||||
- goto error;
|
|
||||||
+ goto next;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(num_watchers > 0) {
|
|
||||||
@@ -181,12 +188,12 @@ void ps_presentity_db_timer_clean(unsigned int ticks, void *param)
|
|
||||||
if(pa_dbf.abort_transaction(pa_db) < 0)
|
|
||||||
LM_ERR("in abort_transaction\n");
|
|
||||||
}
|
|
||||||
- goto error;
|
|
||||||
+ goto next;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if(delete_presentity(&pres, NULL) < 0) {
|
|
||||||
- LM_ERR("Deleting presentity\n");
|
|
||||||
- goto error;
|
|
||||||
+ LM_ERR("Deleting presentity uri[%.*s]\n", STR_FMT(&uri));
|
|
||||||
+ goto next;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(pa_dbf.end_transaction) {
|
|
||||||
@@ -201,22 +208,30 @@ void ps_presentity_db_timer_clean(unsigned int ticks, void *param)
|
|
||||||
&pres.user, &pres.domain, &rules_doc)
|
|
||||||
< 0) {
|
|
||||||
LM_ERR("getting rules doc\n");
|
|
||||||
- goto error;
|
|
||||||
+ goto simple_error;
|
|
||||||
}
|
|
||||||
if(publ_notify(&pres, uri, NULL, &pres.etag, rules_doc) < 0) {
|
|
||||||
LM_ERR("sending Notify request\n");
|
|
||||||
- goto error;
|
|
||||||
- }
|
|
||||||
- if(rules_doc) {
|
|
||||||
- if(rules_doc->s)
|
|
||||||
- pkg_free(rules_doc->s);
|
|
||||||
- pkg_free(rules_doc);
|
|
||||||
- rules_doc = NULL;
|
|
||||||
+ goto simple_error;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
- pkg_free(uri.s);
|
|
||||||
- uri.s = NULL;
|
|
||||||
+simple_error:
|
|
||||||
+ if(num_watchers == 0 && delete_presentity(&pres, NULL) < 0) {
|
|
||||||
+ LM_ERR("Deleting presentity\n");
|
|
||||||
+ }
|
|
||||||
+next:
|
|
||||||
+ if(uri.s) {
|
|
||||||
+ pkg_free(uri.s);
|
|
||||||
+ uri.s = NULL;
|
|
||||||
+ }
|
|
||||||
+ if(rules_doc) {
|
|
||||||
+ if(rules_doc->s) {
|
|
||||||
+ pkg_free(rules_doc->s);
|
|
||||||
+ }
|
|
||||||
+ pkg_free(rules_doc);
|
|
||||||
+ rules_doc = NULL;
|
|
||||||
+ }
|
|
||||||
}
|
|
||||||
} while(db_fetch_next(&pa_dbf, pres_fetch_rows, pa_db, &result) == 1
|
|
||||||
&& RES_ROW_N(result) > 0);
|
|
||||||
@@ -277,22 +292,23 @@ void ps_ptable_timer_clean(unsigned int ticks, void *param)
|
|
||||||
pres.etag = ptn->etag;
|
|
||||||
pres.event = contains_event(&ptn->event, NULL);
|
|
||||||
if(pres.event == NULL || pres.event->evp == NULL) {
|
|
||||||
- LM_ERR("event not found\n");
|
|
||||||
- goto error;
|
|
||||||
+ LM_ERR("event[%.*s] not found\n", STR_FMT(&ptn->event));
|
|
||||||
+ goto next;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(uandd_to_uri(pres.user, pres.domain, &uri) < 0) {
|
|
||||||
- LM_ERR("constructing uri\n");
|
|
||||||
- goto error;
|
|
||||||
+ LM_ERR("constructing uri from [user]=%.*s [domain]=%.*s\n",
|
|
||||||
+ STR_FMT(&pres.user), STR_FMT(&pres.domain));
|
|
||||||
+ goto next;
|
|
||||||
}
|
|
||||||
|
|
||||||
- LM_DBG("found expired publish for [user]=%.*s [domanin]=%.*s\n",
|
|
||||||
+ LM_DBG("found expired publish for [user]=%.*s [domain]=%.*s\n",
|
|
||||||
pres.user.len, pres.user.s, pres.domain.len, pres.domain.s);
|
|
||||||
|
|
||||||
if(pres_force_delete == 1) {
|
|
||||||
if(ps_ptable_remove(ptn) <0) {
|
|
||||||
LM_ERR("Deleting presentity\n");
|
|
||||||
- goto error;
|
|
||||||
+ goto next;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if(pres.event->get_rules_doc
|
|
||||||
@@ -300,25 +316,28 @@ void ps_ptable_timer_clean(unsigned int ticks, void *param)
|
|
||||||
&pres.user, &pres.domain, &rules_doc)
|
|
||||||
< 0) {
|
|
||||||
LM_ERR("getting rules doc\n");
|
|
||||||
- goto error;
|
|
||||||
+ goto next;
|
|
||||||
}
|
|
||||||
if(publ_notify(&pres, uri, NULL, &pres.etag, rules_doc) < 0) {
|
|
||||||
LM_ERR("sending Notify request\n");
|
|
||||||
- goto error;
|
|
||||||
- }
|
|
||||||
- if(rules_doc) {
|
|
||||||
- if(rules_doc->s)
|
|
||||||
- pkg_free(rules_doc->s);
|
|
||||||
- pkg_free(rules_doc);
|
|
||||||
- rules_doc = NULL;
|
|
||||||
+ goto next;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
- pkg_free(uri.s);
|
|
||||||
- uri.s = NULL;
|
|
||||||
+next:
|
|
||||||
+ if(uri.s) {
|
|
||||||
+ pkg_free(uri.s);
|
|
||||||
+ uri.s = NULL;
|
|
||||||
+ }
|
|
||||||
+ if(rules_doc) {
|
|
||||||
+ if(rules_doc->s) {
|
|
||||||
+ pkg_free(rules_doc->s);
|
|
||||||
+ }
|
|
||||||
+ pkg_free(rules_doc);
|
|
||||||
+ rules_doc = NULL;
|
|
||||||
+ }
|
|
||||||
}
|
|
||||||
|
|
||||||
-error:
|
|
||||||
for(ptn = ptlist; ptn != NULL; ptn = ptn->next) {
|
|
||||||
if(ps_ptable_remove(ptn) <0) {
|
|
||||||
LM_ERR("failed deleting presentity item\n");
|
|
||||||
@ -1,238 +0,0 @@
|
|||||||
From: Victor Seva <vseva@sipwise.com>
|
|
||||||
Date: Wed, 22 Jun 2022 15:12:33 +0200
|
|
||||||
Subject: pv_headers: rework pvh_remove_header_param
|
|
||||||
|
|
||||||
* fix KEMI interface, this is suppose to be called
|
|
||||||
like pvh_remove_header_param(header_name, string_to_remove)
|
|
||||||
* use pv buffer for temporal value
|
|
||||||
* use xavi interface to set the new value
|
|
||||||
---
|
|
||||||
src/modules/pv_headers/pv_headers.c | 63 +++++++++++++++---------
|
|
||||||
src/modules/pv_headers/pvh_func.c | 96 +++++++++++++------------------------
|
|
||||||
src/modules/pv_headers/pvh_func.h | 2 +-
|
|
||||||
3 files changed, 76 insertions(+), 85 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/src/modules/pv_headers/pv_headers.c b/src/modules/pv_headers/pv_headers.c
|
|
||||||
index fb20dfc..e555e02 100644
|
|
||||||
--- a/src/modules/pv_headers/pv_headers.c
|
|
||||||
+++ b/src/modules/pv_headers/pv_headers.c
|
|
||||||
@@ -220,15 +220,47 @@ static int w_pvh_header_param_exists(
|
|
||||||
return pvh_header_param_exists(msg, &hname, &value);
|
|
||||||
}
|
|
||||||
|
|
||||||
+static int ki_pvh_remove_header_param(struct sip_msg *msg, str *hname, str *toRemove)
|
|
||||||
+{
|
|
||||||
+ int idx;
|
|
||||||
+ int new_size;
|
|
||||||
+ str dst = STR_NULL;
|
|
||||||
+ sr_xavp_t *avi = pvh_xavi_get_child(msg, &xavi_name, hname);
|
|
||||||
+
|
|
||||||
+ for(idx=0; avi != NULL; avi = xavi_get_next(avi)) {
|
|
||||||
+ if (avi->val.type == SR_XTYPE_STR && avi->val.v.s.s != NULL) {
|
|
||||||
+ if(str_casesearch(&avi->val.v.s, toRemove) != NULL) {
|
|
||||||
+ new_size = pvh_remove_header_param_helper(&avi->val.v.s, toRemove, &dst);
|
|
||||||
+ if(dst.len == 0) {
|
|
||||||
+ LM_DBG("nothing left in the header:%.*s, remove it[%d]\n",
|
|
||||||
+ STR_FMT(hname), idx);
|
|
||||||
+ if(pvh_remove_header(msg, hname, idx) < 0)
|
|
||||||
+ return -1;
|
|
||||||
+ } else if(dst.len < 0 || new_size == avi->val.v.s.len) {
|
|
||||||
+ LM_DBG("'%.*s' not found at '%.*s'\n", STR_FMT(toRemove),
|
|
||||||
+ STR_FMT(&avi->val.v.s));
|
|
||||||
+ } else {
|
|
||||||
+ LM_DBG("old_value:'%.*s' new_value:'%.*s'\n",
|
|
||||||
+ STR_FMT(&avi->val.v.s), STR_FMT(&dst));
|
|
||||||
+ if(pvh_set_xavi(msg, &xavi_name, hname, &dst, SR_XTYPE_STR, idx, 0) < 0) {
|
|
||||||
+ LM_ERR("can't set new value\n");
|
|
||||||
+ return -1;
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+ } else {
|
|
||||||
+ LM_DBG("'%.*s' not found at '%.*s'\n", STR_FMT(toRemove),
|
|
||||||
+ STR_FMT(&avi->val.v.s));
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+ idx++;
|
|
||||||
+ }
|
|
||||||
+ return 1;
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
static int w_pvh_remove_header_param(struct sip_msg *msg, char *p1, char *p2)
|
|
||||||
{
|
|
||||||
- int ret = -1;
|
|
||||||
- int idx = 0;
|
|
||||||
str hname = STR_NULL;
|
|
||||||
str value = STR_NULL;
|
|
||||||
- sr_xavp_t *avi=NULL;
|
|
||||||
- char tt[header_name_size];
|
|
||||||
- str br_xname = {tt, header_name_size};
|
|
||||||
|
|
||||||
if(fixup_get_svalue(msg, (gparam_p)p1, &hname) < 0)
|
|
||||||
return -1;
|
|
||||||
@@ -236,20 +268,7 @@ static int w_pvh_remove_header_param(struct sip_msg *msg, char *p1, char *p2)
|
|
||||||
if(p2 && fixup_get_svalue(msg, (gparam_p)p2, &value) < 0)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
- pvh_get_branch_xname(msg, &xavi_name, &br_xname);
|
|
||||||
-
|
|
||||||
- avi = xavi_get_child(&br_xname, &hname);
|
|
||||||
-
|
|
||||||
- while(avi)
|
|
||||||
- {
|
|
||||||
- if (avi->val.type == SR_XTYPE_STR && avi->val.v.s.s != NULL && _strnstr(avi->val.v.s.s, value.s, avi->val.v.s.len) != NULL) {
|
|
||||||
- ret = pvh_remove_header_param(msg, idx, &hname, &avi->val.v.s, &value) && ret;
|
|
||||||
- }
|
|
||||||
- idx++;
|
|
||||||
- avi = xavi_get_next(avi);
|
|
||||||
- }
|
|
||||||
-
|
|
||||||
- return ret;
|
|
||||||
+ return ki_pvh_remove_header_param(msg, &hname, &value);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* clang-format off */
|
|
||||||
@@ -594,9 +613,9 @@ static sr_kemi_t pvh_kemi_exports[] = {
|
|
||||||
SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE}
|
|
||||||
},
|
|
||||||
{ str_init("pv_headers"), str_init("pvh_remove_header_param"),
|
|
||||||
- SR_KEMIP_INT, pvh_remove_header_param,
|
|
||||||
- { SR_KEMIP_INT, SR_KEMIP_STR, SR_KEMIP_STR,
|
|
||||||
- SR_KEMIP_STR, SR_KEMIP_NONE, SR_KEMIP_NONE}
|
|
||||||
+ SR_KEMIP_INT, ki_pvh_remove_header_param,
|
|
||||||
+ { SR_KEMIP_STR, SR_KEMIP_STR, SR_KEMIP_NONE,
|
|
||||||
+ SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE}
|
|
||||||
},
|
|
||||||
{{0, 0}, {0, 0}, 0, NULL, {0, 0, 0, 0, 0, 0}}
|
|
||||||
};
|
|
||||||
diff --git a/src/modules/pv_headers/pvh_func.c b/src/modules/pv_headers/pvh_func.c
|
|
||||||
index dde1b83..a6adaa1 100644
|
|
||||||
--- a/src/modules/pv_headers/pvh_func.c
|
|
||||||
+++ b/src/modules/pv_headers/pvh_func.c
|
|
||||||
@@ -22,7 +22,7 @@
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
-
|
|
||||||
+#include "../../core/pvapi.h"
|
|
||||||
#include "../../core/strutils.h"
|
|
||||||
|
|
||||||
#include "pv_headers.h"
|
|
||||||
@@ -381,73 +381,45 @@ int pvh_header_param_exists(struct sip_msg *msg, str *hname, str *hvalue)
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
-int pvh_remove_header_param(struct sip_msg *msg, int idx, str *hname, str *elements, str *toRemove)
|
|
||||||
+int pvh_remove_header_param_helper(str *orig, const str *toRemove, str *dst)
|
|
||||||
{
|
|
||||||
- int notTarget, writtenChars;
|
|
||||||
+ int notTarget;
|
|
||||||
+ int writtenChars = 0;
|
|
||||||
int offset = 0;
|
|
||||||
- int ret = -1;
|
|
||||||
- char *next_token;
|
|
||||||
+ char *saveptr = NULL;
|
|
||||||
char *token;
|
|
||||||
- char *result = (char*)pkg_malloc(elements->len - toRemove->len);
|
|
||||||
- char *t = (char*)pkg_malloc(elements->len+1);
|
|
||||||
-
|
|
||||||
- if (result == NULL || t == NULL)
|
|
||||||
- {
|
|
||||||
- PKG_MEM_ERROR;
|
|
||||||
- goto clean;
|
|
||||||
- }
|
|
||||||
-
|
|
||||||
- snprintf(t, elements->len+1, "%s", elements->s);
|
|
||||||
-
|
|
||||||
- token = strtok_r(t, ", ", &next_token);
|
|
||||||
- while(token)
|
|
||||||
- {
|
|
||||||
- notTarget = strncmp(token, toRemove->s, toRemove->len);
|
|
||||||
- if (notTarget)
|
|
||||||
- {
|
|
||||||
- writtenChars = snprintf(result + offset, elements->len - offset, "%s", token);
|
|
||||||
- if (writtenChars < 0 || writtenChars >= elements->len - offset)
|
|
||||||
- {
|
|
||||||
- break;
|
|
||||||
- }
|
|
||||||
- offset += writtenChars;
|
|
||||||
- }
|
|
||||||
- token = strtok_r(NULL, ", ", &next_token);
|
|
||||||
- if (token && notTarget && elements->len - offset - toRemove->len > 2)
|
|
||||||
- {
|
|
||||||
- writtenChars = snprintf(result + offset, elements->len - offset, ", ");
|
|
||||||
- if (writtenChars < 0 || writtenChars >= elements->len - offset)
|
|
||||||
- {
|
|
||||||
- break;
|
|
||||||
- }
|
|
||||||
+ char t[header_value_size];
|
|
||||||
+ char *result = pv_get_buffer();
|
|
||||||
+ int maxSize = pv_get_buffer_size();
|
|
||||||
+
|
|
||||||
+ memset(result, 0, maxSize);
|
|
||||||
+ LM_DBG("orig:'%.*s' toRemove:'%.*s'\n", STR_FMT(orig), STR_FMT(toRemove));
|
|
||||||
+ strncpy(t, orig->s, orig->len);
|
|
||||||
+ t[orig->len] = '\0';
|
|
||||||
+ token = strtok_r(t, ", ", &saveptr);
|
|
||||||
+ dst->s = NULL; dst->len = -1;
|
|
||||||
+ while(token) {
|
|
||||||
+ notTarget = strncasecmp(token, toRemove->s, toRemove->len);
|
|
||||||
+ LM_DBG("offset:%d token:%s notTarget:%d\n", offset, token, notTarget);
|
|
||||||
+ if(notTarget) {
|
|
||||||
+ writtenChars = snprintf(result + offset, maxSize - offset, "%s, ", token);
|
|
||||||
+ if(writtenChars < 0) break;
|
|
||||||
offset += writtenChars;
|
|
||||||
+ } else {
|
|
||||||
+ dst->len = 0; /* we found a token */
|
|
||||||
}
|
|
||||||
+ token = strtok_r(NULL, ", ", &saveptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
- if (elements->len-toRemove->len > 0)
|
|
||||||
- {
|
|
||||||
- snprintf(elements->s, (strlen(result)%elements->len)+1, "%s", result);
|
|
||||||
- elements->len = strlen(result);
|
|
||||||
- ret = 1;
|
|
||||||
- }
|
|
||||||
- else
|
|
||||||
- {
|
|
||||||
- ret = pvh_remove_header(msg, hname, idx);
|
|
||||||
- }
|
|
||||||
-
|
|
||||||
-clean:
|
|
||||||
-
|
|
||||||
- if(t != NULL)
|
|
||||||
- {
|
|
||||||
- pkg_free(t);
|
|
||||||
- t = NULL;
|
|
||||||
- }
|
|
||||||
-
|
|
||||||
- if(result != NULL)
|
|
||||||
- {
|
|
||||||
- pkg_free(result);
|
|
||||||
- result = NULL;
|
|
||||||
+ if(offset > 0) {
|
|
||||||
+ dst->s = result;
|
|
||||||
+ if(offset > 2 && result[offset-2] == ',' && result[offset-1] == ' ') {
|
|
||||||
+ LM_DBG("remove last separator\n");
|
|
||||||
+ offset = offset - 2;
|
|
||||||
+ result[offset] = '\0';
|
|
||||||
+ }
|
|
||||||
+ dst->len = offset;
|
|
||||||
+ LM_DBG("offset:%d result:'%.*s'[%d]\n", offset, STR_FMT(dst), dst->len);
|
|
||||||
}
|
|
||||||
-
|
|
||||||
- return ret;
|
|
||||||
+ return offset;
|
|
||||||
}
|
|
||||||
diff --git a/src/modules/pv_headers/pvh_func.h b/src/modules/pv_headers/pvh_func.h
|
|
||||||
index a4e0bfa..737212c 100644
|
|
||||||
--- a/src/modules/pv_headers/pvh_func.h
|
|
||||||
+++ b/src/modules/pv_headers/pvh_func.h
|
|
||||||
@@ -39,6 +39,6 @@ int pvh_append_header(struct sip_msg *msg, str *hname, str *hvalue);
|
|
||||||
int pvh_modify_header(struct sip_msg *msg, str *hname, str *hvalue, int indx);
|
|
||||||
int pvh_remove_header(struct sip_msg *msg, str *hname, int indx);
|
|
||||||
int pvh_header_param_exists(struct sip_msg *msg, str *hname, str *hvalue);
|
|
||||||
-int pvh_remove_header_param(struct sip_msg *msg, int idx, str *hname, str *elements, str *toRemove);
|
|
||||||
+int pvh_remove_header_param_helper(str *orig, const str *toRemove, str *dst);
|
|
||||||
|
|
||||||
#endif /* PV_FUNC_H */
|
|
||||||
@ -1,21 +0,0 @@
|
|||||||
From: Victor Seva <vseva@sipwise.com>
|
|
||||||
Date: Mon, 4 Jul 2022 15:49:20 +0200
|
|
||||||
Subject: tm: check T just in case before UNREF
|
|
||||||
|
|
||||||
---
|
|
||||||
src/modules/tm/t_funcs.h | 2 +-
|
|
||||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
|
||||||
|
|
||||||
diff --git a/src/modules/tm/t_funcs.h b/src/modules/tm/t_funcs.h
|
|
||||||
index 6830b13..dbbdc19 100644
|
|
||||||
--- a/src/modules/tm/t_funcs.h
|
|
||||||
+++ b/src/modules/tm/t_funcs.h
|
|
||||||
@@ -110,7 +110,7 @@ int send_pr_buffer( struct retr_buf *rb, void *buf, int len);
|
|
||||||
|
|
||||||
#define UNREF_NOSTATS(_T_cell) \
|
|
||||||
do{\
|
|
||||||
- if (atomic_dec_and_test(&(_T_cell)->ref_count)){ \
|
|
||||||
+ if (_T_cell && atomic_dec_and_test(&(_T_cell)->ref_count)){ \
|
|
||||||
unlink_timers((_T_cell)); \
|
|
||||||
free_cell((_T_cell)); \
|
|
||||||
}\
|
|
||||||
@ -1,25 +0,0 @@
|
|||||||
From: Victor Seva <vseva@sipwise.com>
|
|
||||||
Date: Wed, 7 Oct 2020 15:35:50 +0200
|
|
||||||
Subject: topos: don't insert contact header for 4xx replies
|
|
||||||
|
|
||||||
unless original msg has contact
|
|
||||||
---
|
|
||||||
src/modules/topos/tps_msg.c | 5 +++++
|
|
||||||
1 file changed, 5 insertions(+)
|
|
||||||
|
|
||||||
diff --git a/src/modules/topos/tps_msg.c b/src/modules/topos/tps_msg.c
|
|
||||||
index c01dde7..a3f123b 100644
|
|
||||||
--- a/src/modules/topos/tps_msg.c
|
|
||||||
+++ b/src/modules/topos/tps_msg.c
|
|
||||||
@@ -1167,6 +1167,11 @@ int tps_response_sent(sip_msg_t *msg)
|
|
||||||
&& msg->contact==NULL) {
|
|
||||||
contact_keep = 1;
|
|
||||||
}
|
|
||||||
+ if(contact_keep==0 && msg->first_line.u.reply.statuscode>=400
|
|
||||||
+ && msg->first_line.u.reply.statuscode<500
|
|
||||||
+ && msg->contact==NULL) {
|
|
||||||
+ contact_keep = 1;
|
|
||||||
+ }
|
|
||||||
if(contact_keep==0) {
|
|
||||||
tps_remove_headers(msg, HDR_CONTACT_T);
|
|
||||||
if(direction==TPS_DIR_DOWNSTREAM) {
|
|
||||||
@ -1,33 +0,0 @@
|
|||||||
From: Daniel-Constantin Mierla <miconda@gmail.com>
|
|
||||||
Date: Tue, 21 Jun 2022 08:41:53 +0200
|
|
||||||
Subject: topos: skip adding contact header for BYE, CANCEL, PRACK
|
|
||||||
|
|
||||||
- GH #3149
|
|
||||||
---
|
|
||||||
src/modules/topos/tps_msg.c | 6 ++++++
|
|
||||||
1 file changed, 6 insertions(+)
|
|
||||||
|
|
||||||
diff --git a/src/modules/topos/tps_msg.c b/src/modules/topos/tps_msg.c
|
|
||||||
index 83d5f5f..c01dde7 100644
|
|
||||||
--- a/src/modules/topos/tps_msg.c
|
|
||||||
+++ b/src/modules/topos/tps_msg.c
|
|
||||||
@@ -46,6 +46,8 @@
|
|
||||||
#include "tps_msg.h"
|
|
||||||
#include "tps_storage.h"
|
|
||||||
|
|
||||||
+#define TPS_METHODS_NOCONTACT (METHOD_CANCEL|METHOD_BYE|METHOD_PRACK)
|
|
||||||
+
|
|
||||||
extern int _tps_param_mask_callid;
|
|
||||||
extern int _tps_contact_mode;
|
|
||||||
extern str _tps_cparam_name;
|
|
||||||
@@ -582,6 +584,10 @@ int tps_reinsert_contact(sip_msg_t *msg, tps_data_t *ptsd, str *hbody)
|
|
||||||
{
|
|
||||||
str hname = str_init("Contact");
|
|
||||||
|
|
||||||
+ if (get_cseq(msg)->method_id & TPS_METHODS_NOCONTACT) {
|
|
||||||
+ return 0;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
if(tps_add_headers(msg, &hname, hbody, 0)<0) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
@ -1,43 +0,0 @@
|
|||||||
--- a/src/modules/topos_redis/topos_redis_storage.c
|
|
||||||
+++ b/src/modules/topos_redis/topos_redis_storage.c
|
|
||||||
@@ -54,6 +54,10 @@ static str _tps_redis_dprefix = str_init
|
|
||||||
|
|
||||||
static char _tps_redis_cbuf[TPS_REDIS_DATA_SIZE];
|
|
||||||
|
|
||||||
+static str _tps_redis_empty = str_init("");
|
|
||||||
+
|
|
||||||
+#define TPS_REDIS_STRZ(_s) ((_s).s)?(_s):(_tps_redis_empty)
|
|
||||||
+
|
|
||||||
/**
|
|
||||||
* storage keys
|
|
||||||
*/
|
|
||||||
@@ -594,6 +598,7 @@ int tps_redis_load_initial_method_branch
|
|
||||||
str skey = STR_NULL;
|
|
||||||
str sval = STR_NULL;
|
|
||||||
str xuuid = str_init("");
|
|
||||||
+ str xtag = str_init("");
|
|
||||||
str smethod = str_init("INVITE");
|
|
||||||
|
|
||||||
if(msg==NULL || md==NULL || sd==NULL)
|
|
||||||
@@ -615,6 +620,12 @@ int tps_redis_load_initial_method_branch
|
|
||||||
memset(argvlen, 0, TPS_REDIS_NR_KEYS * sizeof(size_t));
|
|
||||||
argc = 0;
|
|
||||||
|
|
||||||
+ if(md->direction==TPS_DIR_DOWNSTREAM) {
|
|
||||||
+ xtag = TPS_REDIS_STRZ(md->b_tag);
|
|
||||||
+ } else {
|
|
||||||
+ xtag = TPS_REDIS_STRZ(md->a_tag);
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
if(md->a_uuid.len>1) {
|
|
||||||
xuuid.s = md->a_uuid.s + 1;
|
|
||||||
xuuid.len = md->a_uuid.len - 1;
|
|
||||||
@@ -641,7 +652,7 @@ int tps_redis_load_initial_method_branch
|
|
||||||
_tps_redis_bprefix.len, _tps_redis_bprefix.s,
|
|
||||||
smethod.len, smethod.s,
|
|
||||||
md->a_callid.len, md->a_callid.s,
|
|
||||||
- md->b_tag.len, md->b_tag.s,
|
|
||||||
+ xtag.len, xtag.s,
|
|
||||||
xuuid.len, xuuid.s);
|
|
||||||
if(rkey.len<0 || rkey.len>=TPS_REDIS_DATA_SIZE) {
|
|
||||||
LM_ERR("error or insufficient buffer size: %d\n", rkey.len);
|
|
||||||
Loading…
Reference in new issue