[Asterisk-code-review] Fix segfault if Dial() is used on PJSIP and endpoint not spe... (asterisk[master])

snuffy asteriskteam at digium.com
Sat May 16 18:49:36 CDT 2015


snuffy has uploaded a new change for review.

  https://gerrit.asterisk.org/479

Change subject: Fix segfault if Dial() is used on PJSIP and endpoint not specified.
......................................................................

Fix segfault if Dial() is used on PJSIP and endpoint not specified.

Add missing return -1; when we discover the endpoint is not specified.

ASTERISK-25086 #close
Reported by: snuffy

Change-Id: Ib5da54bd0188cd145128734084fa53ebbfe750c0
---
M channels/chan_pjsip.c
M res/res_pjsip_session.c
2 files changed, 2 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/79/479/1

diff --git a/channels/chan_pjsip.c b/channels/chan_pjsip.c
index 1195f16..14ba4a2 100644
--- a/channels/chan_pjsip.c
+++ b/channels/chan_pjsip.c
@@ -1864,6 +1864,7 @@
 	if (ast_strlen_zero(endpoint_name)) {
 		ast_log(LOG_ERROR, "Unable to create PJSIP channel with empty endpoint name\n");
 		req_data->cause = AST_CAUSE_CHANNEL_UNACCEPTABLE;
+		return -1;
 	} else if (!(endpoint = ast_sorcery_retrieve_by_id(ast_sip_get_sorcery(), "endpoint", endpoint_name))) {
 		ast_log(LOG_ERROR, "Unable to create PJSIP channel - endpoint '%s' was not found\n", endpoint_name);
 		req_data->cause = AST_CAUSE_NO_ROUTE_DESTINATION;
diff --git a/res/res_pjsip_session.c b/res/res_pjsip_session.c
index 9c48fd6..f9e7632 100644
--- a/res/res_pjsip_session.c
+++ b/res/res_pjsip_session.c
@@ -1444,10 +1444,7 @@
 
 	/* If no location has been provided use the AOR list from the endpoint itself if it exists */
 	if (location || !contact) {
-		location = S_OR(location, endpoint ? endpoint->aors : NULL);
-		if (ast_strlen_zero(location)) {
-			return NULL;
-		}
+		location = S_OR(location, endpoint->aors);
 
 		ast_sip_location_retrieve_contact_and_aor_from_list(location, &found_aor, &found_contact);
 		if (!found_contact || ast_strlen_zero(found_contact->uri)) {

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib5da54bd0188cd145128734084fa53ebbfe750c0
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Owner: snuffy <snuffy22 at gmail.com>



More information about the asterisk-code-review mailing list