[Asterisk-code-review] CHAOS: prevent crash on failed strdup (asterisk[13])

Scott Griepentrog asteriskteam at digium.com
Wed Mar 2 11:05:07 CST 2016


Scott Griepentrog has uploaded a new change for review.

  https://gerrit.asterisk.org/2342

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(-)


  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/42/2342/1

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: newchange
Gerrit-Change-Id: I3f67434820ba53b53663efd6cbb42749f4f6c0f5
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-Owner: Scott Griepentrog <sgriepentrog at digium.com>



More information about the asterisk-code-review mailing list