Module: kamailio
Branch: master
Commit: 75e3cdfacbe4172fcd6b16ab94d96e2e29229878
URL: 
https://github.com/kamailio/kamailio/commit/75e3cdfacbe4172fcd6b16ab94d96e2e29229878

Author: Alessio Garzi <[email protected]>
Committer: Victor Seva <[email protected]>
Date: 2026-05-14T16:59:29+02:00

siputils: validate SIP URI produced by tel2sip and tel2sip2

After constructing the SIP URI, call parse_uri() to verify the result
is well-formed before writing it to the output pvar. If validation
fails, free the allocated pkg memory and return -1.

---

Modified: src/modules/siputils/checks.c

---

Diff:  
https://github.com/kamailio/kamailio/commit/75e3cdfacbe4172fcd6b16ab94d96e2e29229878.diff
Patch: 
https://github.com/kamailio/kamailio/commit/75e3cdfacbe4172fcd6b16ab94d96e2e29229878.patch

---

diff --git a/src/modules/siputils/checks.c b/src/modules/siputils/checks.c
index 2eeed023fdf..21ad59d041e 100644
--- a/src/modules/siputils/checks.c
+++ b/src/modules/siputils/checks.c
@@ -645,6 +645,7 @@ int tel2sip(struct sip_msg *_msg, char *_uri, char 
*_hostpart, char *_res)
        int i, j, in_tel_parameters = 0;
        pv_spec_t *res;
        pv_value_t res_val;
+       struct sip_uri parsed_check;
 
        /* get parameters */
        if(get_str_fparam(&uri, _msg, (fparam_t *)_uri) < 0) {
@@ -709,6 +710,11 @@ int tel2sip(struct sip_msg *_msg, char *_uri, char 
*_hostpart, char *_res)
        /* tel_uri is not needed anymore */
        pkg_free(tel_uri.s);
 
+       if(parse_uri(sip_uri.s, sip_uri.len, &parsed_check) < 0) {
+               pkg_free(sip_uri.s);
+               return -1;
+       }
+
        /* set result pv value and write sip uri to result pv */
        res_val.rs = sip_uri;
        res_val.flags = PV_VAL_STR;
@@ -823,6 +829,7 @@ int tel2sip2(struct sip_msg *_msg, char *_uri, char 
*_hostpart, char *_res)
        pv_value_t res_val;
        char *tmp_ptr = NULL;
        tel_param_t params[MAX_TEL_PARAMS];
+       struct sip_uri parsed_check;
 
        /* get parameters */
        if(get_str_fparam(&uri, _msg, (fparam_t *)_uri) < 0) {
@@ -935,6 +942,11 @@ int tel2sip2(struct sip_msg *_msg, char *_uri, char 
*_hostpart, char *_res)
        /* tel_uri is not needed anymore */
        pkg_free(tel_uri.s);
 
+       if(parse_uri(sip_uri.s, sip_uri.len, &parsed_check) < 0) {
+               pkg_free(sip_uri.s);
+               return -1;
+       }
+
        sip_uri.len = strlen(sip_uri.s);
 
        /* set result pv value and write sip uri to result pv */

_______________________________________________
Kamailio - Development Mailing List -- [email protected]
To unsubscribe send an email to [email protected]
Important: keep the mailing list in the recipients, do not reply only to the 
sender!

Reply via email to