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

Author: Daniel-Constantin Mierla <mico...@gmail.com>
Committer: Daniel-Constantin Mierla <mico...@gmail.com>
Date: 2025-07-08T12:39:56+02:00

textops: remove old body based on message length for set_body()

---

Modified: src/modules/textops/textops.c

---

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

---

diff --git a/src/modules/textops/textops.c b/src/modules/textops/textops.c
index 4686d72fce9..bfd58d21114 100644
--- a/src/modules/textops/textops.c
+++ b/src/modules/textops/textops.c
@@ -2506,7 +2506,6 @@ static int ki_set_body(sip_msg_t *msg, str *nb, str *nc)
                return -1;
        }
 
-       body.len = 0;
        body.s = get_body(msg);
        if(body.s == 0) {
                LM_ERR("malformed sip message\n");
@@ -2516,17 +2515,12 @@ static int ki_set_body(sip_msg_t *msg, str *nb, str *nc)
        del_nonshm_lump(&(msg->body_lumps));
        msg->body_lumps = NULL;
 
-       if(msg->content_length) {
-               body.len = get_content_length(msg);
-               if(body.len > 0) {
-                       if(body.s + body.len > msg->buf + msg->len) {
-                               LM_ERR("invalid content length: %d\n", 
body.len);
-                               return -1;
-                       }
-                       if(del_lump(msg, body.s - msg->buf, body.len, 0) == 0) {
-                               LM_ERR("cannot delete existing body");
-                               return -1;
-                       }
+       /* remove existing body */
+       body.len = msg->buf + msg->len - body.s;
+       if(body.len > 0) {
+               if(del_lump(msg, body.s - msg->buf, body.len, 0) == 0) {
+                       LM_ERR("cannot remove body\n");
+                       return -1;
                }
        }
 

_______________________________________________
Kamailio - Development Mailing List -- sr-dev@lists.kamailio.org
To unsubscribe send an email to sr-dev-le...@lists.kamailio.org
Important: keep the mailing list in the recipients, do not reply only to the 
sender!

Reply via email to