From: Kevin Harwell Date: Wed, 3 Jan 2018 16:41:46 +0000 (-0600) Subject: res_pjsip_session: Check if sequence header is missing X-Git-Tag: 13.20.0-rc1~128 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=d25a9bc7d32cc6e0b5c91f82bcb1e474adf1991c;p=thirdparty%2Fasterisk.git res_pjsip_session: Check if sequence header is missing The pjsip_msg_find_hdr function can return NULL. This patch adds a check when searching for the sequence header to make sure a NULL pointer is never de-referenced. Change-Id: I19af23aeeded65be016be92360e8cb7ffe51fad2 --- diff --git a/res/res_pjsip_session.c b/res/res_pjsip_session.c index ae5f19a034..b4fe0be775 100644 --- a/res/res_pjsip_session.c +++ b/res/res_pjsip_session.c @@ -2508,6 +2508,12 @@ static void handle_outgoing_response(struct ast_sip_session *session, pjsip_tx_d struct ast_sip_session_supplement *supplement; struct pjsip_status_line status = tdata->msg->line.status; pjsip_cseq_hdr *cseq = pjsip_msg_find_hdr(tdata->msg, PJSIP_H_CSEQ, NULL); + + if (!cseq) { + ast_log(LOG_ERROR, "Cannot send response due to missing sequence header"); + return; + } + ast_debug(3, "Method is %.*s, Response is %d %.*s\n", (int) pj_strlen(&cseq->method.name), pj_strbuf(&cseq->method.name), status.code, (int) pj_strlen(&status.reason), pj_strbuf(&status.reason));