From d7164b062961c421c2b11f74a5826a52bc09d3aa Mon Sep 17 00:00:00 2001 From: Juha Heinanen Date: Fri, 3 Jul 2015 11:27:12 +0300 Subject: [PATCH] modules/rls: normalize RLS entry URIs - RLS entry URI is xs:AnyURI, which may be an absolute or relative URI. In relative URI, URI scheme is missing. (cherry picked from commit 68bb6b35098f5555ca35ddb21527660e46b7336a) (cherry picked from commit 41a211e6c13dcecaa6752238d63dfae932433ea7) --- modules/rls/subscribe.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/modules/rls/subscribe.c b/modules/rls/subscribe.c index 801d5e4d3f8..223d37502e8 100644 --- a/modules/rls/subscribe.c +++ b/modules/rls/subscribe.c @@ -987,23 +987,32 @@ int send_resource_subs(char* uri, void* param) str pres_uri, *tmp_str; struct sip_uri parsed_pres_uri; int duplicate = 0; + str *normalized_uri; subs_info_t *s = (subs_info_t *) ((void**)param)[0]; list_entry_t **rls_contact_list = (list_entry_t **) ((void**)param)[1]; pres_uri.s = uri; pres_uri.len = strlen(uri); - if (parse_uri(pres_uri.s, pres_uri.len, &parsed_pres_uri) < 0) - { - LM_ERR("bad uri: %.*s\n", pres_uri.len, pres_uri.s); - return -1; + + normalized_uri = normalize_sip_uri(&pres_uri); + if (normalized_uri->s == NULL || normalized_uri->len == 0) { + LM_ERR("failed to normalize RLS entry URI %.*s\n", + pres_uri.len, pres_uri.s); + return -1; + } + + if (parse_uri(normalized_uri->s, normalized_uri->len, &parsed_pres_uri) + < 0) { + LM_ERR("bad uri: %.*s\n", normalized_uri->len, normalized_uri->s); + return -1; } if (check_self(&parsed_pres_uri.host, 0, PROTO_NONE) != 1 && rls_disable_remote_presence != 0) { LM_WARN("Unable to subscribe to remote contact %.*s for watcher %.*s\n", - pres_uri.len, pres_uri.s, + normalized_uri->len, normalized_uri->s, s->watcher_uri->len, s->watcher_uri->s); return 1; @@ -1014,8 +1023,8 @@ int send_resource_subs(char* uri, void* param) if (rls_max_backend_subs > 0 && ++counter > rls_max_backend_subs) return 1; - s->pres_uri = &pres_uri; - s->remote_target = &pres_uri; + s->pres_uri = normalized_uri; + s->remote_target = normalized_uri; /* Build list of contacts... checking each contact exists only once */ if ((tmp_str = (str *)pkg_malloc(sizeof(str))) == NULL) @@ -1029,8 +1038,8 @@ int send_resource_subs(char* uri, void* param) LM_ERR("out of private memory\n"); return -1; } - memcpy(tmp_str->s, pres_uri.s, pres_uri.len); - tmp_str->len = pres_uri.len; + memcpy(tmp_str->s, normalized_uri->s, normalized_uri->len); + tmp_str->len = normalized_uri->len; *rls_contact_list = list_insert(tmp_str, *rls_contact_list, &duplicate); if (duplicate != 0) {