Kaynağa Gözat

modules_k/nathelper: replaced offending contact alias character
- Changed character ':' in contact alias paramater value to '~',
because ':' is not allowed in value field of generic contact
parameter.

Juha Heinanen 15 yıl önce
ebeveyn
işleme
ee37a2ce17
1 değiştirilmiş dosya ile 11 ekleme ve 3 silme
  1. 11 3
      modules_k/nathelper/nathelper.c

+ 11 - 3
modules_k/nathelper/nathelper.c

@@ -818,7 +818,7 @@ add_contact_alias_f(struct sip_msg* msg, char* str1, char* str2)
 	LM_ERR("you can't call alias_contact twice, check your config!\n");
 	return -1;
     }
-    param_len = SALIAS_LEN + IP6_MAX_STR_SIZE + 1 /* : */ + 5 /* port */ +
+    param_len = SALIAS_LEN + IP6_MAX_STR_SIZE + 1 /* ~ */ + 5 /* port */ +
 	1 /* t */ + 1 /* proto */;
     param = (char*)pkg_malloc(param_len);
     if (!param) {
@@ -834,7 +834,7 @@ add_contact_alias_f(struct sip_msg* msg, char* str1, char* str2)
 	return -1;
     }
     at = at + ip_len;
-    append_chr(at, ':');
+    append_chr(at, '~');
     port = int2str(msg->rcv.src_port, &len);
     append_str(at, port, len);
     append_chr(at, 't');
@@ -877,7 +877,8 @@ static int
 handle_ruri_alias_f(struct sip_msg* msg, char* str1, char* str2)
 {
     str uri, proto;
-    char buf[MAX_URI_SIZE], *val, *sep, *trans, *at, *next, *cur_uri, *rest;
+    char buf[MAX_URI_SIZE], *val, *sep, *trans, *at, *next, *cur_uri, *rest,
+	*col;
     unsigned int len, rest_len, val_len, alias_len, proto_type, cur_uri_len,
 	ip_port_len;
 
@@ -920,6 +921,13 @@ handle_ruri_alias_f(struct sip_msg* msg, char* str1, char* str2)
     append_str(at, "sip:", 4);
     ip_port_len = sep - val;
     alias_len = SALIAS_LEN + ip_port_len + 2 /* tn */;
+    /* replace ~ with : */
+    col = memchr(val, 126 /* ~ */, ip_port_len); 
+    if (col == NULL) {
+	LM_ERR("no '~' in alias param value\n");
+	return -1;
+    }
+    *(col) = ':';
     memcpy(at, val, ip_port_len);
     at = at + ip_port_len;
     trans = sep + 1;