[sr-dev] git:master:5e3880fb: tls: clone tokens for ipv6 address in tls profile for parsing

Daniel-Constantin Mierla miconda at gmail.com
Tue Feb 24 12:26:30 CET 2015


Module: kamailio
Branch: master
Commit: 5e3880fb0f71821639610ea5b74cafe9a6675a4c
URL: https://github.com/kamailio/kamailio/commit/5e3880fb0f71821639610ea5b74cafe9a6675a4c

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2015-02-24T12:25:38+01:00

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

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

---

Modified: modules/tls/tls_config.c

---

Diff:  https://github.com/kamailio/kamailio/commit/5e3880fb0f71821639610ea5b74cafe9a6675a4c.diff
Patch: https://github.com/kamailio/kamailio/commit/5e3880fb0f71821639610ea5b74cafe9a6675a4c.patch

---

diff --git a/modules/tls/tls_config.c b/modules/tls/tls_config.c
index 3960c5f..e1dca1b 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;




More information about the sr-dev mailing list