Skip to content

Commit

Permalink
uac: restore first display name then uri with dialog callback
Browse files Browse the repository at this point in the history
- same as for rr callback, otherwise the new header can be malformed:
the case of initial INVITE with From URI having no angle brackets and goes
out with display name and angle brackets, the ACK for 200ok results with
From broken when forwarded
  • Loading branch information
miconda committed Sep 7, 2020
1 parent 492c99e commit efa6c6a
Showing 1 changed file with 28 additions and 28 deletions.
56 changes: 28 additions & 28 deletions src/modules/uac/replace.c
Expand Up @@ -942,26 +942,6 @@ static void replace_callback(struct dlg_cell *dlg, int type,
old_uri.len, old_uri.s, new_display->len, new_display->s,
new_uri->len, new_uri->s);

/* duplicate the decoded value */
p = pkg_malloc( new_uri->len);
if (!p) {
PKG_MEM_ERROR;
return;
}
memcpy( p, new_uri->s, new_uri->len);

/* build del/add lumps */
l = del_lump( msg, old_uri.s-msg->buf, old_uri.len, 0);
if (l==0) {
LM_ERR("del lump failed\n");
goto free;
}

if (insert_new_lump_after( l, p, new_uri->len, 0)==0) {
LM_ERR("insert new lump failed\n");
goto free;
}

/* deal with display name */
l = 0;
/* first remove the existing display */
Expand All @@ -972,8 +952,8 @@ static void replace_callback(struct dlg_cell *dlg, int type,
l = del_lump(msg, body->display.s-msg->buf, body->display.len, 0);
if (l==0) {
LM_ERR("display del lump failed\n");
goto free;
}
return;
}
}
if (new_display->s && new_display->len > 0) {
LM_DBG("inserting display [%.*s]\n",
Expand All @@ -982,20 +962,40 @@ static void replace_callback(struct dlg_cell *dlg, int type,
buf.s = pkg_malloc(new_display->len + 2);
if (buf.s==0) {
PKG_MEM_ERROR;
goto free;
return;
}
memcpy( buf.s, new_display->s, new_display->len);
buf.len = new_display->len;
if (l==0 && (l=get_display_anchor(msg, hdr, body, &buf)) == 0) {
LM_ERR("failed to insert anchor\n");
goto free2;
goto free1;
}
if (insert_new_lump_after(l, buf.s, buf.len, 0) == 0) {
LM_ERR("insert new display lump failed\n");
goto free2;
goto free1;
}
}

/* uri update - duplicate the decoded value */
p = pkg_malloc( new_uri->len);
if (!p) {
PKG_MEM_ERROR;
goto free1;
}
memcpy( p, new_uri->s, new_uri->len);

/* build del/add lumps */
l = del_lump( msg, old_uri.s-msg->buf, old_uri.len, 0);
if (l==0) {
LM_ERR("del lump failed\n");
goto free2;
}

if (insert_new_lump_after( l, p, new_uri->len, 0)==0) {
LM_ERR("insert new lump failed\n");
goto free2;
}

/* register tm callback to change replies,
* but only if not registered earlier */
if (!(msg->msg_flags & (FL_USE_UAC_FROM|FL_USE_UAC_TO)) &&
Expand All @@ -1009,10 +1009,10 @@ static void replace_callback(struct dlg_cell *dlg, int type,
return;

free2:
pkg_free(buf.s);

free:
pkg_free(p);

free1:
pkg_free(buf.s);
}


Expand Down

0 comments on commit efa6c6a

Please sign in to comment.