Skip to content

Commit

Permalink
tm: do not add duplicate headers in local requests
Browse files Browse the repository at this point in the history
(cherry picked from commit ada3701)
  • Loading branch information
miconda committed Oct 9, 2020
1 parent 6e2bdf1 commit f57c900
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions src/modules/tm/t_msgbuilder.c
Expand Up @@ -268,6 +268,7 @@ char *build_local_reparse(tm_cell_t *Trans,unsigned int branch,
struct hdr_field *reas1, *reas_last, *hdr;
int hadded = 0;
sr_cfgenv_t *cenv = NULL;
hdr_flags_t hdr_flags = 0;

invite_buf = Trans->uac[branch].request.buffer;
invite_len = Trans->uac[branch].request.buffer_len;
Expand Down Expand Up @@ -361,6 +362,11 @@ char *build_local_reparse(tm_cell_t *Trans,unsigned int branch,
switch(hf_type) {
case HDR_CSEQ_T:
/* find the method name and replace it */
if(hdr_flags & HDR_CSEQ_F) {
LM_DBG("duplicate CSeq header\n");
goto errorhdr;
}
hdr_flags |= HDR_CSEQ_F;
while ((s < invite_buf_end)
&& ((*s == ':') || (*s == ' ') || (*s == '\t') ||
((*s >= '0') && (*s <= '9')))
Expand All @@ -381,6 +387,12 @@ char *build_local_reparse(tm_cell_t *Trans,unsigned int branch,
break;

case HDR_TO_T:
if(hdr_flags & HDR_TO_F) {
LM_DBG("duplicate To header\n");
goto errorhdr;
}
hdr_flags |= HDR_TO_F;

if (to_len == 0) {
/* there is no To tag required, just copy paste
* the header */
Expand All @@ -395,7 +407,25 @@ char *build_local_reparse(tm_cell_t *Trans,unsigned int branch,
break;

case HDR_FROM_T:
/* copy hf */
if(hdr_flags & HDR_FROM_F) {
LM_DBG("duplicate From header\n");
goto errorhdr;
}
hdr_flags |= HDR_FROM_F;
s = lw_next_line(s, invite_buf_end);
append_str(d, s1, s - s1);
break;
case HDR_CALLID_T:
/* copy hf */
if(hdr_flags & HDR_CALLID_F) {
LM_DBG("duplicate Call-Id header\n");
goto errorhdr;
}
hdr_flags |= HDR_CALLID_F;
s = lw_next_line(s, invite_buf_end);
append_str(d, s1, s - s1);
break;
case HDR_ROUTE_T:
case HDR_MAXFORWARDS_T:
/* copy hf */
Expand Down Expand Up @@ -495,6 +525,7 @@ char *build_local_reparse(tm_cell_t *Trans,unsigned int branch,
/* HDR_EOH_T was not found in the buffer, the message is corrupt */
LM_ERR("HDR_EOH_T was not found\n");

errorhdr:
shm_free(cancel_buf);
error:
LM_ERR("cannot build %.*s request\n", method_len, method);
Expand Down

0 comments on commit f57c900

Please sign in to comment.