Browse code

Revert "pv: fix $Au pseudo-variable, it contains incorrectly domain or realm (GH #2056)"

This reverts commit aa8f0820318762a393c41623cba3a5795225fb0a.

Henning Westerholt authored on 05/09/2019 19:31:16
Showing 1 changed files
... ...
@@ -1575,13 +1575,29 @@ static inline str *cred_realm(struct sip_msg *rq)
1575 1575
 int pv_get_acc_username(struct sip_msg *msg, pv_param_t *param,
1576 1576
 		pv_value_t *res)
1577 1577
 {
1578
+	static char buf[MAX_URI_SIZE];
1578 1579
 	str* user;
1580
+	str* realm;
1579 1581
 	struct sip_uri puri;
1580 1582
 	struct to_body* from;
1583
+	str s;
1581 1584
 
1582 1585
 	/* try to take it from credentials */
1583 1586
 	user = cred_user(msg);
1584 1587
 	if (user) {
1588
+		realm = cred_realm(msg);
1589
+		if (realm) {
1590
+			s.len = user->len+1+realm->len;
1591
+			if (s.len > MAX_URI_SIZE) {
1592
+				LM_ERR("uri too long\n");
1593
+				return pv_get_null(msg, param, res);
1594
+			}
1595
+			s.s = buf;
1596
+			memcpy(s.s, user->s, user->len);
1597
+			(s.s)[user->len] = '@';
1598
+			memcpy(s.s+user->len+1, realm->s, realm->len);
1599
+			return pv_get_strval(msg, param, res, &s);
1600
+		}
1585 1601
 		return pv_get_strval(msg, param, res, user);
1586 1602
 	}
1587 1603
 
... ...
@@ -1596,9 +1612,20 @@ int pv_get_acc_username(struct sip_msg *msg, pv_param_t *param,
1596 1612
 			LM_ERR("bad From URI\n");
1597 1613
 			return pv_get_null(msg, param, res);
1598 1614
 		}
1599
-		return pv_get_strval(msg, param, res, &(puri.user));
1615
+		s.len = puri.user.len + 1 + puri.host.len;
1616
+		if (s.len > MAX_URI_SIZE) {
1617
+			LM_ERR("from URI too long\n");
1618
+			return pv_get_null(msg, param, res);
1619
+		}
1620
+		s.s = buf;
1621
+		memcpy(s.s, puri.user.s, puri.user.len);
1622
+		(s.s)[puri.user.len] = '@';
1623
+		memcpy(s.s + puri.user.len + 1, puri.host.s, puri.host.len);
1624
+	} else {
1625
+		s.len = 0;
1626
+		s.s = 0;
1600 1627
 	}
1601
-	return pv_get_null(msg, param, res);
1628
+	return pv_get_strval(msg, param, res, &s);
1602 1629
 }
1603 1630
 
1604 1631
 int pv_get_branch(struct sip_msg *msg, pv_param_t *param,