From 5e3880fb0f71821639610ea5b74cafe9a6675a4c Mon Sep 17 00:00:00 2001 From: Daniel-Constantin Mierla Date: Tue, 24 Feb 2015 12:20:10 +0100 Subject: [PATCH] tls: clone tokens for ipv6 address in tls profile for parsing - cfg parsing is moving the pointers, forgetting the previous parts --- modules/tls/tls_config.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/modules/tls/tls_config.c b/modules/tls/tls_config.c index 3960c5f9159..e1dca1bd564 100644 --- a/modules/tls/tls_config.c +++ b/modules/tls/tls_config.c @@ -51,16 +51,19 @@ static int parse_ipv6(struct ip_addr* ip, cfg_token_t* token, cfg_token_t t; struct ip_addr* ipv6; str ip6_str; + char ip6_buff[IP_ADDR_MAX_STR_SIZE+3]; - ip6_str.s = t.val.s; + ip6_buff[0] = '\0'; while(1) { ret = cfg_get_token(&t, st, 0); if (ret != 0) goto err; if (t.type == ']') break; if (t.type != CFG_TOKEN_ALPHA && t.type != ':') goto err; + strncat(ip6_buff, t.val.s, t.val.len); } - ip6_str.len = (int)(long)(t.val.s - ip6_str.s); - + ip6_str.s = ip6_buff; + ip6_str.len = strlen(ip6_buff); + LM_DBG("found IPv6 address [%.*s]\n", ip6_str.len, ip6_str.s); ipv6 = str2ip6(&ip6_str); if (ipv6 == 0) goto err; *ip = *ipv6;