[Asterisk-code-review] res pjsip: Prevent "user=phone" being added multiple times t... (asterisk[13])

dtryba asteriskteam at digium.com
Fri Oct 6 05:21:45 CDT 2017


dtryba has uploaded this change for review. ( https://gerrit.asterisk.org/6671


Change subject: res_pjsip: Prevent "user=phone" being added multiple times to header
......................................................................

res_pjsip: Prevent "user=phone" being added multiple times to header

ast_sip_add_usereqphone adds "user=phone" to the header every time is is
called without checking whether the param already exists. Preventing
this by searching to string representation of header for "user=phone".

ASTERISK-26988 #close

Change-Id: Ib84383b07254de357dc6a98d91fc1d2c2c3719e6
---
M res/res_pjsip.c
1 file changed, 7 insertions(+), 0 deletions(-)



  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/71/6671/1

diff --git a/res/res_pjsip.c b/res/res_pjsip.c
index 3c8f730..e7fc166 100644
--- a/res/res_pjsip.c
+++ b/res/res_pjsip.c
@@ -3021,6 +3021,7 @@
 	pjsip_param *param;
 	static const pj_str_t STR_USER = { "user", 4 };
 	static const pj_str_t STR_PHONE = { "phone", 5 };
+	char check_uri[PJSIP_MAX_URL_SIZE];
 
 	if (!endpoint || !endpoint->usereqphone || (!PJSIP_URI_SCHEME_IS_SIP(uri) && !PJSIP_URI_SCHEME_IS_SIPS(uri))) {
 		return;
@@ -3047,6 +3048,12 @@
 		return;
 	}
 
+	pjsip_uri_print(PJSIP_URI_IN_REQ_URI, sip_uri, check_uri, sizeof(check_uri));
+
+	if (strcasestr(check_uri,"user=phone")!=NULL) {
+		return;
+	}
+
 	param = PJ_POOL_ALLOC_T(pool, pjsip_param);
 	param->name = STR_USER;
 	param->value = STR_PHONE;

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

Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib84383b07254de357dc6a98d91fc1d2c2c3719e6
Gerrit-Change-Number: 6671
Gerrit-PatchSet: 1
Gerrit-Owner: dtryba <daniel at tryba.nl>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20171006/26825cb2/attachment-0001.html>


More information about the asterisk-code-review mailing list