[Asterisk-code-review] res_pjsip: Fix double Route headers in OPTIONS (asterisk[16])

Igor Goncharovsky asteriskteam at digium.com
Tue Sep 13 14:39:32 CDT 2022


Igor Goncharovsky has uploaded this change for review. ( https://gerrit.asterisk.org/c/asterisk/+/19211 )


Change subject: res_pjsip:  Fix double Route headers in OPTIONS
......................................................................

res_pjsip:  Fix double Route headers in OPTIONS

Move aor proxy set to create_out_of_dialog_request() to prevent double set
of rpoxies in OPTIONS request.

ASTERISK-30224 #close

Change-Id: Ic43137cfcc468791bf4891ec9792bdb45043a5dc
---
M res/res_pjsip.c
M res/res_pjsip/pjsip_options.c
2 files changed, 30 insertions(+), 16 deletions(-)



  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/11/19211/1

diff --git a/res/res_pjsip.c b/res/res_pjsip.c
index c52ceec..076734c 100644
--- a/res/res_pjsip.c
+++ b/res/res_pjsip.c
@@ -1223,13 +1223,22 @@
 	ast_sip_add_usereqphone(endpoint, (*tdata)->pool, (*tdata)->msg->line.req.uri);
 
 	/* If an outbound proxy is specified on the endpoint apply it to this request */
-	if (endpoint && !ast_strlen_zero(endpoint->outbound_proxy) &&
-		ast_sip_set_outbound_proxy((*tdata), endpoint->outbound_proxy)) {
-		ast_log(LOG_ERROR, "Unable to apply outbound proxy on request %.*s to endpoint %s as outbound proxy URI '%s' is not valid\n",
-			(int) pj_strlen(&method->name), pj_strbuf(&method->name), ast_sorcery_object_get_id(endpoint),
-			endpoint->outbound_proxy);
-		pjsip_endpt_release_pool(ast_sip_get_pjsip_endpoint(), pool);
-		return -1;
+	if (pjsip_method_cmp(method, &pjsip_options_method)) {
+		if (contact && !ast_strlen_zero(contact->outbound_proxy) &&
+			ast_sip_set_outbound_proxy((*tdata), contact->outbound_proxy)) {
+			ast_log(LOG_ERROR, "Unable to apply outbound proxy on request to qualify contact %s\n", contact->uri);
+			pjsip_endpt_release_pool(ast_sip_get_pjsip_endpoint(), pool);
+			return -1;
+		}
+	} else {
+		if (endpoint && !ast_strlen_zero(endpoint->outbound_proxy) &&
+			ast_sip_set_outbound_proxy((*tdata), endpoint->outbound_proxy)) {
+			ast_log(LOG_ERROR, "Unable to apply outbound proxy on request %.*s to endpoint %s as outbound proxy URI '%s' is not valid\n",
+				(int) pj_strlen(&method->name), pj_strbuf(&method->name), ast_sorcery_object_get_id(endpoint),
+				endpoint->outbound_proxy);
+			pjsip_endpt_release_pool(ast_sip_get_pjsip_endpoint(), pool);
+			return -1;
+		}
 	}
 
 	ast_sip_mod_data_set((*tdata)->pool, (*tdata)->mod_data, supplement_module.id, MOD_DATA_CONTACT, ao2_bump(contact));
diff --git a/res/res_pjsip/pjsip_options.c b/res/res_pjsip/pjsip_options.c
index 7632dea..db8ea47 100644
--- a/res/res_pjsip/pjsip_options.c
+++ b/res/res_pjsip/pjsip_options.c
@@ -877,15 +877,6 @@
 		return 0;
 	}
 
-	/* If an outbound proxy is specified set it on this request */
-	if (!ast_strlen_zero(contact->outbound_proxy) &&
-		ast_sip_set_outbound_proxy(tdata, contact->outbound_proxy)) {
-		ast_log(LOG_ERROR, "Unable to apply outbound proxy on request to qualify contact %s\n",
-			contact->uri);
-		pjsip_tx_data_dec_ref(tdata);
-		return 0;
-	}
-
 	contact_status = ast_res_pjsip_find_or_create_contact_status(contact);
 	if (!contact_status) {
 		ast_log(LOG_ERROR, "Unable to retrieve contact status information for contact %s on AOR %s\n",

-- 
To view, visit https://gerrit.asterisk.org/c/asterisk/+/19211
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: 16
Gerrit-Change-Id: Ic43137cfcc468791bf4891ec9792bdb45043a5dc
Gerrit-Change-Number: 19211
Gerrit-PatchSet: 1
Gerrit-Owner: Igor Goncharovsky <igor.goncharovsky at gmail.com>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20220913/0c5cb420/attachment.html>


More information about the asterisk-code-review mailing list