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

Author: Daniel-Constantin Mierla <[email protected]>
Committer: Daniel-Constantin Mierla <[email protected]>
Date: 2026-01-20T14:40:49+01:00

core: sip_msg_copy() restructure

---

Modified: src/core/sip_msg_clone.c

---

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

---

diff --git a/src/core/sip_msg_clone.c b/src/core/sip_msg_clone.c
index 6ddb32ac5f6..1a032823a2a 100644
--- a/src/core/sip_msg_clone.c
+++ b/src/core/sip_msg_clone.c
@@ -1015,20 +1015,6 @@ int sip_msg_copy(sip_msg_t *imsg, sip_msg_t *omsg, 
unsigned int flags)
        omsg->len = imsg->len;
        omsg->buf[omsg->len] = '\0';
 
-       /* parse the output message */
-       LM_DBG("SIP message content copied - reparsing\n");
-       if(parse_msg(omsg->buf, omsg->len, omsg) != 0) {
-               LM_ERR("parsing out sip message failed [[%.*s]]\n", omsg->len,
-                               omsg->buf);
-               goto error;
-       }
-       if(parse_headers(omsg, HDR_FROM_F | HDR_TO_F | HDR_CALLID_F | 
HDR_CSEQ_F, 0)
-                       < 0) {
-               LM_ERR("parsing main headers of new sip message failed 
[[%.*s]]\n",
-                               omsg->len, omsg->buf);
-               goto error;
-       }
-
        omsg->id = imsg->id;
        omsg->pid = imsg->pid;
        omsg->tval = imsg->tval;
@@ -1049,6 +1035,23 @@ int sip_msg_copy(sip_msg_t *imsg, sip_msg_t *omsg, 
unsigned int flags)
        omsg->otcpid = imsg->otcpid;
        omsg->hash_index = imsg->hash_index;
 
+       /* parse the output message */
+       LM_DBG("SIP message content copied - reparsing\n");
+       if(parse_msg(omsg->buf, omsg->len, omsg) != 0) {
+               LM_ERR("parsing out sip message failed [[%.*s]]\n", omsg->len,
+                               omsg->buf);
+               goto error;
+       }
+       if(parse_headers(omsg, HDR_FROM_F | HDR_TO_F | HDR_CALLID_F | 
HDR_CSEQ_F, 0)
+                       < 0) {
+               LM_ERR("parsing main headers of new sip message failed 
[[%.*s]]\n",
+                               omsg->len, omsg->buf);
+               goto error;
+       }
+
+       memcpy(omsg->add_to_branch_s, imsg->add_to_branch_s, 
MAX_BRANCH_PARAM_LEN);
+       omsg->add_to_branch_len = imsg->add_to_branch_len;
+
        /* duplicate */
        if(imsg->new_uri.s != NULL) {
                if(pkg_str_dup(&omsg->new_uri, &imsg->new_uri) < 0) {
@@ -1081,9 +1084,6 @@ int sip_msg_copy(sip_msg_t *imsg, sip_msg_t *omsg, 
unsigned int flags)
                }
        }
 
-       memcpy(omsg->add_to_branch_s, imsg->add_to_branch_s, 
MAX_BRANCH_PARAM_LEN);
-       omsg->add_to_branch_len = omsg->add_to_branch_len;
-
        if(imsg->add_rm != NULL) {
                omsg->add_rm = copy_lump_list(imsg->add_rm);
                if(omsg->add_rm == NULL) {

_______________________________________________
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