From 5cf591a25416bd21085bd555f81e7200fad52450 Mon Sep 17 00:00:00 2001 From: Michael Santos Date: Sun, 17 Jun 2018 10:01:44 -0400 Subject: [PATCH] Avoid segfault with malformed IPv6 address A literal IPv6 address without a trailing bracket will result in a write past the end of the address buffer: ~~~ segfault.conf protocols: ( { name: "tls"; host: "["; port: "8443"; } ); ~~~ ~~~ $ sslh-select -p 127.0.0.1:443 --foreground -F./segfault.conf [: no closing bracket in IPv6 address? Segmentation fault (core dumped) ~~~ --- common.c | 1 + 1 file changed, 1 insertion(+) diff --git a/common.c b/common.c index 378eb9a..997507c 100644 --- a/common.c +++ b/common.c @@ -496,6 +496,7 @@ int resolve_split_name(struct addrinfo **out, const char* ct_host, const char* s end = strrchr(host, ']'); if (!end) { fprintf(stderr, "%s: no closing bracket in IPv6 address?\n", host); + return -1; } host++; /* skip first bracket */ *end = 0; /* remove last bracket */