瀏覽代碼

tls: minor fix: obey USE_IPV6

- if USE_IPV6 is not defined, don't try to parse/use ipv6
  addresses.

Reported-by: Juha Heinanen <[email protected]>
Andrei Pelinescu-Onciul 16 年之前
父節點
當前提交
443c6e5519
共有 1 個文件被更改,包括 10 次插入1 次删除
  1. 10 1
      modules/tls/tls_config.c

+ 10 - 1
modules/tls/tls_config.c

@@ -46,7 +46,7 @@
 static tls_cfg_t* cfg = NULL;
 static tls_domain_t* domain = NULL;
 
-
+#ifdef USE_IPV6
 static int parse_ipv6(struct ip_addr* ip, cfg_token_t* token, 
 					  cfg_parser_t* st)
 {
@@ -74,6 +74,7 @@ static int parse_ipv6(struct ip_addr* ip, cfg_token_t* token,
 	    st->file, token->start.line, token->start.col);
 	return -1;
 }
+#endif /* USE_IPV6 */
 
 
 static int parse_ipv4(struct ip_addr* ip, cfg_token_t* token, 
@@ -196,7 +197,15 @@ static int parse_hostport(int* type, struct ip_addr* ip, unsigned int* port,
 	}
 
 	if (t.type == '[') {
+#ifdef USE_IPV6
 		if (parse_ipv6(ip, &t, st) < 0) return -1;
+#else
+		ERR("%s:%d:%d: IPv6 address  not supported (compiled without IPv6"
+				" support)\n", 
+		    st->file, t.start.line, t.start.col);
+		return -1;
+	}
+#endif /* USE_IPV6 */
 	} else if (t.type == CFG_TOKEN_ALPHA) {
 		opt = cfg_lookup_token(token_default, &t.val);
 		if (opt) {