Browse code

tls: clone tokens for ipv6 address in tls profile for parsing

- cfg parsing is moving the pointers, forgetting the previous parts

Daniel-Constantin Mierla authored on 24/02/2015 11:20:10
Showing 1 changed files
... ...
@@ -51,16 +51,19 @@ static int parse_ipv6(struct ip_addr* ip, cfg_token_t* token,
51 51
 	cfg_token_t t;
52 52
 	struct ip_addr* ipv6;
53 53
 	str ip6_str;
54
+	char ip6_buff[IP_ADDR_MAX_STR_SIZE+3];
54 55
 
55
-	ip6_str.s = t.val.s;
56
+	ip6_buff[0] = '\0';
56 57
 	while(1) {
57 58
 		ret = cfg_get_token(&t, st, 0);
58 59
 		if (ret != 0) goto err;
59 60
 		if (t.type == ']') break;
60 61
 		if (t.type != CFG_TOKEN_ALPHA && t.type != ':') goto err;
62
+		strncat(ip6_buff, t.val.s, t.val.len);
61 63
 	}
62
-	ip6_str.len = (int)(long)(t.val.s - ip6_str.s);
63
-
64
+	ip6_str.s = ip6_buff;
65
+	ip6_str.len = strlen(ip6_buff);
66
+	LM_DBG("found IPv6 address [%.*s]\n", ip6_str.len, ip6_str.s);
64 67
 	ipv6 = str2ip6(&ip6_str);
65 68
 	if (ipv6 == 0) goto err;
66 69
 	*ip = *ipv6;