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

Author: Xenofon Karamanos <[email protected]>
Committer: Xenofon Karamanos <[email protected]>
Date: 2026-05-04T14:46:55Z

imc: Add length check

---

Modified: src/modules/imc/imc_cmd.c

---

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

---

diff --git a/src/modules/imc/imc_cmd.c b/src/modules/imc/imc_cmd.c
index f0085359cbb..f5ded9b8cb4 100644
--- a/src/modules/imc/imc_cmd.c
+++ b/src/modules/imc/imc_cmd.c
@@ -108,12 +108,17 @@ static str *build_headers(struct sip_msg *msg)
        static str name = STR_STATIC_INIT("In-Reply-To: ");
        static str nl = STR_STATIC_INIT("\r\n");
        static char buf[1024];
-       static str rv;
+       static str rv = {NULL, 0};
        str *callid;
 
        rv.s = buf;
        rv.len = all_hdrs.len + ctname.len + msg->content_type->body.len;
 
+       if(rv.len > sizeof(buf)) {
+               LM_ERR("headers too long\n");
+               return &rv;
+       }
+
        memcpy(buf, all_hdrs.s, all_hdrs.len);
        memcpy(buf + all_hdrs.len, ctname.s, ctname.len);
        memcpy(buf + all_hdrs.len + ctname.len, msg->content_type->body.s,

_______________________________________________
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