Quellcode durchsuchen

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
Daniel-Constantin Mierla vor 5 Jahren
Ursprung
Commit
efa6c6a9bf
1 geänderte Dateien mit 28 neuen und 28 gelöschten Zeilen
  1. 28 28
      src/modules/uac/replace.c

+ 28 - 28
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,
 			old_uri.len, old_uri.s, new_display->len, new_display->s,
 			new_uri->len, new_uri->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 */
 	/* deal with display name */
 	l = 0;
 	l = 0;
 	/* first remove the existing display */
 	/* 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);
 		l = del_lump(msg, body->display.s-msg->buf, body->display.len, 0);
 		if (l==0) {
 		if (l==0) {
 			LM_ERR("display del lump failed\n");
 			LM_ERR("display del lump failed\n");
-			goto free;
-			}
+			return;
+		}
 	}
 	}
 	if (new_display->s && new_display->len > 0) {
 	if (new_display->s && new_display->len > 0) {
 		LM_DBG("inserting display [%.*s]\n",
 		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);
 		buf.s = pkg_malloc(new_display->len + 2);
 		if (buf.s==0) {
 		if (buf.s==0) {
 			PKG_MEM_ERROR;
 			PKG_MEM_ERROR;
-			goto free;
+			return;
 		}
 		}
 		memcpy( buf.s, new_display->s, new_display->len);
 		memcpy( buf.s, new_display->s, new_display->len);
 		buf.len = new_display->len;
 		buf.len = new_display->len;
 		if (l==0 && (l=get_display_anchor(msg, hdr, body, &buf)) == 0) {
 		if (l==0 && (l=get_display_anchor(msg, hdr, body, &buf)) == 0) {
 			LM_ERR("failed to insert anchor\n");
 			LM_ERR("failed to insert anchor\n");
-			goto free2;
+			goto free1;
 		}
 		}
 		if (insert_new_lump_after(l, buf.s, buf.len, 0) == 0) {
 		if (insert_new_lump_after(l, buf.s, buf.len, 0) == 0) {
 			LM_ERR("insert new display lump failed\n");
 			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,
 	/* register tm callback to change replies,
 	 * but only if not registered earlier */
 	 * but only if not registered earlier */
 	if (!(msg->msg_flags & (FL_USE_UAC_FROM|FL_USE_UAC_TO)) &&
 	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;
 	return;
 
 
 free2:
 free2:
-	pkg_free(buf.s);
-
-free:
 	pkg_free(p);
 	pkg_free(p);
+
+free1:
+	pkg_free(buf.s);
 }
 }