[Asterisk-code-review] WIP (asterisk[13])

Sean Bright asteriskteam at digium.com
Thu Nov 16 15:47:44 CST 2017


Sean Bright has uploaded this change for review. ( https://gerrit.asterisk.org/7242


Change subject: WIP
......................................................................

WIP

Change-Id: I86f37aa9ef07a4fe63448cb881bbadd996834bb1
---
M res/res_pjsip/location.c
1 file changed, 10 insertions(+), 9 deletions(-)



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

diff --git a/res/res_pjsip/location.c b/res/res_pjsip/location.c
index 8ba409e..2bd40e8 100644
--- a/res/res_pjsip/location.c
+++ b/res/res_pjsip/location.c
@@ -71,16 +71,17 @@
 {
 	const struct ast_sip_aor *aor = object;
 	const char *aor_id = ast_sorcery_object_get_id(object);
-	/* Give enough space for ^ at the beginning and ;@ at the end, since that is our object naming scheme */
-	char regex[strlen(aor_id) + 4];
+	/* Give enough space for ;@ at the end, since that is our object naming scheme */
+	size_t prefix_len = strlen(aor_id) + sizeof(";@") - 1;
+	char prefix[prefix_len + 1];
 	struct ao2_container *contacts;
 
 	if (aor->permanent_contacts) {
 		ao2_callback(aor->permanent_contacts, OBJ_NODATA | OBJ_MULTIPLE | OBJ_UNLINK, destroy_contact, NULL);
 	}
 
-	snprintf(regex, sizeof(regex), "^%s;@", aor_id);
-	if (!(contacts = ast_sorcery_retrieve_by_regex(ast_sip_get_sorcery(), "contact", regex))) {
+	sprintf(prefix, "%s;@", aor_id); /* Safe */
+	if (!(contacts = ast_sorcery_retrieve_by_prefix(ast_sip_get_sorcery(), "contact", prefix, prefix_len))) {
 		return;
 	}
 	/* Destroy any contacts that may still exist that were made for this AoR */
@@ -217,13 +218,13 @@
 struct ao2_container *ast_sip_location_retrieve_aor_contacts_nolock_filtered(const struct ast_sip_aor *aor,
 	unsigned int flags)
 {
-	/* Give enough space for ^ at the beginning and ;@ at the end, since that is our object naming scheme */
-	char regex[strlen(ast_sorcery_object_get_id(aor)) + 4];
+	/* Give enough space for ;@ at the end, since that is our object naming scheme */
+	size_t prefix_len = strlen(ast_sorcery_object_get_id(aor)) + sizeof(";@") - 1;
+	char prefix[prefix_len + 1];
 	struct ao2_container *contacts;
 
-	snprintf(regex, sizeof(regex), "^%s;@", ast_sorcery_object_get_id(aor));
-
-	if (!(contacts = ast_sorcery_retrieve_by_regex(ast_sip_get_sorcery(), "contact", regex))) {
+	sprintf(prefix, "%s;@", ast_sorcery_object_get_id(aor)); /* Safe */
+	if (!(contacts = ast_sorcery_retrieve_by_prefix(ast_sip_get_sorcery(), "contact", prefix, prefix_len))) {
 		return NULL;
 	}
 

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

Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-MessageType: newchange
Gerrit-Change-Id: I86f37aa9ef07a4fe63448cb881bbadd996834bb1
Gerrit-Change-Number: 7242
Gerrit-PatchSet: 1
Gerrit-Owner: Sean Bright <sean.bright at gmail.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20171116/a282524d/attachment.html>


More information about the asterisk-code-review mailing list