Skip to content

Commit

Permalink
topos: properly handle cases of no user in contact for mode 1
Browse files Browse the repository at this point in the history
- contact mode 1 accepted cases with no-user in contact uri but not in
  r-uri, however, requests within dialog can have one's contact in r-uri
  and then processing failed
  • Loading branch information
miconda committed Mar 10, 2024
1 parent b6fccea commit 24e410f
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions src/modules/topos/tps_storage.c
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ int tps_storage_fill_contact(
int i;
int contact_len;
int cparam_len;
int cuser_len = 0;
sr_xavp_t *vavu = NULL;

if(dir == TPS_DIR_DOWNSTREAM) {
Expand Down Expand Up @@ -317,21 +318,27 @@ int tps_storage_fill_contact(
LM_ERR("failed to parse the contact uri\n");
return -1;
}
memcpy(td->cp, curi.user.s, curi.user.len);
td->cp += curi.user.len;
if(curi.user.len > 0) {
memcpy(td->cp, curi.user.s, curi.user.len);
td->cp += curi.user.len;
cuser_len = curi.user.len;
} else {
LM_DBG("no contact user - skipping it\n");
}
} else {
/* extract the ruri */
if(parse_sip_msg_uri(msg) < 0) {
LM_ERR("failed to parse r-uri\n");
return -1;
}
if(msg->parsed_uri.user.len == 0) {
LM_ERR("no r-uri user\n");
return -1;
if(msg->parsed_uri.user.len > 0) {
memcpy(td->cp, msg->parsed_uri.user.s,
msg->parsed_uri.user.len);
td->cp += msg->parsed_uri.user.len;
cuser_len = msg->parsed_uri.user.len;
} else {
LM_DBG("no r-uri user - skipping it\n");
}
memcpy(td->cp, msg->parsed_uri.user.s,
msg->parsed_uri.user.len);
td->cp += msg->parsed_uri.user.len;
}
} else if(ctmode == TPS_CONTACT_MODE_XAVPUSER) {
if(dir == TPS_DIR_DOWNSTREAM) {
Expand All @@ -344,6 +351,7 @@ int tps_storage_fill_contact(
}
memcpy(td->cp, vavu->val.v.s.s, vavu->val.v.s.len);
td->cp += vavu->val.v.s.len;
cuser_len = vavu->val.v.s.len;
} else {
/* extract the b contact */
vavu = xavu_get_child_with_sval(
Expand All @@ -354,11 +362,11 @@ int tps_storage_fill_contact(
}
memcpy(td->cp, vavu->val.v.s.s, vavu->val.v.s.len);
td->cp += vavu->val.v.s.len;
cuser_len = vavu->val.v.s.len;
}
}

if(!((ctmode == TPS_CONTACT_MODE_RURIUSER)
&& (dir == TPS_DIR_DOWNSTREAM) && (curi.user.len <= 0))) {
if(cuser_len > 0) {
*td->cp = '@';
td->cp++;
}
Expand Down

0 comments on commit 24e410f

Please sign in to comment.