[Asterisk-code-review] res pjsip session: Check if sequence header is missing (asterisk[13])

Joshua Colp asteriskteam at digium.com
Thu Jan 4 06:46:59 CST 2018


Joshua Colp has submitted this change and it was merged. ( https://gerrit.asterisk.org/7789 )

Change subject: res_pjsip_session: Check if sequence header is missing
......................................................................

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
---
M res/res_pjsip_session.c
1 file changed, 6 insertions(+), 0 deletions(-)

Approvals:
  Benjamin Keith Ford: Looks good to me, but someone else must approve
  Corey Farrell: Looks good to me, but someone else must approve
  Joshua Colp: Looks good to me, approved; Approved for Submit



diff --git a/res/res_pjsip_session.c b/res/res_pjsip_session.c
index ae5f19a..b4fe0be 100644
--- a/res/res_pjsip_session.c
+++ b/res/res_pjsip_session.c
@@ -2508,6 +2508,12 @@
 	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));

-- 
To view, visit https://gerrit.asterisk.org/7789
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-MessageType: merged
Gerrit-Change-Id: I19af23aeeded65be016be92360e8cb7ffe51fad2
Gerrit-Change-Number: 7789
Gerrit-PatchSet: 1
Gerrit-Owner: Kevin Harwell <kharwell at digium.com>
Gerrit-Reviewer: Benjamin Keith Ford <bford at digium.com>
Gerrit-Reviewer: Corey Farrell <git at cfware.com>
Gerrit-Reviewer: Jenkins2
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20180104/a726a93b/attachment.html>


More information about the asterisk-code-review mailing list