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

Author: Daniel-Constantin Mierla <[email protected]>
Committer: Daniel-Constantin Mierla <[email protected]>
Date: 2026-06-23T08:58:50+02:00

pospops: extended the checks for offset parameter

---

Modified: src/modules/posops/posops_mod.c

---

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

---

diff --git a/src/modules/posops/posops_mod.c b/src/modules/posops/posops_mod.c
index 5f72042b9f4..cec2e16f7bb 100644
--- a/src/modules/posops/posops_mod.c
+++ b/src/modules/posops/posops_mod.c
@@ -184,7 +184,7 @@ static int ki_posops_pos_append(sip_msg_t *msg, int idx, 
str *val)
        } else {
                offset = idx;
        }
-       if(offset > msg->len) {
+       if(offset < 0 || offset > msg->len) {
                LM_ERR("offset invalid: %d (msg-len: %d)\n", offset, msg->len);
                return -1;
        }
@@ -243,7 +243,7 @@ static int ki_posops_pos_insert(sip_msg_t *msg, int idx, 
str *val)
        } else {
                offset = idx;
        }
-       if(offset > msg->len) {
+       if(offset < 0 || offset > msg->len) {
                LM_ERR("offset invalid: %d (msg-len: %d)\n", offset, msg->len);
                return -1;
        }
@@ -302,7 +302,7 @@ static int ki_posops_pos_rm(sip_msg_t *msg, int idx, int 
len)
        } else {
                offset = idx;
        }
-       if(offset > msg->len) {
+       if(offset < 0 || offset > msg->len) {
                LM_ERR("offset invalid: %d (msg-len: %d)\n", offset, msg->len);
                return -1;
        }
@@ -364,7 +364,7 @@ static int ki_posops_pos_set_char(sip_msg_t *msg, int idx, 
str *val)
        } else {
                offset = idx;
        }
-       if(offset > msg->len) {
+       if(offset < 0 || offset > msg->len) {
                LM_ERR("offset invalid: %d (msg-len: %d)\n", offset, msg->len);
                return -1;
        }

_______________________________________________
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