Module: kamailio
Branch: master
Commit: 7bf0081102a5755c3282e7f01a0f45e160fdda0f
URL:
https://github.com/kamailio/kamailio/commit/7bf0081102a5755c3282e7f01a0f45e…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2021-04-28T16:06:50+02:00
core: kemi - parse headers before insert operation
---
Modified: src/core/kemi.c
---
Diff:
https://github.com/kamailio/kamailio/commit/7bf0081102a5755c3282e7f01a0f45e…
Patch:
https://github.com/kamailio/kamailio/commit/7bf0081102a5755c3282e7f01a0f45e…
---
diff --git a/src/core/kemi.c b/src/core/kemi.c
index ba0b435dce..0932339996 100644
--- a/src/core/kemi.c
+++ b/src/core/kemi.c
@@ -2143,6 +2143,11 @@ static int sr_kemi_hdr_insert(sip_msg_t *msg, str *txt)
if(txt==NULL || txt->s==NULL || msg==NULL)
return -1;
+ if ((parse_headers(msg, HDR_EOH_F, 0) == -1) || (msg->headers == NULL)) {
+ LM_ERR("error while parsing message\n");
+ return -1;
+ }
+
LM_DBG("insert hf: %.*s\n", txt->len, txt->s);
hdr = (char*)pkg_malloc(txt->len);
if(hdr==NULL) {
@@ -2188,7 +2193,7 @@ static int sr_kemi_hdr_insert_before(sip_msg_t *msg, str *txt, str
*hname)
return -1;
}
- if (parse_headers(msg, HDR_EOH_F, 0) == -1) {
+ if ((parse_headers(msg, HDR_EOH_F, 0) == -1) || (msg->headers == NULL)) {
LM_ERR("error while parsing message\n");
return -1;
}