[Asterisk-code-review] res pjsip.c: Fix endpoint identifier registration name search. (asterisk[15])

Jenkins2 asteriskteam at digium.com
Tue Jan 9 08:24:27 CST 2018


Jenkins2 has submitted this change and it was merged. ( https://gerrit.asterisk.org/7842 )

Change subject: res_pjsip.c: Fix endpoint identifier registration name search.
......................................................................

res_pjsip.c: Fix endpoint identifier registration name search.

If an endpoint identifier name in the endpoint_identifier_order list is a
prefix to the identifier we are registering, we could install it in the
wrong position of the list.

Assuming
endpoint_identifier_order=username,ip,anonymous

then registering the "ip_only" identifier would put the identifier in the
wrong position of the priority list.

* Fix incorrect strncmp() string prefix matching.

Change-Id: Ib8819ec4b811da8a27419fd93528c54d34f01484
---
M res/res_pjsip.c
1 file changed, 4 insertions(+), 3 deletions(-)

Approvals:
  Joshua Colp: Looks good to me, but someone else must approve
  George Joseph: Looks good to me, approved
  Jenkins2: Approved for Submit



diff --git a/res/res_pjsip.c b/res/res_pjsip.c
index 972ea0b..7ee15ac 100644
--- a/res/res_pjsip.c
+++ b/res/res_pjsip.c
@@ -2622,13 +2622,13 @@
 
 	id_list_item = ast_calloc(1, sizeof(*id_list_item));
 	if (!id_list_item) {
-		ast_log(LOG_ERROR, "Unabled to add endpoint identifier. Out of memory.\n");
+		ast_log(LOG_ERROR, "Unable to add endpoint identifier. Out of memory.\n");
 		return -1;
 	}
 	id_list_item->identifier = identifier;
 	id_list_item->name = name;
 
-	ast_debug(1, "Register endpoint identifier %s (%p)\n", name, identifier);
+	ast_debug(1, "Register endpoint identifier %s(%p)\n", name ?: "", identifier);
 
 	if (ast_strlen_zero(name)) {
 		/* if an identifier has no name then place in front */
@@ -2651,7 +2651,8 @@
 	id_list_item->priority = 0;
 	while ((current = strchr(current, ','))) {
 		++id_list_item->priority;
-		if (!strncmp(prev, name, current - prev)) {
+		if (!strncmp(prev, name, current - prev)
+			&& strlen(name) == current - prev) {
 			break;
 		}
 		prev = ++current;

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

Gerrit-Project: asterisk
Gerrit-Branch: 15
Gerrit-MessageType: merged
Gerrit-Change-Id: Ib8819ec4b811da8a27419fd93528c54d34f01484
Gerrit-Change-Number: 7842
Gerrit-PatchSet: 1
Gerrit-Owner: Richard Mudgett <rmudgett at digium.com>
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Jenkins2
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20180109/740522af/attachment-0001.html>


More information about the asterisk-code-review mailing list