From fb22adcb927d384ca18af071c2f786eb91edfbe0 Mon Sep 17 00:00:00 2001 From: hwchan Date: Tue, 27 Feb 2018 05:14:50 +0800 Subject: [PATCH] Fix https://github.com/shadowsocks/shadowsocks-libev/issues/1945 Refer: https://github.com/dlundquist/sniproxy/commit/4af9a1b62b7987f2e9f3c561f589c10092d4e150 --- src/http.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/http.c b/src/http.c index 607b99a9..aae0f3d7 100644 --- a/src/http.c +++ b/src/http.c @@ -32,7 +32,7 @@ #include /* malloc() */ #include /* strncpy() */ #include /* strncasecmp() */ -#include /* isblank() */ +#include /* isblank(), isdigit() */ #include "http.h" #include "protocol.h" @@ -80,6 +80,7 @@ parse_http_header(const char *data, size_t data_len, char **hostname) /* * if the user specifies the port in the request, it is included here. * Host: example.com:80 + * Host: [2001:db8::1]:8080 * so we trim off port portion */ for (i = result - 1; i >= 0; i--) @@ -87,6 +88,8 @@ parse_http_header(const char *data, size_t data_len, char **hostname) (*hostname)[i] = '\0'; result = i; break; + } else if (!isdigit((*hostname)[i])) { + break; } return result;