Module: kamailio
Branch: 5.2
Commit: 79946bbb6d1731f503fc378ae38311b630e55999
URL:
https://github.com/kamailio/kamailio/commit/79946bbb6d1731f503fc378ae38311b…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2018-12-04T09:07:29+01:00
dialog: safety checks for local cseq and contact vars
- avoid crash on systems not printing null string of length 0
- GH #1717
(cherry picked from commit 46401e465d88495d510d2cb36dc36ec86978c53e)
---
Modified: src/modules/dialog/dlg_handlers.c
---
Diff:
https://github.com/kamailio/kamailio/commit/79946bbb6d1731f503fc378ae38311b…
Patch:
https://github.com/kamailio/kamailio/commit/79946bbb6d1731f503fc378ae38311b…
---
diff --git a/src/modules/dialog/dlg_handlers.c b/src/modules/dialog/dlg_handlers.c
index b6ce4d2bbd..a94dd641a4 100644
--- a/src/modules/dialog/dlg_handlers.c
+++ b/src/modules/dialog/dlg_handlers.c
@@ -200,7 +200,7 @@ int populate_leg_info( struct dlg_cell *dlg, struct sip_msg *msg,
if (leg==DLG_CALLER_LEG) {
if((!msg->cseq && (parse_headers(msg,HDR_CSEQ_F,0)<0 || !msg->cseq))
|| !msg->cseq->parsed){
- LM_ERR("bad sip message or missing CSeq hdr :-/\n");
+ LM_ERR("bad sip message or missing CSeq hdr\n");
goto error0;
}
cseq = (get_cseq(msg))->number;
@@ -208,6 +208,10 @@ int populate_leg_info( struct dlg_cell *dlg, struct sip_msg *msg,
/* use the same as in request */
cseq = dlg->cseq[DLG_CALLEE_LEG];
}
+ if(cseq.s==NULL || cseq.len<=0) {
+ LM_ERR("empty CSeq number\n");
+ goto error0;
+ }
/* extract the contact address */
if
(!msg->contact&&(parse_headers(msg,HDR_CONTACT_F,0)<0||!msg->contact)){
@@ -221,6 +225,10 @@ int populate_leg_info( struct dlg_cell *dlg, struct sip_msg *msg,
goto error0;
}
contact = ((contact_body_t *)msg->contact->parsed)->contacts->uri;
+ if(contact.s==NULL || contact.len<=0) {
+ LM_ERR("empty contact uri\n");
+ goto error0;
+ }
/* extract the record-route addresses */
if (leg==DLG_CALLER_LEG) {
@@ -250,10 +258,10 @@ int populate_leg_info( struct dlg_cell *dlg, struct sip_msg *msg,
LM_DBG("leg(%d) route_set [%.*s], contact [%.*s], cseq [%.*s]"
" and bind_addr [%.*s]\n",
- leg, rr_set.len, rr_set.s, contact.len, contact.s,
- cseq.len, cseq.s,
+ leg, rr_set.len, ZSW(rr_set.s), contact.len, ZSW(contact.s),
+ cseq.len, ZSW(cseq.s),
msg->rcv.bind_address->sock_str.len,
- msg->rcv.bind_address->sock_str.s);
+ ZSW(msg->rcv.bind_address->sock_str.s));
if (dlg_set_leg_info( dlg, tag, &rr_set, &contact, &cseq, leg)!=0) {
LM_ERR("dlg_set_leg_info failed (leg %d)\n", leg);