[sr-dev] git:5.3:8079c537: uac: restore first display name then uri with dialog callback
Daniel-Constantin Mierla
miconda at gmail.com
Mon Sep 7 20:42:17 CEST 2020
Module: kamailio
Branch: 5.3
Commit: 8079c537fa34be1ca075617d2b79143cd932e719
URL: https://github.com/kamailio/kamailio/commit/8079c537fa34be1ca075617d2b79143cd932e719
Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2020-09-07T20:35:28+02:00
uac: restore first display name then uri with dialog callback
- 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
- backport of commit efa6c6a9bf13c430d5be5146168d1ded4c39dba7 (master)
- backport of commit 1a49cc015609c8701057d5a9cf50f68db61870c1 (5.4)
---
Modified: src/modules/uac/replace.c
---
Diff: https://github.com/kamailio/kamailio/commit/8079c537fa34be1ca075617d2b79143cd932e719.diff
Patch: https://github.com/kamailio/kamailio/commit/8079c537fa34be1ca075617d2b79143cd932e719.patch
---
diff --git a/src/modules/uac/replace.c b/src/modules/uac/replace.c
index 8da8fc7441..ebde602595 100644
--- a/src/modules/uac/replace.c
+++ b/src/modules/uac/replace.c
@@ -936,26 +936,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) {
- LM_ERR("no more pkg mem\n");
- 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 */
@@ -966,8 +946,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",
@@ -976,20 +956,40 @@ static void replace_callback(struct dlg_cell *dlg, int type,
buf.s = pkg_malloc(new_display->len + 2);
if (buf.s==0) {
LM_ERR("no more pkg mem\n");
- 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 - duplicate the decoded value */
+ p = pkg_malloc( new_uri->len);
+ if (!p) {
+ LM_ERR("no more pkg mem\n");
+ 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 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)) &&
@@ -1003,10 +1003,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);
}
More information about the sr-dev
mailing list