[asterisk-commits] res pjsip: Use hash for contact object identity instead of C... (asterisk[master])

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Sep 9 05:53:02 CDT 2015


Joshua Colp has submitted this change and it was merged.

Change subject: res_pjsip: Use hash for contact object identity instead of Contact URI.
......................................................................


res_pjsip: Use hash for contact object identity instead of Contact URI.

In the wild it is possible for Contact URIs to be quite long as
parameters can exist on them. This can present a problem when storing
them in the AstDB as the URI is used as part of the object name and
there is a fixed length limit for the AstDB. This will cause
the contact to not get stored.

This change uses the MD5 hash of the Contact URI as part of the
object name instead. This has a fixed length which is guaranteed
to not exceed the AstDB length limit.

ASTERISK-25295 #close

Change-Id: Ie8252a75331ca00b41b9f308f42cc1fbdf701a02
---
M res/res_pjsip/location.c
1 file changed, 3 insertions(+), 1 deletion(-)

Approvals:
  Kevin Harwell: Looks good to me, but someone else must approve
  Mark Michelson: Looks good to me, but someone else must approve
  Anonymous Coward #1000019: Verified
  Joshua Colp: Looks good to me, approved



diff --git a/res/res_pjsip/location.c b/res/res_pjsip/location.c
index d87410d..c3e665e 100644
--- a/res/res_pjsip/location.c
+++ b/res/res_pjsip/location.c
@@ -234,8 +234,10 @@
 {
 	char name[MAX_OBJECT_FIELD * 2 + 3];
 	RAII_VAR(struct ast_sip_contact *, contact, NULL, ao2_cleanup);
+	char hash[33];
 
-	snprintf(name, sizeof(name), "%s;@%s", ast_sorcery_object_get_id(aor), uri);
+	ast_md5_hash(hash, uri);
+	snprintf(name, sizeof(name), "%s;@%s", ast_sorcery_object_get_id(aor), hash);
 
 	if (!(contact = ast_sorcery_alloc(ast_sip_get_sorcery(), "contact", name))) {
 		return -1;

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ie8252a75331ca00b41b9f308f42cc1fbdf701a02
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Owner: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Anonymous Coward #1000019
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Kevin Harwell <kharwell at digium.com>
Gerrit-Reviewer: Mark Michelson <mmichelson at digium.com>



More information about the asterisk-commits mailing list