[sr-dev] git:master:efa6c6a9: uac: restore first display name then uri with dialog callback

Daniel-Constantin Mierla miconda at gmail.com
Mon Sep 7 19:46:32 CEST 2020


Module: kamailio
Branch: master
Commit: efa6c6a9bf13c430d5be5146168d1ded4c39dba7
URL: https://github.com/kamailio/kamailio/commit/efa6c6a9bf13c430d5be5146168d1ded4c39dba7

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2020-09-07T19:35:04+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

---

Modified: src/modules/uac/replace.c

---

Diff:  https://github.com/kamailio/kamailio/commit/efa6c6a9bf13c430d5be5146168d1ded4c39dba7.diff
Patch: https://github.com/kamailio/kamailio/commit/efa6c6a9bf13c430d5be5146168d1ded4c39dba7.patch

---

diff --git a/src/modules/uac/replace.c b/src/modules/uac/replace.c
index c64af52999..3a476a3d82 100644
--- a/src/modules/uac/replace.c
+++ b/src/modules/uac/replace.c
@@ -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 */
@@ -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",
@@ -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)) &&
@@ -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);
 }
 
 




More information about the sr-dev mailing list