Browse Source

corex: fix regression introduced with detection of ipv6 for send()

- reported by Paul Arnold, GH #496
Daniel-Constantin Mierla 9 years ago
parent
commit
8e20a3c5cf
1 changed files with 7 additions and 4 deletions
  1. 7 4
      modules/corex/corex_lib.c

+ 7 - 4
modules/corex/corex_lib.c

@@ -258,11 +258,14 @@ int corex_send(sip_msg_t *msg, gparam_t *pu, enum sip_protos proto)
 		u = &next_hop;
 		u->port_no = 5060;
 		u->host = dest;
-		p = dest.s;
 		/* detect ipv6 */
-		p = memchr(p, ']', dest.len);
-		if (p) p++;
-		p = memchr(p, ':', dest.len);
+		p = memchr(dest.s, ']', dest.len);
+		if (p) {
+			p++;
+			p = memchr(p, ':', dest.s + dest.len - p);
+		} else {
+			p = memchr(dest.s, ':', dest.len);
+		}
 		if (p)
 		{
 			u->host.len = p - dest.s;