Skip to content

Commit

Permalink
[presence] refine uandd_to_uri() changes
Browse files Browse the repository at this point in the history
Be sure we have at least one URI part (domain or user).
Make more clear the TEL versus SIP handling
  • Loading branch information
bogdan-iancu committed Apr 18, 2024
1 parent 5ca4136 commit e3b2c34
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions modules/presence/utils_func.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ static inline int uandd_to_uri(str user, str domain, str *out)
{
int size;

if(out==0)
if(out==0 || (user.len+domain.len==0))
return -1;

size = user.len + domain.len+7;
Expand All @@ -54,25 +54,23 @@ static inline int uandd_to_uri(str user, str domain, str *out)
return -1;
}

if (domain.len != 0)
if (domain.len != 0) {
strcpy(out->s,"sip:");
else
out->len = 4;
if( user.len != 0) {
memcpy(out->s+out->len, user.s, user.len);
out->len += user.len;
out->s[out->len++] = '@';
}
memcpy(out->s + out->len, domain.s, domain.len);
out->len += domain.len;
} else {
strcpy(out->s,"tel:");

out->len = 4;
if( user.len != 0)
{
out->len = 4;
memcpy(out->s+out->len, user.s, user.len);
out->len += user.len;
if (domain.len != 0)
out->s[out->len++] = '@';
}

if (domain.len != 0) {
memcpy(out->s + out->len, domain.s, domain.len);
out->len += domain.len;
}

out->s[out->len] = '\0';


Expand Down

0 comments on commit e3b2c34

Please sign in to comment.