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

Author: Daniel-Constantin Mierla <[email protected]>
Committer: Daniel-Constantin Mierla <[email protected]>
Date: 2026-02-13T09:59:11+01:00

pv: manage if changing uri to from/to needs enclosing

---

Modified: src/modules/pv/pv_core.c

---

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

---

diff --git a/src/modules/pv/pv_core.c b/src/modules/pv/pv_core.c
index a1064738bba..cd7840fd5d2 100644
--- a/src/modules/pv/pv_core.c
+++ b/src/modules/pv/pv_core.c
@@ -3657,6 +3657,7 @@ int pv_set_xto_attr(struct sip_msg *msg, pv_param_t 
*param, int op,
        int llen = 0;
        int llen_uri = 0;
        int is_enclosed = 0;
+       char *p;
 
        if(msg == NULL || param == NULL) {
                LM_ERR("bad parameters\n");
@@ -3674,13 +3675,28 @@ int pv_set_xto_attr(struct sip_msg *msg, pv_param_t 
*param, int op,
                                return -1;
                        }
 
-                       buf.s = pkg_malloc(val->rs.len);
+                       buf.len = val->rs.len;
+                       if(!(tb->style & TBS_URI_ENCLOSED)) {
+                               /* existing uri not enclosed - check if new one 
has parameters */
+                               for(p = val->rs.s + val->rs.len - 1; p > 
val->rs.s; p--) {
+                                       if(*p == ';') {
+                                               buf.len += 2;
+                                               break;
+                                       }
+                               }
+                       }
+                       buf.s = pkg_malloc(buf.len);
                        if(buf.s == NULL) {
                                LM_ERR("no more pkg mem\n");
                                goto error;
                        }
-                       buf.len = val->rs.len;
-                       memcpy(buf.s, val->rs.s, val->rs.len);
+                       if(buf.len == val->rs.len + 2) {
+                               buf.s[0] = '<';
+                               memcpy(buf.s + 1, val->rs.s, val->rs.len);
+                               buf.s[buf.len - 1] = '>';
+                       } else {
+                               memcpy(buf.s, val->rs.s, val->rs.len);
+                       }
                        loffset = tb->uri.s - msg->buf;
                        llen = tb->uri.len;
                        break;

_______________________________________________
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