Skip to content

Commit

Permalink
Fix building TO / FROM hdr via t_uac()
Browse files Browse the repository at this point in the history
t_uac() gets URIs as values for TO / FROM, so these URIs may contain URI params. If those URIs are placed into headers without <> enclosing, their params will become header params :(
So, to be sure, let's enclose the URIs all the time.

Closes 2843

(cherry picked from commit 9af1926)
  • Loading branch information
bogdan-iancu committed Jan 19, 2023
1 parent a12f352 commit b3211e3
Showing 1 changed file with 8 additions and 27 deletions.
35 changes: 8 additions & 27 deletions modules/tm/t_msgbuilder.c
Original file line number Diff line number Diff line change
Expand Up @@ -666,7 +666,7 @@ static inline char* print_request_uri(char* w, str* method, dlg_t* dialog, struc
static inline char* print_to(char* w, dlg_t* dialog, struct cell* t)
{
t->to.s = w;
t->to.len = TO_LEN + dialog->rem_uri.len + CRLF_LEN;
t->to.len = TO_LEN + dialog->rem_uri.len + 2 + CRLF_LEN;

append_string(w, TO, TO_LEN);

Expand All @@ -676,18 +676,9 @@ static inline char* print_to(char* w, dlg_t* dialog, struct cell* t)
*(w++) = ' ';
}

if(dialog->rem_dname.len || dialog->id.rem_tag.len) {
t->to.len +=1;
*(w++) = '<';
}

*(w++) = '<';
append_string(w, dialog->rem_uri.s, dialog->rem_uri.len);

if(dialog->rem_dname.len || dialog->id.rem_tag.len) {
t->to.len +=1;
*(w++) = '>';
}

*(w++) = '>';

if (dialog->id.rem_tag.len) {
t->to.len += TOTAG_LEN + dialog->id.rem_tag.len ;
Expand All @@ -706,7 +697,7 @@ static inline char* print_to(char* w, dlg_t* dialog, struct cell* t)
static inline char* print_from(char* w, dlg_t* dialog, struct cell* t)
{
t->from.s = w;
t->from.len = FROM_LEN + dialog->loc_uri.len + CRLF_LEN;
t->from.len = FROM_LEN + dialog->loc_uri.len + 2 + CRLF_LEN;

append_string(w, FROM, FROM_LEN);

Expand All @@ -716,17 +707,9 @@ static inline char* print_from(char* w, dlg_t* dialog, struct cell* t)
*(w++) = ' ';
}

if(dialog->loc_dname.len || dialog->id.loc_tag.len) {
t->from.len +=1;
*(w++) = '<';
}

*(w++) = '<';
append_string(w, dialog->loc_uri.s, dialog->loc_uri.len);

if(dialog->loc_dname.len || dialog->id.loc_tag.len) {
t->from.len += 1;
*(w++) = '>';
}
*(w++) = '>';

if (dialog->id.loc_tag.len) {
t->from.len += FROMTAG_LEN + dialog->id.loc_tag.len;
Expand Down Expand Up @@ -819,15 +802,13 @@ char* build_uac_req(str* method, str* headers, str* body, dlg_t* dialog,
+ (dialog->rem_dname.len ? dialog->rem_dname.len+1 : 0)
+ dialog->rem_uri.len
+ (dialog->id.rem_tag.len ? TOTAG_LEN + dialog->id.rem_tag.len : 0)
+ (dialog->rem_dname.len || dialog->id.rem_tag.len ? 2 : 0)
+ CRLF_LEN;
+ 2 /* <> for URI */ + CRLF_LEN;
/* From */
*len += FROM_LEN
+ (dialog->loc_dname.len ? dialog->loc_dname.len+1 : 0)
+ dialog->loc_uri.len
+ (dialog->id.loc_tag.len ? FROMTAG_LEN + dialog->id.loc_tag.len : 0)
+ (dialog->loc_dname.len || dialog->id.loc_tag.len ? 2 : 0)
+ CRLF_LEN;
+ 2 /* <> for URI */ + CRLF_LEN;
/* Call-ID */
*len += CALLID_LEN + dialog->id.call_id.len + CRLF_LEN;
/* CSeq */
Expand Down

0 comments on commit b3211e3

Please sign in to comment.