[asterisk-commits] CHAOS: prevent crash on failed strdup (asterisk[13])

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Mar 2 17:24:57 CST 2016


Joshua Colp has submitted this change and it was merged.

Change subject: CHAOS: prevent crash on failed strdup
......................................................................


CHAOS: prevent crash on failed strdup

This patch avoids crashing on a null pointer
if the strdup() allocation fails.

ASTERISK-25323

Change-Id: I3f67434820ba53b53663efd6cbb42749f4f6c0f5
---
M res/res_pjsip_messaging.c
1 file changed, 4 insertions(+), 0 deletions(-)

Approvals:
  Kevin Harwell: Looks good to me, but someone else must approve
  Richard Mudgett: Looks good to me, but someone else must approve
  Joshua Colp: Looks good to me, approved; Verified



diff --git a/res/res_pjsip_messaging.c b/res/res_pjsip_messaging.c
index 54880db..fe285d8 100644
--- a/res/res_pjsip_messaging.c
+++ b/res/res_pjsip_messaging.c
@@ -530,6 +530,10 @@
 	/* Make sure we start with sip: */
 	mdata->to = ast_begins_with(to, "sip:") ? ast_strdup(++to) : ast_strdup(to - 3);
 	mdata->from = ast_strdup(from);
+	if (!mdata->to || !mdata->from) {
+		ao2_ref(mdata, -1);
+		return NULL;
+	}
 
 	/* sometimes from can still contain the tag at this point, so remove it */
 	if ((tag = strchr(mdata->from, ';'))) {

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I3f67434820ba53b53663efd6cbb42749f4f6c0f5
Gerrit-PatchSet: 2
Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-Owner: Scott Griepentrog <sgriepentrog at digium.com>
Gerrit-Reviewer: Anonymous Coward #1000019
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Kevin Harwell <kharwell at digium.com>
Gerrit-Reviewer: Richard Mudgett <rmudgett at digium.com>



More information about the asterisk-commits mailing list