Module: kamailio
Branch: master
Commit: d1118064d04bb77c818540e68edf1766db1d560a
URL:
https://github.com/kamailio/kamailio/commit/d1118064d04bb77c818540e68edf176…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2024-04-05T16:19:42+02:00
siputils: tel2sip2() - memset to 0 pkg allocs and recompute len of new uri
---
Modified: src/modules/siputils/checks.c
---
Diff:
https://github.com/kamailio/kamailio/commit/d1118064d04bb77c818540e68edf176…
Patch:
https://github.com/kamailio/kamailio/commit/d1118064d04bb77c818540e68edf176…
---
diff --git a/src/modules/siputils/checks.c b/src/modules/siputils/checks.c
index 2ba80b5be94..6cc977197fb 100644
--- a/src/modules/siputils/checks.c
+++ b/src/modules/siputils/checks.c
@@ -780,7 +780,7 @@ int tel2sip2(struct sip_msg *_msg, char *_uri, char *_hostpart, char
*_res)
return 1;
/* reserve memory for clean tel uri */
- tel_uri.s = pkg_malloc(uri.len + 1);
+ tel_uri.s = pkg_mallocxz(uri.len + 1);
if(tel_uri.s == 0) {
LM_ERR("no more pkg memory\n");
return -1;
@@ -839,7 +839,7 @@ int tel2sip2(struct sip_msg *_msg, char *_uri, char *_hostpart, char
*_res)
/* reserve memory for resulting sip uri */
sip_uri.len = 4 + tel_uri.len - 4 + 1 + hostpart.len + 1 + 10;
- sip_uri.s = pkg_malloc(sip_uri.len + 1);
+ sip_uri.s = pkg_mallocxz(sip_uri.len + 1);
if(sip_uri.s == 0) {
LM_ERR("no more pkg memory\n");
pkg_free(tel_uri.s);
@@ -873,6 +873,8 @@ int tel2sip2(struct sip_msg *_msg, char *_uri, char *_hostpart, char
*_res)
/* tel_uri is not needed anymore */
pkg_free(tel_uri.s);
+ sip_uri.len = strlen(sip_uri.s);
+
/* set result pv value and write sip uri to result pv */
res_val.rs = sip_uri;
res_val.flags = PV_VAL_STR;