summaryrefslogtreecommitdiff
path: root/res/res_pjsip/location.c
diff options
context:
space:
mode:
authorJoshua Colp <jcolp@digium.com>2015-09-08 09:21:11 -0300
committerJoshua Colp <jcolp@digium.com>2015-09-08 07:44:52 -0500
commit3628e380b806b57c4699e121636bc2814cb6fd08 (patch)
treee27096b1c5a44de33edda317f9720be0bf9c6bf0 /res/res_pjsip/location.c
parentd2106c0b21e2e4d53eb177d1d271c30c362700f1 (diff)
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
Diffstat (limited to 'res/res_pjsip/location.c')
-rw-r--r--res/res_pjsip/location.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/res/res_pjsip/location.c b/res/res_pjsip/location.c
index d87410d3b..c3e665e0c 100644
--- a/res/res_pjsip/location.c
+++ b/res/res_pjsip/location.c
@@ -234,8 +234,10 @@ int ast_sip_location_add_contact(struct ast_sip_aor *aor, const char *uri,
{
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;